@esbuild-kit/esm-loader
Advanced tools
Comparing version 2.6.4 to 2.6.5
@@ -1,2 +0,2 @@ | ||
import l from"path";import{fileURLToPath as w,pathToFileURL as F}from"url";import{installSourceMapSupport as U,compareNodeVersion as p,resolveTsPath as D,transform as T,transformDynamicImport as S}from"@esbuild-kit/core-utils";import{parseTsconfig as I,getTsconfig as M,createFilesMatcher as W,createPathsMatcher as A}from"get-tsconfig";import k from"fs";const d=new Map;async function L(t){if(d.has(t))return d.get(t);if(!await k.promises.access(t).then(()=>!0,()=>!1)){d.set(t,void 0);return}const r=await k.promises.readFile(t,"utf8");try{const e=JSON.parse(r);return d.set(t,e),e}catch{throw new Error(`Error parsing: ${t}`)}}async function J(t){let s=new URL("package.json",t);for(;!s.pathname.endsWith("/node_modules/package.json");){const r=w(s),e=await L(r);if(e)return e;const o=s;if(s=new URL("../package.json",s),s.pathname===o.pathname)break}}async function b(t){var s;const r=await J(t);return(s=r==null?void 0:r.type)!=null?s:"commonjs"}const f=U(),u=process.env.ESBK_TSCONFIG_PATH?{path:l.resolve(process.env.ESBK_TSCONFIG_PATH),config:I(process.env.ESBK_TSCONFIG_PATH)}:M(),R=u&&W(u),N=u&&A(u),_="file://",h=/\.([cm]?ts|[tj]sx)$/,x=t=>{const s=l.extname(t);if(s===".json")return"json";if(s===".mjs"||s===".mts")return"module";if(s===".cjs"||s===".cts")return"commonjs"},O=t=>{const s=x(t);if(s)return s;if(h.test(t))return b(t)},C=p([20,0,0])>=0;let y=process.send?process.send.bind(process):void 0,E;const K=({port:t})=>(E=t,y=t.postMessage.bind(t),` | ||
import l from"path";import{fileURLToPath as y,pathToFileURL as U}from"url";import{installSourceMapSupport as I,compareNodeVersion as m,resolveTsPath as M,transform as S,transformDynamicImport as k}from"@esbuild-kit/core-utils";import{parseTsconfig as A,getTsconfig as J,createFilesMatcher as L,createPathsMatcher as W}from"get-tsconfig";import R from"fs";const f=new Map;async function b(t){if(f.has(t))return f.get(t);if(!await R.promises.access(t).then(()=>!0,()=>!1)){f.set(t,void 0);return}const e=await R.promises.readFile(t,"utf8");try{const n=JSON.parse(e);return f.set(t,n),n}catch{throw new Error(`Error parsing: ${t}`)}}async function $(t){let s=new URL("package.json",t);for(;!s.pathname.endsWith("/node_modules/package.json");){const e=y(s),n=await b(e);if(n)return n;const r=s;if(s=new URL("../package.json",s),s.pathname===r.pathname)break}}async function x(t){var s;const e=await $(t);return(s=e==null?void 0:e.type)!=null?s:"commonjs"}const u=I(),d=process.env.ESBK_TSCONFIG_PATH?{path:l.resolve(process.env.ESBK_TSCONFIG_PATH),config:A(process.env.ESBK_TSCONFIG_PATH)}:J(),N=d&&L(d),O=d&&W(d),w="file://",g=/\.([cm]?ts|[tj]sx)($|\?)/,_=/\.json(?:$|\?)/,C=t=>{const s=l.extname(t);if(s===".json")return"json";if(s===".mjs"||s===".mts")return"module";if(s===".cjs"||s===".cts")return"commonjs"},j=t=>{const s=C(t);if(s)return s;if(g.test(t))return x(t)},v=/\/(?:$|\?)/,K=m([20,0,0])>=0;let P=process.send?process.send.bind(process):void 0,E;const q=({port:t})=>(E=t,P=t.postMessage.bind(t),` | ||
const require = getBuiltin('module').createRequire("${import.meta.url}"); | ||
@@ -12,2 +12,2 @@ require('@esbuild-kit/core-utils').installSourceMapSupport(port); | ||
port.unref(); // Allows process to exit without waiting for port to close | ||
`),$=C?K:void 0,B=[".js",".json",".ts",".tsx",".jsx"];async function P(t,s,r){let e;for(const o of B)try{return await g(t+o,s,r,!0)}catch(a){if(e===void 0&&a instanceof Error){const{message:n}=a;a.message=a.message.replace(`${o}'`,"'"),a.stack=a.stack.replace(n,a.message),e=a}}throw e}async function j(t,s,r){const e=t.endsWith("/"),o=e?"index":"/index";try{return await P(t+o,s,r)}catch(a){if(!e)try{return await P(t,s,r)}catch{}const n=a,{message:c}=n;throw n.message=n.message.replace(`${o.replace("/",l.sep)}'`,"'"),n.stack=n.stack.replace(c,n.message),n}}const G=/^\.{1,2}\//,H=p([14,13,1])>=0||p([12,20,0])>=0,g=async function(t,s,r,e){var o;if(!H&&t.startsWith("node:")&&(t=t.slice(5)),t.endsWith("/"))return await j(t,s,r);const a=t.startsWith(_)||G.test(t);if(N&&!a&&!((o=s.parentURL)!=null&&o.includes("/node_modules/"))){const c=N(t);for(const i of c)try{return await g(F(i).toString(),s,r)}catch{}}if(h.test(s.parentURL)){const c=D(t);if(c)try{return await g(c,s,r,!0)}catch(i){const{code:m}=i;if(m!=="ERR_MODULE_NOT_FOUND"&&m!=="ERR_PACKAGE_PATH_NOT_EXPORTED")throw i}}let n;try{n=await r(t,s)}catch(c){if(c instanceof Error&&!e){const{code:i}=c;if(i==="ERR_UNSUPPORTED_DIR_IMPORT")try{return await j(t,s,r)}catch(m){if(m.code!=="ERR_PACKAGE_IMPORT_NOT_DEFINED")throw m}if(i==="ERR_MODULE_NOT_FOUND")try{return await P(t,s,r)}catch{}}throw c}return!n.format&&n.url.startsWith(_)&&(n.format=await O(n.url)),n},q=async function(t,s,r){var e;y&&y({type:"dependency",path:t}),t.endsWith(".json")&&(s.importAssertions||(s.importAssertions={}),s.importAssertions.type="json");const o=await r(t,s);if(!o.source)return o;const a=t.startsWith("file://")?w(t):t,n=o.source.toString();if(o.format==="json"||h.test(t)){const c=await T(n,a,{tsconfigRaw:(e=R)==null?void 0:e(a)});return{format:"module",source:f(c,t,E)}}if(o.format==="module"){const c=S(a,n);c&&(o.source=f(c,t,E))}return o},X=async function(t,s,r){if(t.endsWith(".json"))return{format:"module"};try{return await r(t,s,r)}catch(e){if(e.code==="ERR_UNKNOWN_FILE_EXTENSION"&&t.startsWith(_)){const o=await O(t);if(o)return{format:o}}throw e}},V=async function(t,s,r){var e;const{url:o}=s,a=o.startsWith("file://")?w(o):o;if(process.send&&process.send({type:"dependency",path:o}),o.endsWith(".json")||h.test(o)){const c=await T(t.toString(),a,{tsconfigRaw:(e=R)==null?void 0:e(a)});return{source:f(c,o)}}const n=await r(t,s,r);if(s.format==="module"){const c=S(a,n.source.toString());c&&(n.source=f(c,o))}return n},v=p([16,12,0])<0,z=v?X:void 0,Q=v?V:void 0;export{z as getFormat,$ as globalPreload,q as load,g as resolve,Q as transformSource}; | ||
`),B=K?q:void 0,G=[".js",".json",".ts",".tsx",".jsx"];async function T(t,s,e){const[n,r]=t.split("?");let i;for(const a of G)try{return await h(n+a+(r?`?${r}`:""),s,e,!0)}catch(o){if(i===void 0&&o instanceof Error){const{message:c}=o;o.message=o.message.replace(`${a}'`,"'"),o.stack=o.stack.replace(c,o.message),i=o}}throw i}async function F(t,s,e){const n=v.test(t),r=n?"index":"/index",[i,a]=t.split("?");try{return await T(i+r+(a?`?${a}`:""),s,e)}catch(o){if(!n)try{return await T(t,s,e)}catch{}const c=o,{message:p}=c;throw c.message=c.message.replace(`${r.replace("/",l.sep)}'`,"'"),c.stack=c.stack.replace(p,c.message),c}}const H=/^\.{1,2}\//,Q=m([14,13,1])>=0||m([12,20,0])>=0,h=async function(t,s,e,n){var r;if(!Q&&t.startsWith("node:")&&(t=t.slice(5)),v.test(t))return await F(t,s,e);const i=t.startsWith(w)||H.test(t);if(O&&!i&&!((r=s.parentURL)!=null&&r.includes("/node_modules/"))){const o=O(t);for(const c of o)try{return await h(U(c).toString(),s,e)}catch{}}if(g.test(s.parentURL)){const o=M(t);if(o)try{return await h(o,s,e,!0)}catch(c){const{code:p}=c;if(p!=="ERR_MODULE_NOT_FOUND"&&p!=="ERR_PACKAGE_PATH_NOT_EXPORTED")throw c}}let a;try{a=await e(t,s)}catch(o){if(o instanceof Error&&!n){const{code:c}=o;if(c==="ERR_UNSUPPORTED_DIR_IMPORT")try{return await F(t,s,e)}catch(p){if(p.code!=="ERR_PACKAGE_IMPORT_NOT_DEFINED")throw p}if(c==="ERR_MODULE_NOT_FOUND")try{return await T(t,s,e)}catch{}}throw o}return!a.format&&a.url.startsWith(w)&&(a.format=await j(a.url)),a},X=async function(t,s,e){var n;P&&P({type:"dependency",path:t}),_.test(t)&&(s.importAssertions||(s.importAssertions={}),s.importAssertions.type="json");const r=await e(t,s);if(!r.source)return r;const i=t.startsWith("file://")?y(t):t,a=r.source.toString();if(r.format==="json"||g.test(t)){const o=await S(a,i,{tsconfigRaw:(n=N)==null?void 0:n(i)});return{format:"module",source:u(o,t,E)}}if(r.format==="module"){const o=k(i,a);o&&(r.source=u(o,t,E))}return r},V=async function(t,s,e){if(_.test(t))return{format:"module"};try{return await e(t,s,e)}catch(n){if(n.code==="ERR_UNKNOWN_FILE_EXTENSION"&&t.startsWith(w)){const r=await j(t);if(r)return{format:r}}throw n}},z=async function(t,s,e){var n;const{url:r}=s,i=r.startsWith("file://")?y(r):r;if(process.send&&process.send({type:"dependency",path:r}),_.test(r)||g.test(r)){const o=await S(t.toString(),i,{tsconfigRaw:(n=N)==null?void 0:n(i)});return{source:u(o,r)}}const a=await e(t,s,e);if(s.format==="module"){const o=k(i,a.source.toString());o&&(a.source=u(o,r))}return a},D=m([16,12,0])<0,Y=D?V:void 0,Z=D?z:void 0;export{Y as getFormat,B as globalPreload,X as load,h as resolve,Z as transformSource}; |
{ | ||
"name": "@esbuild-kit/esm-loader", | ||
"version": "2.6.4", | ||
"version": "2.6.5", | ||
"publishConfig": { | ||
@@ -28,5 +28,5 @@ "access": "public" | ||
"dependencies": { | ||
"@esbuild-kit/core-utils": "^3.3.0", | ||
"@esbuild-kit/core-utils": "^3.3.2", | ||
"get-tsconfig": "^4.7.0" | ||
} | ||
} |
@@ -12,2 +12,3 @@ # esm-loader | ||
- Resolves `tsconfig.json` [`paths`](https://www.typescriptlang.org/tsconfig#paths) | ||
- Named imports from JSON modules | ||
@@ -14,0 +15,0 @@ > **Protip: use with _cjs-loader_ or _tsx_** |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13364
156