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.1.0 to 2.1.1

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

@@ -34,3 +34,3 @@ "access": "public"

"dependencies": {
"@esbuild-kit/core-utils": "^1.1.0",
"@esbuild-kit/core-utils": "^1.1.2",
"es-module-lexer": "^0.10.5",

@@ -37,0 +37,0 @@ "get-tsconfig": "^3.0.1"

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