@d1g1tal/tsnode 1.0.0 → 1.1.0
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/api/index.js +3 -3
- package/dist/cli.js +4 -4
- package/dist/loader.d.ts +41 -1
- package/dist/{package-O4DS43QB.js → package-75ORL5F6.js} +1 -1
- package/package.json +4 -4
- /package/dist/{run-eval-in-process-LFWU3AL6.js → run-eval-in-process-FSY2ACC3.js} +0 -0
- /package/dist/{run-in-process-5OFAUP24.js → run-in-process-G4BTEPTH.js} +0 -0
package/dist/api/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as $,g as G,h as q}from"../chunk-G3UY36AV.js";import{a as D}from"../chunk-QZ6GOFQ4.js";import{a as B,b as z}from"../chunk-UY7ICRUU.js";import{a as C,b as S,c as m,f as I,g,h as j,i as U,j as W}from"../chunk-CWI5WFAA.js";import
|
|
2
|
-
`)},y=Ft(G(" ESM "));import{createRequire as
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,`,lt=({code:t,map:e})=>e?t+
|
|
1
|
+
import{a as $,g as G,h as q}from"../chunk-G3UY36AV.js";import{a as D}from"../chunk-QZ6GOFQ4.js";import{a as B,b as z}from"../chunk-UY7ICRUU.js";import{a as C,b as S,c as m,f as I,g,h as j,i as U,j as W}from"../chunk-CWI5WFAA.js";import rr from"node:module";import T from"node:path";import Ut from"node:fs";var d=class{static parse(e){return JSON.parse(e)}static serialize(e){return JSON.stringify(e)}};var P=t=>{try{return d.parse(Ut.readFileSync(t,"utf8"))}catch{}};var V=Symbol("missing-tsconfig"),Q=new Map,Dt=t=>{let e=P(t);if(!e)return;let{compilerOptions:{baseUrl:r,paths:s={},allowJs:n=!1}={}}=e;return{compilerOptions:{allowJs:n,baseUrl:T.resolve(T.dirname(t),r||"."),paths:s}}},X=(t,e)=>{let r=[],{baseUrl:s,paths:n}=t.compilerOptions;for(let[o,i]of Object.entries(n)){let a=o.indexOf("*");if(a===-1&&e!==o)continue;let c=a===-1?"":void 0;if(a!==-1){let p=o.slice(0,a),f=o.slice(a+1);if(!e.startsWith(p)||!e.endsWith(f))continue;c=e.slice(p.length,e.length-f.length)}for(let p of i)r.push(T.resolve(s,p.replaceAll("*",c)))}return r};var K=(t="tsconfig.json")=>T.resolve(t),Y=(t="tsconfig.json")=>{let e=T.resolve(t),r=Q.get(e);if(r!==void 0)return r===V?void 0:r;let s=Dt(e);return Q.set(e,s??V),s};var R=t=>{if(t.tsconfig===!1){t.hasLoadedTsconfig=!0;return}return t.hasLoadedTsconfig||(t.parsedTsconfig=Y(t.tsconfig??process.env?.TSNODE_TSCONFIG_PATH),t.hasLoadedTsconfig=!0),t.parsedTsconfig},Z=t=>({active:!0,hasLoadedTsconfig:!1,namespace:t?.namespace,onImport:t?.onImport,parsedTsconfig:void 0,virtualSources:t?.virtualSources,tsconfig:t?.tsconfig});import{fileURLToPath as Re}from"node:url";import{writeSync as Lt}from"node:fs";import{createRequire as _t}from"node:module";var h=Number(process.env.TSNODE_DEBUG);h&&$(!0);var tt,Mt=()=>(tt??=_t(import.meta.url)("node:util").inspect,tt),Ft=t=>(e,...r)=>{if(!h||e>h)return;let s=Mt(),n=r.map(o=>typeof o=="string"?o:s(o,{colors:!0})).join(" ");Lt(1,`${`${q(` tsnode P${process.pid} `)} ${t}`} ${n}
|
|
2
|
+
`)},y=Ft(G(" ESM "));import{createRequire as se,stripTypeScriptTypes as ne}from"node:module";import oe from"node:path";import L from"node:path";import{existsSync as Ht,mkdirSync as Jt,readFileSync as kt,writeFileSync as At}from"node:fs";import{unlink as _,mkdir as It,readdir as jt,rm as Wt,writeFile as $t,stat as et,readFile as Gt}from"node:fs/promises";var b=()=>{},qt=64,Bt=2e3,zt=10080*60*1e3,Vt=1440*60*1e3,rt=".last-sweep",M=class{#e=new Map;#t=B;#h=z;#c=0;#r=new Map;#o=!1;#p=!1;#u;#n;#s;#d=!1;get(e){return this.#m(e)??this.#l(e,this.#E(e))}async getAsync(e){return this.#m(e)??this.#l(e,await this.#O(e))}set(e,r){return this.#a(e,r),r&&this.#c<Bt&&(this.#c+=1,this.#r.set(e,r),this.#x()),this}has(e){return this.#e.has(e)||this.#r.has(e)}clear(){this.#e.clear(),this.#r.clear()}async#y(){let e=L.join(this.#t,rt);try{let{mtimeMs:r}=await et(e);if(Date.now()-r<Vt)return!1}catch{}try{await this.#T(),await $t(e,"")}catch{return!1}return!0}#S(){this.#d||(this.#d=!0,setImmediate(async()=>{try{if(!await this.#y())return;await this.#w(),await this.#v()}catch{}}))}#i(e){return L.join(this.#t,e)}#T(){return this.#n!==this.#t&&(this.#n=this.#t,this.#s=void 0,this.#u=It(this.#t,{recursive:!0}).then(b)),this.#s=!0,this.#u}#R(){if(this.#n!==this.#t){Jt(this.#t,{recursive:!0}),this.#n=this.#t,this.#s=!0;return}this.#s=!0}#f(){return this.#s?!0:Ht(this.#t)?this.#s=!0:!1}#a(e,r){if(!this.#e.has(e)&&this.#e.size>=qt){let s=this.#e.keys().next().value;s!==void 0&&this.#e.delete(s)}this.#e.set(e,r)}#m(e){let r=this.#e.get(e);if(r)return r;let s=this.#r.get(e);if(s)return this.#a(e,s),s}#l(e,r){if(r)return this.#a(e,r),this.#S(),r}#E(e){if(!this.#f())return;let r=this.#i(e);try{return d.parse(kt(r,"utf8"))}catch(s){s.code!=="ENOENT"&&_(r).catch(b);return}}async#O(e){if(!this.#f())return;let r=this.#i(e);try{return d.parse(await Gt(r,"utf8"))}catch(s){s.code!=="ENOENT"&&_(r).catch(b);return}}#x(){this.#P(),!this.#o&&(this.#o=!0,setImmediate(()=>{this.#o=!1,this.#b()}))}#P(){this.#p||(this.#p=!0,process.once("exit",()=>this.#g()))}#b(){return this.#g(),Promise.resolve()}#g(){if(this.#r.size===0)return;let e=[...this.#r];this.#r.clear();try{this.#R()}catch{return}for(let[r,s]of e)try{At(this.#i(r),JSON.stringify(s))}catch{}}async#w(){let e;try{e=await jt(this.#t)}catch{return}let r=Date.now()-zt;await Promise.all(e.map(async s=>{if(s===rt)return;let n=L.join(this.#t,s);try{(await et(n)).mtimeMs<r&&await _(n)}catch{}}))}async#N(e){return Wt(e,{recursive:!0,force:!0}).catch(b)}async#v(){await Promise.all(this.#h.map(this.#N))}},E=process.env.TSNODE_DISABLE_CACHE?new Map:new M;import Qt from"node:path";var Xt=Object.freeze({target:`node${process.versions.node}`,loader:"default"}),Kt=/^--inspect(?:-brk|-port|-publish-uid|-wait)?(?:=|$)/,Yt=/^--enable-source-maps(?:=|$)/,st=process.execArgv.some(t=>Kt.test(t)),Zt=process.execArgv.some(t=>Yt.test(t)),nt=!!process.env.NODE_V8_COVERAGE,te=process.env.TSNODE_SOURCE_MAPS==="1",ee=st||Zt||nt||te,F={...Xt,sourcemap:ee,sourcesContent:nt||st,minifyWhitespace:!0,keepNames:!0},re=t=>{let e=t.indexOf("?");return e===-1?t:t.slice(0,e)},ot=t=>{let e=t.sourcefile;return e&&Qt.extname(re(e)).length===0&&(t.sourcefile+=".js"),e},it=(t,e,r)=>{let s;return t.map&&(e!==r&&(t.map=t.map.replace(d.serialize(e),d.serialize(r))),s=d.parse(t.map)),{code:t.code,map:s}};var pt=se(import.meta.url),ie=`-${pt("esbuild/package.json").version}`,at,ae=()=>at??(at=pt("esbuild")),ce=t=>{throw t.name="TransformError",delete t.errors,delete t.warnings,t},ct=new WeakMap,H=t=>{if(t&&typeof t=="object"){let e=ct.get(t);return e!==void 0||(e=JSON.stringify(t),ct.set(t,e)),e}return JSON.stringify(t)??""},u=(t,e)=>{let r=t;for(let s=0,n=e.length;s<n;s+=1)r=Math.imul(r^e.charCodeAt(s),16777619);return r},O="\0",pe=(t,e)=>{let r=2166136261;return r=u(r,t),r=u(r,O),r=u(r,e),(r>>>0).toString(16)},ue=(t,e,r,s,n)=>{let o=2166136261;return o=u(o,t),o=u(o,O),o=u(o,e),o=u(o,O),o=u(o,r),o=u(o,O),o=u(o,s),o=u(o,O),o=u(o,n),(o>>>0).toString(16)},de=H({...F,format:"esm"}),fe=`-strip-${process.versions.node}`,ut=t=>{let e=pe(t,fe),r=E.get(e);return r||(r={code:ne(t,{mode:"strip"})},E.set(e,r)),r},me=t=>{if(!t)return!1;for(let e in t)if(e!=="sourcefile"&&e!=="tsconfigRaw"&&e!=="tsconfigHash"&&e!=="getTsconfigRaw")return!0;return!1},le=(t,e,r,s,n,o)=>ue(t,e,n,o??H(r.tsconfigRaw),s),ge=t=>{let e=t.indexOf("?");return e===-1?t:t.slice(0,e)},he=t=>t?oe.extname(ge(t)).length===0:!1,dt=(t,e,r)=>{let{tsconfigHash:s,getTsconfigRaw:n,...o}=r??{},i={...F,format:"esm",sourcefile:e,...o},a=he(i.sourcefile)?ot(i):i.sourcefile;n&&i.tsconfigRaw===void 0&&!s&&(i.tsconfigRaw=n());let c=me(r)?H({...i,sourcefile:void 0,tsconfigRaw:void 0}):de,p=le(t,e,i,ie,c,s),f=E.get(p);if(!f){n&&i.tsconfigRaw===void 0&&(i.tsconfigRaw=n());let v;try{v=ae().transformSync(t,i)}catch(Ct){throw ce(Ct)}f=i.sourcemap||a!==i.sourcefile?it(v,i.sourcefile,a):{code:v.code},E.set(p,f)}return f};var ye=new Set(I),ft=t=>Te(t),Se=/\.ts($|\?)/,Te=t=>Se.test(t)&&!t.includes("/node_modules/"),mt=t=>{let e=t.indexOf("?"),r=t.indexOf("#");(e===-1||r!==-1&&r<e)&&(e=r),e===-1&&(e=t.length);let s=t.lastIndexOf(".",e-1);if(s>t.lastIndexOf("/",e-1)&&ye.has(t.slice(s,e)))return"module"},l="tsnode-namespace=",x=t=>{let e=t.indexOf(l);if(e===-1)return;let r=t[e-1];if(r!=="?"&&r!=="&")return;let s=e+l.length,n=t.indexOf("&",s);return n===-1?t.slice(s):t.slice(s,n)};var Ee=`
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,`,lt=({code:t,map:e})=>e?t+Ee+Buffer.from(JSON.stringify(e),"utf8").toString("base64"):t,Oe=t=>t==="module-typescript"||t==="typescript",xe=t=>R(t),Pe=t=>t.tsconfig===!1?void 0:K(t.tsconfig??process.env.TSNODE_TSCONFIG_PATH),be=t=>t.startsWith(m)?Re(t):t,we=t=>typeof t=="string"?t:new TextDecoder().decode(t),Ne=/^\s*@/m,ve=t=>t.includes("@")&&Ne.test(t),Ce=/(?:^|[^\w$])(?:enum|namespace)\s+[\w$]/m,Ue=t=>(t.includes("enum")||t.includes("namespace"))&&Ce.test(t),De=t=>{try{return ut(t)}catch(e){if(e.code==="ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX")return;throw e}},Le=(t,e)=>{let r=e;if(e.includes(l)){let s=new URL(e);s.searchParams.delete("tsnode-namespace"),r=s.toString()}return t.onImport?.(r),r},_e=(t,e)=>{if(!j.test(t))return e;let r=e.importAttributes;return r?.type?e:{...e,importAttributes:{...r,type:"json"}}},gt=t=>{let e=(r,s,n)=>{if(!t.active||t.namespace!==x(r))return n(r,s);let o=t.virtualSources?.get(r);if(o!==void 0)return{format:"module",source:o,shortCircuit:!0};(t.onImport||D.send)&&D.send?.({type:"dependency",path:Le(t,r)});let i=n(r,_e(r,s));if(y(3,"loaded by next loader",{url:r,loaded:i}),!i.source)return i;let a=Oe(i.format)||g.test(r),c=i.format==="json"&&s.conditions?.includes("import")===!0;if(!c&&!a)return i;let p=we(i.source);if(a&&ft(r)&&!ve(p)&&!Ue(p)){let f=De(p);if(f)return{format:"module",source:lt(f)}}return c||a?{format:"module",source:lt(dt(p,be(r),{tsconfigHash:Pe(t),getTsconfigRaw:()=>xe(t)}))}:i};return h?(r,s,n)=>{y(2,"loadSync",{url:r,context:s});let o=e(r,s,n);return y(1,"loadedSync",{url:r,result:o}),o}:e};import{pathToFileURL as Tt}from"node:url";import{extname as Me,isAbsolute as Fe,posix as He,sep as Je}from"node:path";var Rt=[".js",".json"],Et=[".ts",".tsx",".jsx"],ke=[...Et,...Rt],Ae=[...Rt,...Et],k=Object.create(null);k[".js"]=[".ts",".tsx",".js",".jsx"];k[".jsx"]=[".tsx",".ts",".jsx",".js"];var Ie=new Set([".ts",".tsx"]),je=t=>{let e=t.indexOf("?");return e===-1?[t,""]:[t.slice(0,e),t.slice(e)]},We=t=>{let[e,r]=je(t),s=Me(e);if(Ie.has(s))return;let n=[],o=p=>e.slice(0,-s.length)+p+r,i=k[s];if(i)return n.push(...i.map(o)),n;let a=p=>e+p+r,c=!(t.startsWith(m)||S(e))||e.includes(W)||e.includes("/node_modules/")?Ae:ke;return n.push(...c.map(a)),n},$e=/^(?:[a-z][\d+.a-z-]*:\/\/|data:|file:|node:)/i,Ge=t=>!S(t)&&!$e.test(t),Ot=t=>{if(t.url)return t.url;let e=t.message.match(/^Cannot find module '([^']+)'/);if(e){let[,s]=e;return s}let r=t.message.match(/^Cannot find package '([^']+)'/);if(r){let[,s]=r;if(!Fe(s))return;let n=Tt(s);if(n.pathname.endsWith("/")&&(n.pathname+="package.json"),n.pathname.endsWith("/package.json")){let o=P(n);if(o?.main)return new URL(o.main,n).toString()}else return n.toString()}},A=t=>t==="ERR_MODULE_NOT_FOUND"||t==="MODULE_NOT_FOUND",N=(t,e,r,s)=>{let n=We(t);if(!n)return;let o;for(let i of n)try{return r(i,e)}catch(a){let{code:c}=a;if(!A(c)&&c!=="ERR_PACKAGE_PATH_NOT_EXPORTED")throw a;o=a}if(s){if(o===void 0)return r(n[0],e);throw o}},qe=(t,e,r)=>g.test(t)?!1:(t.startsWith(m)||C(t))&&(g.test(e.parentURL)||(R(r)?.compilerOptions.allowJs??!1)),ht=(t,e,r,s)=>{if(qe(t,e,s)){let n=N(t,e,r);if(n)return n}try{return r(t,e)}catch(n){if(n instanceof Error){let o=n;if(A(o.code)){let i=Ot(o);if(i){let a=N(i,e,r);if(a)return a}}}throw n}},Be=t=>t==="."||t===".."||t.endsWith("/..")?`${t}/`:t,yt=(t,e,r,s)=>{if(t=Be(t),U.test(t)){if(!S(t)&&!t.startsWith(m))return ht(t,e,r,s);let n=new URL(t,e.parentURL);return n.pathname=He.join(n.pathname,"index"),N(n.toString(),e,r,!0)}try{return ht(t,e,r,s)}catch(n){if(n instanceof Error){let o=n;if(o.code==="ERR_UNSUPPORTED_DIR_IMPORT"){let i=Ot(o);if(i)try{return N(`${i}/index`,e,r,!0)}catch(a){let c=a,{message:p}=c;throw c.message=c.message.replace(`${"/index".replace("/",Je)}'`,"'"),c.stack=c.stack.replace(p,c.message),c}}}throw n}},xt=(t,e,r,s)=>{let n=R(s);if(Ge(t)&&n&&!e.parentURL?.includes("/node_modules/"))for(let o of X(n,t))try{return yt(Tt(o).toString(),e,r,s)}catch{}return yt(t,e,r,s)},J="tsnode://",ze=/\.(?:m?js|json)($|\?)/,St=(t,e)=>`${t}${t.includes("?")?"&":"?"}${e}`,Ve=(t,e,{namespace:r})=>{let s=x(t)??(e.parentURL&&x(e.parentURL)),n=e.parentURL;if(r){let o;if(t.startsWith(J)){try{o=JSON.parse(t.slice(J.length))}catch{}o?.namespace&&(s=o.namespace)}if(r!==s)return;o&&(t=o.specifier,n=o.parentURL)}return{specifier:t,requestNamespace:s,parentURL:n}},Qe=(t,e,r)=>(e&&(t.url=St(t.url,e)),r&&!t.url.includes(l)&&(t.url=St(t.url,`${l}${r}`)),t),w=t=>((!t.format||t.format==="module-typescript")&&t.url.startsWith(m)&&(t.format=mt(t.url)),t),Pt=(t,e)=>!e.namespace&&!t.startsWith(J)&&!t.includes(l)&&!t.includes("?")&&!U.test(t)&&(t.startsWith(m)||C(t)||S(t)),Xe=(t,e)=>Pt(t,e)&&g.test(t),Ke=(t,e,r)=>Pt(t,r)&&ze.test(t)&&!g.test(e.parentURL??""),Ye=t=>((e,r,s)=>{if(!t.active||e.startsWith("node:"))return s(e,r);if(Xe(e,t))return w(s(e,r));if(Ke(e,r,t))try{return w(s(e,r))}catch(o){if(!A(o.code))throw o}let n=xt(e,r,s,t);return n.format==="builtin"?n:w(n)}),Ze=t=>((e,r,s)=>{if(!t.active||e.startsWith("node:"))return s(e,r);let n=Ve(e,r,t);if(!n)return s(e,r);let o=n.parentURL&&n.parentURL!==r.parentURL?{...r,parentURL:n.parentURL}:r,[i,a]=n.specifier.split("?"),c=xt(i,o,s,t);return c.format==="builtin"?c:(w(c),Qe(c,a,n.requestNamespace))}),bt=t=>{let e=t.namespace?Ze(t):Ye(t);return h?(r,s,n)=>{y(2,"resolveSync",{specifier:r,context:s});let o=e(r,s,n);return y(1,"resolvedSync",{specifier:r,context:s,result:o}),o}:e};import{pathToFileURL as tr}from"node:url";var er=new Function("specifier","return import(specifier);"),wt=t=>(e,r)=>{if(!r)throw new Error("The current file path (import.meta.url) must be provided in the second argument of tsImport()");let s=r.startsWith(m)?r:tr(r).toString();return er(`tsnode://${JSON.stringify({specifier:e,parentURL:s,namespace:t})}`)};var sr=/^--enable-source-maps(?:=|$)/,nr=/^--inspect(?:-brk|-port|-publish-uid|-wait)?(?:=|$)/,or=t=>sr.test(t),ir=t=>nr.test(t),Nt=process.execArgv.some(or)||process.execArgv.some(ir)||!!process.env.NODE_V8_COVERAGE||process.env.TSNODE_SOURCE_MAPS==="1";function vt(t){Nt&&process.setSourceMapsEnabled(!0);let e=Z({namespace:t?.namespace,onImport:t?.onImport,tsconfig:t?.tsconfig}),r=rr.registerHooks({load:gt(e),resolve:bt(e)}),s=async()=>{e.active=!1,r.deregister(),Nt&&process.sourceMapsEnabled===!1&&process.setSourceMapsEnabled(!1)};return t?.namespace?{import:wt(t.namespace),unregister:s}:{unregister:s}}var us=(t,e)=>{if(!e||typeof e=="object"&&!e.parentURL)throw new Error("The current file path (import.meta.url) must be provided in the second argument of tsImport()");return typeof e=="string"&&(e={parentURL:e}),vt({...e,namespace:Date.now().toString()}).import(t,e.parentURL)};export{vt as register,us as tsImport};
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{d as v,e as S}from"./chunk-CWI5WFAA.js";import{constants as g}from"node:os";import{enableCompileCache as h}from"node:module";if(typeof h=="function"&&process.env.NODE_DISABLE_COMPILE_CACHE!=="1")try{h()}catch{}var
|
|
1
|
+
import{d as v,e as S}from"./chunk-CWI5WFAA.js";import{constants as g}from"node:os";import{enableCompileCache as h}from"node:module";if(typeof h=="function"&&process.env.NODE_DISABLE_COMPILE_CACHE!=="1")try{h()}catch{}var I=(o,i)=>{let t;i.on("data",e=>{e?.type==="signal"&&t&&t(e.signal)});let c=()=>{let e=new Promise(n=>{setTimeout(()=>n(void 0),30),t=n});return e.then(()=>t=void 0,()=>{}),e},s=async e=>{await c()!==e&&(o.kill(e),await c()!==e&&(o.on("exit",()=>{process.exit(128+g.signals[e])}),o.kill(g.signals.SIGKILL)))};process.on("SIGINT",s),process.on("SIGTERM",s)},C={noCache:{type:Boolean},tsconfig:{type:String}},T={...C,version:{type:Boolean,alias:"v"},help:{type:Boolean,alias:"h"}},A={...T,inputType:{type:String},test:{type:Boolean},eval:{type:String,alias:"e"},print:{type:String,alias:"p"}},O={"no-cache":{type:"boolean"},tsconfig:{type:"string"},version:{type:"boolean",short:"v"},help:{type:"boolean",short:"h"},"input-type":{type:"string"},test:{type:"boolean"},eval:{type:"string",short:"e"},print:{type:"string",short:"p"}},F=async o=>{let{parseArgs:i}=await import("node:util");return i({args:o,allowPositionals:!0,strict:!1,options:O}).values},N=o=>{for(let i of["print","eval"]){let t=o[i];if(t!==void 0)return{type:i,code:t}}},_=()=>{process.stdout.write(`Node.js runtime enhanced with esbuild for loading TypeScript & ESM
|
|
2
2
|
`),process.stdout.write(`Usage: tsnode [script path] [arguments]
|
|
3
|
-
`)},f=process.argv.slice(2);if(f[0]==="watch")
|
|
4
|
-
node `)}else
|
|
5
|
-
`));let
|
|
3
|
+
`)},f=process.argv.slice(2);if(f[0]==="watch")await(await import("./watch-KRAOMOO6.js")).runWatchCommand(f.slice(1)),process.exitCode??=0;else{let{findFirstPositionalIndex:o,removeArgvFlags:i}=await import("./remove-argv-flags-YKV2LNF2.js"),t=o(A,f),c=t===-1?f:f.slice(0,t),s=c.length===0?{}:await F(c);if(s.version){let{default:{version:r}}=await import("./package-75ORL5F6.js");process.stdout.write(`tsnode v${r}
|
|
4
|
+
node `)}else s.help&&(_(),console.log(`${"-".repeat(45)}
|
|
5
|
+
`));let e=i({...C,eval:{type:String,alias:"e"},print:{type:String,alias:"p"}}),n=N(s);if(n){let r=(await import("esbuild")).transformSync(n.code,{loader:"ts",sourcefile:"/eval.ts",...n.type==="eval"?{format:"esm"}:{}});e.unshift(`--${n.type}`,r.code),n.type==="eval"&&s["input-type"]!=="module"&&e.unshift("--input-type=module")}s.test&&t===-1&&e.push("**/{test,test/**/*,test-*,*[.-_]test}.?(c|m)@(t|j)s");let{run:E}=await import("./run-J7WDXCNP.js"),[d]=e,a=d&&!d.startsWith("-")?v(d):d,u=a&&!a.startsWith("-")?S(a):void 0;a!==d&&a!==void 0&&(e[0]=a);let P=process.env.TSNODE_DISABLE_IN_PROCESS!=="1"&&!s.version&&!s.help&&!n&&!s.test&&t!==-1&&a!==void 0&&!a.startsWith("-")&&!process.send&&u!==void 0,w=process.env.TSNODE_DISABLE_IN_PROCESS!=="1"&&!s.version&&!s.help&&n?.type==="eval"&&!s.test&&!process.send&&!e.some(r=>r.startsWith("-"));if(P)s["no-cache"]&&(process.env.TSNODE_DISABLE_CACHE="1"),typeof s.tsconfig=="string"&&(process.env.TSNODE_TSCONFIG_PATH=s.tsconfig),await(await import("./run-in-process-G4BTEPTH.js")).runInProcess(e,u);else if(w)await(await import("./run-eval-in-process-FSY2ACC3.js")).runEvalInProcess(e.shift(),e);else{let r=process.env.TSNODE_DISABLE_SIGNAL_RELAY!=="1"&&(process.env.TSNODE_FORCE_SIGNAL_RELAY==="1"||process.stdin.isTTY||process.stdout.isTTY||process.stderr.isTTY),y=r?await import("./server-TWLLBPU7.js").then(({createIpcServer:l})=>l()):void 0,p=E(e,{noCache:!!s["no-cache"],signalRelay:r,tsconfigPath:s.tsconfig});y&&I(p,y);let m=process.send;m!==void 0&&p.on("message",l=>m(l)),p.send&&process.on("message",l=>p.send(l)),p.on("close",l=>process.exit(l??g.signals[p.signalCode]+128))}}
|
package/dist/loader.d.ts
CHANGED
|
@@ -1 +1,41 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type ScopedImport = (specifier: string, parent: string) => Promise<any>;
|
|
2
|
+
|
|
3
|
+
export type Unregister = () => Promise<void>;
|
|
4
|
+
|
|
5
|
+
export type RegisterHandle = {
|
|
6
|
+
unregister: Unregister;
|
|
7
|
+
import?: ScopedImport;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type NamespacedUnregister = RegisterHandle & {
|
|
11
|
+
import: ScopedImport;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type NodeError = Error & {
|
|
15
|
+
code: string;
|
|
16
|
+
url?: string;
|
|
17
|
+
path?: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type TsconfigOptions = false | string;
|
|
21
|
+
|
|
22
|
+
export type RegisterOptions = {
|
|
23
|
+
namespace?: string;
|
|
24
|
+
onImport?: (url: string) => void;
|
|
25
|
+
tsconfig?: TsconfigOptions;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
type RequiredProperty<Type, Keys extends keyof Type> = Type & {
|
|
29
|
+
[P in Keys]-?: Type[P];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type Register = {
|
|
33
|
+
(options: RequiredProperty<RegisterOptions, 'namespace'>): NamespacedUnregister;
|
|
34
|
+
(options?: RegisterOptions): RegisterHandle;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type TsnodeRequest = {
|
|
38
|
+
namespace: string;
|
|
39
|
+
parentURL: string;
|
|
40
|
+
specifier: string;
|
|
41
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var s={name:"@d1g1tal/tsnode",version:"1.
|
|
1
|
+
var s={name:"@d1g1tal/tsnode",version:"1.1.0",description:"ESM-only Node.js TypeScript runner \u2014 run .ts files directly with `tsnode foo.ts`. CommonJS support removed.",keywords:["cli","runtime","node","esm","typescript","typescript runner"],license:"MIT",repository:"D1g1talEntr0py/tsnode",author:"D1g1talEntr0py",contributors:[{name:"Hiroki Osame",email:"hiroki.osame@gmail.com",url:"https://github.com/privatenumber/tsx"}],files:["dist"],types:"./dist/loader.d.ts",type:"module",bin:{tsnode:"./dist/cli.js"},exports:{"./package.json":"./package.json",".":{types:"./dist/loader.d.ts",default:"./dist/loader.js"},"./api":{types:"./dist/api/index.d.ts",default:"./dist/api/index.js"},"./cli":"./dist/cli.js","./suppress-warnings":"./dist/suppress-warnings.js","./preflight":"./dist/preflight.js","./repl":"./dist/repl.js"},packageManager:"pnpm@11.19.0",scripts:{build:"pnpm type-check && node ./scripts/build/build-js.ts && node ./scripts/build/build-types.ts","run:import":"node --import ./dist/loader.js","run:import:build":"pnpm build && node --import ./dist/loader.js","run:import:no-relay":"TSNODE_DISABLE_SIGNAL_RELAY=1 node --import ./dist/loader.js",benchmark:"pnpm build && node ./dist/cli.js tests/benchmarks/index.ts","benchmark:hooks":"pnpm build && node ./dist/cli.js tests/benchmarks/hooks.ts","benchmark:compare":"pnpm build && node ./dist/cli.js tests/benchmarks/compare.ts","benchmark:memory":"pnpm build && node ./dist/cli.js tests/benchmarks/memory-profile.ts",lint:"eslint --flag unstable_native_nodejs_ts_config ./src","type-check":"tsc",test:"vitest run","test:coverage":"vitest run --coverage","test:watch":"vitest"},engines:{node:">=24.11.1"},dependencies:{"@d1g1tal/watchr":"^1.1.1",esbuild:"^0.28.1"},devDependencies:{"@eslint/js":"^10.0.1","@types/node":"^26.1.2","@typescript-eslint/eslint-plugin":"^8.65.0","@typescript-eslint/parser":"^8.65.0","@typescript/native":"npm:typescript@^7.0.2","@vitest/coverage-v8":"^4.1.10",eslint:"^10.8.0","eslint-plugin-jsdoc":"^63.3.2",execa:"^10.0.1","fs-fixture":"^2.14.0","get-node":"^15.0.4",mitata:"^1.0.34",typescript:"npm:@typescript/typescript6@^6.0.2","typescript-eslint":"^8.65.0",vitest:"^4.1.10"}};export{s as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d1g1tal/tsnode",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "ESM-only Node.js TypeScript runner — run .ts files directly with `tsnode foo.ts`. CommonJS support removed.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -55,14 +55,14 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@eslint/js": "^10.0.1",
|
|
58
|
-
"@types/node": "^26.1.
|
|
58
|
+
"@types/node": "^26.1.2",
|
|
59
59
|
"@typescript-eslint/eslint-plugin": "^8.65.0",
|
|
60
60
|
"@typescript-eslint/parser": "^8.65.0",
|
|
61
61
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
62
62
|
"@vitest/coverage-v8": "^4.1.10",
|
|
63
63
|
"eslint": "^10.8.0",
|
|
64
|
-
"eslint-plugin-jsdoc": "^63.3.
|
|
65
|
-
"execa": "^10.0.
|
|
64
|
+
"eslint-plugin-jsdoc": "^63.3.2",
|
|
65
|
+
"execa": "^10.0.1",
|
|
66
66
|
"fs-fixture": "^2.14.0",
|
|
67
67
|
"get-node": "^15.0.4",
|
|
68
68
|
"mitata": "^1.0.34",
|
|
File without changes
|
|
File without changes
|