ts-arc 1.1.6 → 1.1.8

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 -3
  2. package/package.json +1 -1
package/dist/loader.js CHANGED
@@ -1,4 +1,3 @@
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:`
1
+ import*as _ from"fs";import*as l from"path";import*as h from"url";import{transformSync as D}from"esbuild";let m;function b(r){m=r}async function y(r,i,e){if(!(r.startsWith(".")||r.startsWith("/"))){if(m){const{baseUrl:t,paths:o,tsconfigDir:d}=m,O=t?l.resolve(d??"",t):d;for(const s of Object.keys(o)){let a=null,c=s.endsWith("/*");const n=c?s.slice(0,-2):s;if(c?r.startsWith(n+"/")&&(a=r.slice(n.length+1)):r===s&&(a=""),a!==null)for(const p of o[s]){const U=`./${c?p.replace(/\*/g,a):p}`,R=O??process.cwd(),w=h.pathToFileURL(l.join(R,"dummy.ts")).href;try{return{...await y(U,{parentURL:w},e),shortCircuit:!0}}catch(u){if(console.error(`TS-ARC: Failed to resolve mapped specifier "${U}" from base "${R}":`,u.message),u.code!=="ERR_MODULE_NOT_FOUND")throw u}}}if(t){const s=l.resolve(d??"",t),a=`./${r}`,c=h.pathToFileURL(l.join(s,"dummy.ts")).href;try{return{...await y(a,{parentURL:c},e),shortCircuit:!0}}catch(n){if(console.error(`TS-ARC: Failed to resolve specifier "${r}" from baseUrl "${s}":`,n.message),n.code!=="ERR_MODULE_NOT_FOUND")throw n}}}try{return{...await e(r,i),shortCircuit:!0}}catch(t){throw t.code==="ERR_MODULE_NOT_FOUND",t}}try{return{...await e(r,i),shortCircuit:!0}}catch(t){if(t.code!=="ERR_MODULE_NOT_FOUND")throw t}if(l.extname(r)!=="")throw new Error(`Module not found: ${r}`);for(const t of[".ts",".tsx"])try{return{...await e(r+t,i),shortCircuit:!0}}catch(o){if(o.code!=="ERR_MODULE_NOT_FOUND")throw o}for(const t of["/index.ts","/index.tsx"])try{return{...await e(r+t,i),shortCircuit:!0}}catch(o){if(o.code!=="ERR_MODULE_NOT_FOUND")throw o}throw new Error(`Module not found: ${r}`)}async function E(r,i,e){if(!r.endsWith(".ts")&&!r.endsWith(".tsx"))return e(r,i);const g=r.endsWith(".tsx")?"tsx":"ts",f=h.fileURLToPath(r),t=_.readFileSync(f,"utf8"),{code:o}=D(t,{loader:g,format:"esm",target:`node${process.versions.node}`,sourcemap:"inline",sourcefile:f,banner:`
3
2
  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};
3
+ const require = createRequire(import.meta.url);`});return{format:"module",source:o,shortCircuit:!0}}export{b as initialize,E as load,y 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.8",
4
4
  "type": "module",
5
5
  "description": "A simple typescript runtime.",
6
6
  "main": "dist/bin.js",