ts-arc 1.1.6 → 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.
Files changed (2) hide show
  1. package/dist/loader.js +2 -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 v(t){l=t}async function R(t,s,o){if(!(t.startsWith(".")||t.startsWith("/"))&&(console.debug("Resolving,",t,"with tsconfig:",l),l)){const{baseUrl:r,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(t.startsWith(e)){let a=t.slice(e.length);i=a.startsWith("/")?a.slice(1):a}}else t===n&&(i="");if(i!==null)for(const e of c[n]){const a=e.replace(/\*/g,i),m=r??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(r){const n=h.pathToFileURL(y.join(r,"dummy.ts")).href,i=`./${t}`;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}}}try{return{...await o(t,s),shortCircuit:!0}}catch(r){if(r.code!=="ERR_MODULE_NOT_FOUND")throw r}try{return{...await o(t+".ts",s),shortCircuit:!0}}catch(r){if(r.code!=="ERR_MODULE_NOT_FOUND")throw r}try{return{...await o(t+".tsx",s),shortCircuit:!0}}catch(r){if(r.code!=="ERR_MODULE_NOT_FOUND")throw r}try{return{...await o(t+"/index.ts",s),shortCircuit:!0}}catch(r){if(r.code!=="ERR_MODULE_NOT_FOUND")throw r}try{return{...await o(t+"/index.tsx",s),shortCircuit:!0}}catch(r){throw r}}async function C(t,s,o){if(!t.endsWith(".ts")&&!t.endsWith(".tsx"))return o(t,s);const d=t.endsWith(".tsx")?"tsx":"ts",r=h.fileURLToPath(t),c=w.readFileSync(r,"utf8"),{code:u}=O(c,{loader:d,format:"esm",target:`node${process.versions.node}`,sourcemap:"inline",sourcefile:r,banner:`
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{v as initialize,C as load,R as resolve};
4
+ const require = createRequire(import.meta.url);`});return{format:"module",source:u,shortCircuit:!0}}export{_ as initialize,C as load,R as resolve};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-arc",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "type": "module",
5
5
  "description": "A simple typescript runtime.",
6
6
  "main": "dist/bin.js",