ts-arc 1.1.5 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/loader.js +2 -2
- package/package.json +1 -1
package/dist/loader.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import*as w from"fs";import*as y from"path";import*as h from"url";import{transformSync as O}from"esbuild";let l;function
|
|
2
|
+
import*as w from"fs";import*as y from"path";import*as h from"url";import{transformSync as O}from"esbuild";let l;function _(r){l=r}async function R(r,s,o){if(!(r.startsWith(".")||r.startsWith("/"))&&(console.debug("Resolving,",r,"with tsconfig:",l),l)){const{baseUrl:t,paths:c,tsconfigDir:u}=l;for(const n of Object.keys(c)){let i=null;if(n.endsWith("/*")){const e=n.slice(0,-2);if(r.startsWith(e)){let a=r.slice(e.length);i=a.startsWith("/")?a.slice(1):a}}else r===n&&(i="");if(i!==null)for(const e of c[n]){const a=e.replace(/\*/g,i),m=t??u,g=`./${a}`;if(m){const U=h.pathToFileURL(y.join(m,"dummy.ts")).href;try{return{...await R(g,{parentURL:U},o),shortCircuit:!0}}catch(f){if(console.error("TS-ARC: Could not find a module with a resolved filePath of:",g),f.code!=="ERR_MODULE_NOT_FOUND")throw f}}}}if(t){const n=h.pathToFileURL(y.join(t,"dummy.ts")).href,i=`./${r}`;try{return{...await R(i,{parentURL:n},o),shortCircuit:!0}}catch(e){if(e.code!=="ERR_MODULE_NOT_FOUND")throw console.error("TS-ARC: Could not find a module with a resolved filePath of:",i),e}}}console.log("Module path",r,"is relative.");try{return{...await o(r,s),shortCircuit:!0}}catch(t){if(t.code!=="ERR_MODULE_NOT_FOUND")throw t}try{return{...await o(r+".ts",s),shortCircuit:!0}}catch(t){if(t.code!=="ERR_MODULE_NOT_FOUND")throw t}try{return{...await o(r+".tsx",s),shortCircuit:!0}}catch(t){if(t.code!=="ERR_MODULE_NOT_FOUND")throw t}try{return{...await o(r+"/index.ts",s),shortCircuit:!0}}catch(t){if(t.code!=="ERR_MODULE_NOT_FOUND")throw t}try{return{...await o(r+"/index.tsx",s),shortCircuit:!0}}catch(t){throw t}}async function C(r,s,o){if(!r.endsWith(".ts")&&!r.endsWith(".tsx"))return o(r,s);const d=r.endsWith(".tsx")?"tsx":"ts",t=h.fileURLToPath(r),c=w.readFileSync(t,"utf8"),{code:u}=O(c,{loader:d,format:"esm",target:`node${process.versions.node}`,sourcemap:"inline",sourcefile:t,banner:`
|
|
3
3
|
import { createRequire } from 'module';
|
|
4
|
-
const require = createRequire(import.meta.url);`});return{format:"module",source:u,shortCircuit:!0}}export{
|
|
4
|
+
const require = createRequire(import.meta.url);`});return{format:"module",source:u,shortCircuit:!0}}export{_ as initialize,C as load,R as resolve};
|