Socket
Socket
Sign inDemoInstall

@esbuild-kit/esm-loader

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@esbuild-kit/esm-loader - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

2

dist/index.js

@@ -1,1 +0,1 @@

import{installSourceMapSupport as d,transform as u,transformDynamicImport as g}from"@esbuild-kit/core-utils";import w from"get-tsconfig";import J from"path";import{init as $}from"es-module-lexer";import _ from"fs";import{fileURLToPath as N}from"url";const c=/\.([cm]?ts|[tj]sx)$/,y=t=>{const n=J.extname(t);if(n===".mts")return"module";if(n===".cts")return"commonjs"};$.then(()=>{});const m=new Map;async function W(t){if(m.has(t))return m.get(t);if(!await _.promises.access(t).then(()=>!0,()=>!1)){m.set(t,void 0);return}const o=await _.promises.readFile(t,"utf8");try{const r=JSON.parse(o);return m.set(t,r),r}catch{throw new Error(`Error parsing: ${t}`)}}async function b(t){let n=new URL("package.json",t);for(;!n.pathname.endsWith("/node_modules/package.json");){const o=N(n),r=await W(o);if(r)return r;const s=n;if(n=new URL("../package.json",n),n.pathname===s.pathname)break}}async function h(t){var n;const o=await b(t);return(n=o==null?void 0:o.type)!=null?n:"commonjs"}var T=Object.defineProperty,I=Object.defineProperties,R=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,x=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable,j=(t,n,o)=>n in t?T(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,P=(t,n)=>{for(var o in n||(n={}))x.call(n,o)&&j(t,o,n[o]);if(O)for(var o of O(n))F.call(n,o)&&j(t,o,n[o]);return t},l=(t,n)=>I(t,R(n));const k=d(),E=w(),L=E==null?void 0:E.config,M=/\.\w+$/,S=[".js",".json",".ts",".tsx",".jsx"],A=[...S,...S.map(t=>`/index${t}`)],i=async function(t,n,o){var r;if(t.startsWith("node:")&&(t=t.slice(5)),t.endsWith("/"))return i(`${t}index`,n,o);if(/\.[cm]js$/.test(t)&&c.test(n.parentURL))try{return await i(`${t.slice(0,-2)}ts`,n,o)}catch(s){if(s.code!=="ERR_MODULE_NOT_FOUND")throw s}if(c.test(t)){const s=await o(t,n,o),e=(r=y(s.url))!=null?r:await h(s.url);return l(P({},s),{format:e})}if(t.endsWith(".json"))return l(P({},await o(t,n,o)),{format:"json"});try{return await o(t,n,o)}catch(s){if(s instanceof Error){if(s.code==="ERR_UNSUPPORTED_DIR_IMPORT")return i(`${t}/index`,n,o);if(s.code==="ERR_MODULE_NOT_FOUND"&&!M.test(t))for(const e of A)try{const a=t+(t.endsWith("/")&&e.startsWith("/")?e.slice(1):e);return await i(a,n,o)}catch{}}throw s}},V=async function(t,n,o){process.send&&process.send({type:"dependency",path:t}),t.endsWith(".json")&&(n.importAssertions||(n.importAssertions={}),n.importAssertions.type="json");const r=await o(t,n,o);if(!r.source||t.includes("/node_modules/"))return r;const s=r.source.toString();if(r.format==="json"||c.test(t)){const a=await u(s,t,{format:"esm",tsconfigRaw:L});return a.map&&k.set(t,a.map),{format:"module",source:a.code}}const e=g({code:s});return e&&(r.source=e.code,e.map&&k.set(t,e.map)),r},v=w(),C=v==null?void 0:v.config,U=d(),q=async function(t,n,o){var r;return t.endsWith(".json")?{format:"module"}:c.test(t)?{format:(r=y(t))!=null?r:await h(t)}:await o(t,n,o)},z=async function(t,n,o){const{url:r}=n;if(process.send&&process.send({type:"dependency",path:r}),r.endsWith(".json")||c.test(r)){const a=await u(t.toString(),r,{format:"esm",tsconfigRaw:C});return a.map&&U.set(r,a.map),{source:a.code}}const s=await o(t,n,o),e=g({code:s.source});return e&&(s.source=e.code,e.map&&U.set(r,e.map)),s},p=[16,12,0],f=process.version.slice(1).split(".").map(Number),D=(f[0]-p[0]||f[1]-p[1]||f[2]-p[2])<0,B=D?q:void 0,H=D?z:void 0;export{B as getFormat,V as load,i as resolve,H as transformSource};
import{installSourceMapSupport as d,transform as u,transformDynamicImport as g}from"@esbuild-kit/core-utils";import w from"get-tsconfig";import R from"path";import{init as $}from"es-module-lexer";import _ from"fs";import{fileURLToPath as N}from"url";const c=/\.([cm]?ts|[tj]sx)$/,y=t=>{const o=R.extname(t);if(o===".mts")return"module";if(o===".cts")return"commonjs"};$.then(()=>{});const p=new Map;async function W(t){if(p.has(t))return p.get(t);if(!await _.promises.access(t).then(()=>!0,()=>!1)){p.set(t,void 0);return}const r=await _.promises.readFile(t,"utf8");try{const s=JSON.parse(r);return p.set(t,s),s}catch{throw new Error(`Error parsing: ${t}`)}}async function b(t){let o=new URL("package.json",t);for(;!o.pathname.endsWith("/node_modules/package.json");){const r=N(o),s=await W(r);if(s)return s;const e=o;if(o=new URL("../package.json",o),o.pathname===e.pathname)break}}async function h(t){var o;const r=await b(t);return(o=r==null?void 0:r.type)!=null?o:"commonjs"}var x=Object.defineProperty,T=Object.defineProperties,I=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable,O=(t,o,r)=>o in t?x(t,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[o]=r,j=(t,o)=>{for(var r in o||(o={}))F.call(o,r)&&O(t,r,o[r]);if(l)for(var r of l(o))L.call(o,r)&&O(t,r,o[r]);return t},v=(t,o)=>T(t,I(o));const P=d(),k=w(),M=k==null?void 0:k.config,A=/\.\w+$/,E=[".js",".json",".ts",".tsx",".jsx"],V=[...E,...E.map(t=>`/index${t}`)],i=async function(t,o,r){var s;if(t.startsWith("node:")&&(t=t.slice(5)),t.endsWith("/"))return i(`${t}index`,o,r);if(/\.[cm]js$/.test(t)&&c.test(o.parentURL))try{return await i(`${t.slice(0,-2)}ts`,o,r)}catch(n){if(n.code!=="ERR_MODULE_NOT_FOUND")throw n}let e;try{e=await r(t,o,r)}catch(n){if(n instanceof Error){if(n.code==="ERR_UNSUPPORTED_DIR_IMPORT")return i(`${t}/index`,o,r);if(n.code==="ERR_MODULE_NOT_FOUND"&&!A.test(t))for(const a of V)try{const J=t+(t.endsWith("/")&&a.startsWith("/")?a.slice(1):a);return await i(J,o,r)}catch{}}throw n}if(e.url.endsWith(".json"))return v(j({},e),{format:"json"});if(c.test(e.url)){const n=(s=y(e.url))!=null?s:await h(e.url);return v(j({},e),{format:n})}return e},C=async function(t,o,r){process.send&&process.send({type:"dependency",path:t}),t.endsWith(".json")&&(o.importAssertions||(o.importAssertions={}),o.importAssertions.type="json");const s=await r(t,o,r);if(!s.source)return s;const e=s.source.toString();if(s.format==="json"||c.test(t)){const a=await u(e,t,{format:"esm",tsconfigRaw:M});return a.map&&P.set(t,a.map),{format:"module",source:a.code}}const n=g({code:e});return n&&(s.source=n.code,n.map&&P.set(t,n.map)),s},S=w(),q=S==null?void 0:S.config,U=d(),z=async function(t,o,r){var s;return t.endsWith(".json")?{format:"module"}:c.test(t)?{format:(s=y(t))!=null?s:await h(t)}:await r(t,o,r)},B=async function(t,o,r){const{url:s}=o;if(process.send&&process.send({type:"dependency",path:s}),s.endsWith(".json")||c.test(s)){const a=await u(t.toString(),s,{format:"esm",tsconfigRaw:q});return a.map&&U.set(s,a.map),{source:a.code}}const e=await r(t,o,r),n=g({code:e.source});return n&&(e.source=n.code,n.map&&U.set(s,n.map)),e},m=[16,12,0],f=process.version.slice(1).split(".").map(Number),D=(f[0]-m[0]||f[1]-m[1]||f[2]-m[2])<0,H=D?z:void 0,K=D?B:void 0;export{H as getFormat,C as load,i as resolve,K as transformSource};
{
"name": "@esbuild-kit/esm-loader",
"version": "2.0.0",
"version": "2.1.0",
"publishConfig": {

@@ -5,0 +5,0 @@ "access": "public"

@@ -14,5 +14,5 @@ # esm-loader

>
> _esm-loader_ doesn't hook into `require()` calls.
> _esm-loader_ doesn't hook into `require()` calls or transform CommonJS files (`.js` in commonjs package, `.cjs`, `.cts`).
>
> Use this with [cjs-loader](https://github.com/esbuild-kit/cjs-loader) for `require()` support. Alternatively, use [tsx](https://github.com/esbuild-kit/tsx) to handle them both automatically.
> Use this with [cjs-loader](https://github.com/esbuild-kit/cjs-loader) for CommonJS support. Alternatively, use [tsx](https://github.com/esbuild-kit/tsx) to handle them both automatically.

@@ -19,0 +19,0 @@ ## Install

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc