ts-arc 1.1.11 → 1.1.12

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 +1 -1
  2. package/package.json +1 -1
package/dist/loader.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import*as m from"fs";import*as o from"path";import*as d from"url";import{transformSync as x}from"esbuild";let p={baseUrl:null,paths:{},tsconfigDir:null};function b(t){p=t}function y(){const{baseUrl:t,tsconfigDir:s}=p;return t?o.resolve(s??process.cwd(),t):null}async function h(t,s){const r=o.resolve(t,s),c=[r,r+".ts",r+".tsx",o.join(r,"index.ts"),o.join(r,"index.tsx"),o.join(r,"page.ts"),o.join(r,"page.tsx")];for(const a of c)try{if(m.existsSync(a)&&m.statSync(a).isFile())return{url:d.pathToFileURL(a).href}}catch{}throw Object.assign(new Error(`Cannot find module '${s}'`),{code:"ERR_MODULE_NOT_FOUND"})}async function P(t,s,r){let c=process.cwd();if(s.parentURL&&(c=o.dirname(d.fileURLToPath(s.parentURL))),t.startsWith("file://")){const n=d.fileURLToPath(t),i=o.dirname(n),u=o.basename(n),e=(o.extname(u),u);return{...await h(i,e),shortCircuit:!0}}if(t.startsWith(".")||t.startsWith("/"))return{...await h(c,t),shortCircuit:!0};{console.log("Attempting to resolve non path-like specifier",t);const{paths:n}=p,i=y();console.log("That specifiers effectiveBase is:",t);for(const e of Object.keys(n)){let l=null;const f=e.endsWith("/*"),v=f?e.slice(0,-2):e;if(f&&t.startsWith(v+"/")?l=t.slice(v.length+1):!f&&t===e&&(l=""),l!==null)for(const R of n[e]){const U=f?R.replace(/\*/g,l):R;if(i)try{return{...await h(i,U),shortCircuit:!0}}catch(g){if(g.code!=="ERR_MODULE_NOT_FOUND")throw g}}}if(i)try{return{...await h(i,t),shortCircuit:!0}}catch(e){if(e.code!=="ERR_MODULE_NOT_FOUND")throw e}return{...await r(t,s),shortCircuit:!0}}}async function w(t,s,r){if(!t.endsWith(".ts")&&!t.endsWith(".tsx"))return r(t,s);const c=t.endsWith(".tsx")?"tsx":"ts",a=d.fileURLToPath(t),n=m.readFileSync(a,"utf8"),{code:i}=x(n,{loader:c,format:"esm",target:`node${process.versions.node}`,sourcemap:"inline",sourcefile:a,banner:`
2
+ import*as m from"fs";import*as o from"path";import*as d from"url";import{transformSync as x}from"esbuild";let p={baseUrl:null,paths:{},tsconfigDir:null};function b(t){p=t}function y(){const{baseUrl:t,tsconfigDir:s}=p;return t?o.resolve(s??process.cwd(),t):null}async function g(t,s){const r=o.resolve(t,s),c=[r,r+".ts",r+".tsx",o.join(r,"index.ts"),o.join(r,"index.tsx"),o.join(r,"page.ts"),o.join(r,"page.tsx")];for(const a of c)try{if(m.existsSync(a)&&m.statSync(a).isFile())return{url:d.pathToFileURL(a).href}}catch{}throw Object.assign(new Error(`Cannot find module '${s}'`),{code:"ERR_MODULE_NOT_FOUND"})}async function P(t,s,r){let c=process.cwd();if(s.parentURL&&(c=o.dirname(d.fileURLToPath(s.parentURL))),t.startsWith("file://")){const n=d.fileURLToPath(t),i=o.dirname(n),u=o.basename(n),e=(o.extname(u),u);return{...await g(i,e),shortCircuit:!0}}if(t.startsWith(".")||t.startsWith("/"))return console.log("Attempting to resolve a path-like specifier:",t),{...await g(c,t),shortCircuit:!0};{console.log("Attempting to resolve non path-like specifier:",t);const{paths:n}=p,i=y();console.log("That specifiers effectiveBase is:",t);for(const e of Object.keys(n)){let l=null;const f=e.endsWith("/*"),v=f?e.slice(0,-2):e;if(f&&t.startsWith(v+"/")?l=t.slice(v.length+1):!f&&t===e&&(l=""),l!==null)for(const R of n[e]){const U=f?R.replace(/\*/g,l):R;if(i)try{return{...await g(i,U),shortCircuit:!0}}catch(h){if(h.code!=="ERR_MODULE_NOT_FOUND")throw h}}}if(i)try{return{...await g(i,t),shortCircuit:!0}}catch(e){if(e.code!=="ERR_MODULE_NOT_FOUND")throw e}return{...await r(t,s),shortCircuit:!0}}}async function w(t,s,r){if(!t.endsWith(".ts")&&!t.endsWith(".tsx"))return r(t,s);const c=t.endsWith(".tsx")?"tsx":"ts",a=d.fileURLToPath(t),n=m.readFileSync(a,"utf8"),{code:i}=x(n,{loader:c,format:"esm",target:`node${process.versions.node}`,sourcemap:"inline",sourcefile:a,banner:`
3
3
  import { createRequire } from 'module';
4
4
  const require = createRequire(import.meta.url);`});return{format:"module",source:i,shortCircuit:!0}}export{b as initialize,w as load,P as resolve};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-arc",
3
- "version": "1.1.11",
3
+ "version": "1.1.12",
4
4
  "type": "module",
5
5
  "description": "A simple typescript runtime.",
6
6
  "main": "dist/bin.js",