ts-arc 1.1.1 → 1.1.2

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/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # ts-arc
2
+ A simple & fast typescript runner.
3
+ ## Usage
4
+ `npx ts-arc [filename].ts`
5
+
6
+ ## Features
7
+ - Full TypeScript Support!
8
+ - CommonJS Interoperability.
package/dist/loader.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import*as O from"fs";import*as g from"path";import*as l from"url";import{transformSync as R}from"esbuild";let h;function w(t){h=t}async function y(t,s,e){if(!(t.startsWith(".")||t.startsWith("/"))&&h){const{baseUrl:r,paths:a,tsconfigDir:u}=h;for(const i of Object.keys(a)){let o=null;if(i.endsWith("/*")){const c=i.slice(0,-2);if(t.startsWith(c)){const n=t.slice(c.length);(n===""||n.startsWith("/"))&&(o=n,o.startsWith("/")&&(o=o.slice(1)))}}else t===i&&(o="");if(o!==null)for(const c of a[i]){const n=c.replace(/\*/g,o),m=r??u;if(m){const U=l.pathToFileURL(g.join(m,"dummy.ts")).href;try{return{...await y(`./${n}`,{parentURL:U},e),shortCircuit:!0}}catch(f){if(f.code!=="ERR_MODULE_NOT_FOUND")throw f}}}}if(r){const i=l.pathToFileURL(g.join(r,"dummy.ts")).href;try{return{...await y(`./${t}`,{parentURL:i},e),shortCircuit:!0}}catch(o){if(o.code!=="ERR_MODULE_NOT_FOUND")throw o}}}try{return{...await e(t,s),shortCircuit:!0}}catch(r){if(r.code!=="ERR_MODULE_NOT_FOUND")throw r}try{return{...await e(t+".ts",s),shortCircuit:!0}}catch(r){if(r.code!=="ERR_MODULE_NOT_FOUND")throw r}try{return{...await e(t+".tsx",s),shortCircuit:!0}}catch(r){if(r.code!=="ERR_MODULE_NOT_FOUND")throw r}try{return{...await e(t+"/index.ts",s),shortCircuit:!0}}catch(r){if(r.code!=="ERR_MODULE_NOT_FOUND")throw r}try{return{...await e(t+"/index.tsx",s),shortCircuit:!0}}catch(r){throw r}}async function p(t,s,e){if(!t.endsWith(".ts")&&!t.endsWith(".tsx"))return e(t,s);const d=t.endsWith(".tsx")?"tsx":"ts",r=l.fileURLToPath(t),a=O.readFileSync(r,"utf8"),{code:u}=R(a,{loader:d,format:"esm",target:`node${process.versions.node}`,sourcemap:"inline",sourcefile:r,banner:`
2
+ import*as O from"fs";import*as g from"path";import*as f from"url";import{transformSync as R}from"esbuild";let h;function w(t){h=t}async function y(t,s,o){if(!(t.startsWith(".")||t.startsWith("/"))&&h){const{baseUrl:r,paths:a,tsconfigDir:u}=h;for(const i of Object.keys(a)){let e=null;if(i.endsWith("/*")){const c=i.slice(0,-2);if(t.startsWith(c)){let n=t.slice(c.length);e=n.startsWith("/")?n.slice(1):n}}else t===i&&(e="");if(e!==null)for(const c of a[i]){const n=c.replace(/\*/g,e),m=r??u;if(m){const U=f.pathToFileURL(g.join(m,"dummy.ts")).href;try{return{...await y(`./${n}`,{parentURL:U},o),shortCircuit:!0}}catch(l){if(l.code!=="ERR_MODULE_NOT_FOUND")throw l}}}}if(r){const i=f.pathToFileURL(g.join(r,"dummy.ts")).href;try{return{...await y(`./${t}`,{parentURL:i},o),shortCircuit:!0}}catch(e){if(e.code!=="ERR_MODULE_NOT_FOUND")throw 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 p(t,s,o){if(!t.endsWith(".ts")&&!t.endsWith(".tsx"))return o(t,s);const d=t.endsWith(".tsx")?"tsx":"ts",r=f.fileURLToPath(t),a=O.readFileSync(r,"utf8"),{code:u}=R(a,{loader:d,format:"esm",target:`node${process.versions.node}`,sourcemap:"inline",sourcefile:r,banner:`
3
3
  import { createRequire } from 'module';
4
4
  const require = createRequire(import.meta.url);`});return{format:"module",source:u,shortCircuit:!0}}export{w as initialize,p as load,y as resolve};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-arc",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "type": "module",
5
5
  "description": "A simple typescript runtime.",
6
6
  "main": "dist/bin.js",