tsx 4.2.0 → 4.3.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/README.md CHANGED
@@ -224,6 +224,96 @@ $ ./file.ts hello
224
224
  argv: [ 'hello' ]
225
225
  ```
226
226
 
227
+ ### VS Code debugging
228
+
229
+ #### Setup
230
+
231
+ Create the following configuration file in your project to setup debugging in VS Code:
232
+
233
+ `.vscode/launch.json`
234
+ ```json5
235
+ {
236
+ "version": "0.2.0",
237
+
238
+ "configurations": [
239
+ /*
240
+ Each config in this array is an option in the debug drop-down
241
+ See below for configurations to add...
242
+ */
243
+ ],
244
+ }
245
+ ```
246
+
247
+ #### Debugging method 1: Run tsx directly from VSCode
248
+
249
+ 1. Add the following configuration to the `configurations` array in `.vscode/launch.json`:
250
+ ```json5
251
+ {
252
+ "name": "tsx",
253
+ "type": "node",
254
+ "request": "launch",
255
+
256
+ // Debug current file in VSCode
257
+ "program": "${file}",
258
+
259
+ /*
260
+ Path to tsx binary
261
+ Assuming locally installed
262
+ */
263
+ "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/tsx",
264
+
265
+ /*
266
+ Open terminal when debugging starts (Optional)
267
+ Useful to see console.logs
268
+ */
269
+ "console": "integratedTerminal",
270
+ "internalConsoleOptions": "neverOpen",
271
+
272
+ // Files to exclude from debugger (e.g. call stack)
273
+ "skipFiles": [
274
+ // Node.js internal core modules
275
+ "<node_internals>/**",
276
+
277
+ // Ignore all dependencies (optional)
278
+ "${workspaceFolder}/node_modules/**",
279
+ ],
280
+ }
281
+ ```
282
+
283
+ 2. In VSCode, open the file you want to run
284
+
285
+ 3. Go to VSCode's debug panel, select "tsx" in the drop down, and hit the play button (<kbd>F5</kbd>).
286
+
287
+ #### Debugging method 2: Attach to a running Node.js process
288
+
289
+ > This method works for any Node.js process and it's not specific to tsx
290
+
291
+ 1. Add the following configuration to the `configurations` array in `.vscode/launch.json`:
292
+ ```json
293
+ {
294
+ "name": "Attach to process",
295
+ "type": "node",
296
+ "request": "attach",
297
+ "port": 9229,
298
+ "skipFiles": [
299
+ // Node.js internal core modules
300
+ "<node_internals>/**",
301
+
302
+ // Ignore all dependencies (optional)
303
+ "${workspaceFolder}/node_modules/**",
304
+ ],
305
+ }
306
+ ```
307
+ 2. Run tsx with `--inspect-brk` in a terminal window:
308
+
309
+ ```sh
310
+ tsx --inspect-brk ./your-file.ts
311
+ ```
312
+
313
+ 3. Go to VSCode's debug panel, select "Attach to process" in the drop down, and hit the play button (<kbd>F5</kbd>).
314
+
315
+ See the [VSCode documentation on _Launch Configuration_](https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_launch-configuration) for more information.
316
+
227
317
  <br>
228
318
 
229
319
  <p align="center">
@@ -1 +1 @@
1
- "use strict";var S=require("path"),j=require("fs"),E=require("module"),i=require("get-tsconfig"),O=require("../source-map.cjs"),f=require("../index-798b46f9.cjs"),M=require("../resolve-ts-path-43f50656.cjs");require("source-map-support"),require("../node-features-84a305a1.cjs"),require("url"),require("esbuild"),require("crypto"),require("os");function d(s){return s&&typeof s=="object"&&"default"in s?s:{default:s}}var m=d(S),q=d(j),l=d(E);const P=s=>{if(s.includes("import")||s.includes("export")){const[e,n]=f.parseEsm(s);return e.length>0||n.length>0}return!1},b=/^\.{1,2}\//,A=/\.[cm]?tsx?$/,N=`${m.default.sep}node_modules${m.default.sep}`,u=process.env.TSX_TSCONFIG_PATH?{path:m.default.resolve(process.env.TSX_TSCONFIG_PATH),config:i.parseTsconfig(process.env.TSX_TSCONFIG_PATH)}:i.getTsconfig(),h=u&&i.createFilesMatcher(u),x=u&&i.createPathsMatcher(u),y=O.installSourceMapSupport(),v=l.default._extensions,R=v[".js"],D=[".cts",".mts",".ts",".tsx",".jsx"],I=[".js",".cjs",".mjs"],F=(s,e)=>{process.send&&process.send({type:"dependency",path:e});const n=D.some(t=>e.endsWith(t)),o=I.some(t=>e.endsWith(t));if(!n&&!o)return R(s,e);let r=q.default.readFileSync(e,"utf8");if(e.endsWith(".cjs")){const t=f.transformDynamicImport(e,r);t&&(r=y(t,e))}else if(n||P(r)){const t=f.transformSync(r,e,{tsconfigRaw:h==null?void 0:h(e)});r=y(t,e)}s._compile(r,e)};[".js",".ts",".tsx",".jsx"].forEach(s=>{v[s]=F}),Object.defineProperty(v,".mjs",{value:F,enumerable:!1});const _=l.default._resolveFilename.bind(l.default);l.default._resolveFilename=(s,e,n,o)=>{var r;const t=s.indexOf("?");if(t!==-1&&(s=s.slice(0,t)),x&&!b.test(s)&&!((r=e==null?void 0:e.filename)!=null&&r.includes(N))){const a=x(s);for(const p of a){const T=g(p,e,n,o);if(T)return T;try{return _(p,e,n,o)}catch{}}}const c=g(s,e,n,o);return c||_(s,e,n,o)};const g=(s,e,n,o)=>{const r=M.resolveTsPath(s);if(e!=null&&e.filename&&A.test(e.filename)&&r)for(const t of r)try{return _(t,e,n,o)}catch(c){const{code:a}=c;if(a!=="MODULE_NOT_FOUND"&&a!=="ERR_PACKAGE_PATH_NOT_EXPORTED")throw c}};
1
+ "use strict";var u=require("path"),S=require("fs"),a=require("module"),l=require("get-tsconfig"),g=require("../source-map.cjs"),m=require("../index-bb73d2cd.cjs"),j=require("../resolve-ts-path-3fca13b7.cjs");require("url"),require("esbuild"),require("crypto"),require("os");const E=s=>{if(s.includes("import")||s.includes("export"))try{const[e,n]=m.parseEsm(s);return e.length>0||n.length>0}catch{return!0}return!1},O=/^\.{1,2}\//,P=/\.[cm]?tsx?$/,M=`${u.sep}node_modules${u.sep}`,f=process.env.TSX_TSCONFIG_PATH?{path:u.resolve(process.env.TSX_TSCONFIG_PATH),config:l.parseTsconfig(process.env.TSX_TSCONFIG_PATH)}:l.getTsconfig(),h=f&&l.createFilesMatcher(f),_=f&&l.createPathsMatcher(f),x=g.installSourceMapSupport(),d=a._extensions,q=d[".js"],A=[".cts",".mts",".ts",".tsx",".jsx"],N=[".js",".cjs",".mjs"],y=(s,e)=>{process.send&&process.send({type:"dependency",path:e});const n=A.some(r=>e.endsWith(r)),o=N.some(r=>e.endsWith(r));if(!n&&!o)return q(s,e);let t=S.readFileSync(e,"utf8");if(e.endsWith(".cjs")){const r=m.transformDynamicImport(e,t);r&&(t=x(r))}else if(n||E(t)){const r=m.transformSync(t,e,{tsconfigRaw:h==null?void 0:h(e)});t=x(r)}s._compile(t,e)};[".js",".ts",".tsx",".jsx"].forEach(s=>{d[s]=y}),Object.defineProperty(d,".mjs",{value:y,enumerable:!1});const v=a._resolveFilename.bind(a);a._resolveFilename=(s,e,n,o)=>{var t;const r=s.indexOf("?");if(r!==-1&&(s=s.slice(0,r)),_&&!O.test(s)&&!((t=e==null?void 0:e.filename)!=null&&t.includes(M))){const i=_(s);for(const T of i){const p=F(T,e,n,o);if(p)return p;try{return v(T,e,n,o)}catch{}}}const c=F(s,e,n,o);return c||v(s,e,n,o)};const F=(s,e,n,o)=>{const t=j.resolveTsPath(s);if(e!=null&&e.filename&&P.test(e.filename)&&t)for(const r of t)try{return v(r,e,n,o)}catch(c){const{code:i}=c;if(i!=="MODULE_NOT_FOUND"&&i!=="ERR_PACKAGE_PATH_NOT_EXPORTED")throw c}};
@@ -1 +1 @@
1
- import f from"path";import F from"fs";import m from"module";import{parseTsconfig as y,getTsconfig as S,createFilesMatcher as j,createPathsMatcher as E}from"get-tsconfig";import{installSourceMapSupport as O}from"../source-map.mjs";import{p as g,a as M,b as P}from"../index-a948fc61.mjs";import{r as b}from"../resolve-ts-path-a8cb04a4.mjs";import"source-map-support";import"../node-features-a792cc3d.mjs";import"url";import"esbuild";import"crypto";import"os";const A=o=>{if(o.includes("import")||o.includes("export")){const[s,n]=g(o);return s.length>0||n.length>0}return!1},N=/^\.{1,2}\//,R=/\.[cm]?tsx?$/,I=`${f.sep}node_modules${f.sep}`,a=process.env.TSX_TSCONFIG_PATH?{path:f.resolve(process.env.TSX_TSCONFIG_PATH),config:y(process.env.TSX_TSCONFIG_PATH)}:S(),T=a&&j(a),_=a&&E(a),v=O(),l=m._extensions,C=l[".js"],D=[".cts",".mts",".ts",".tsx",".jsx"],G=[".js",".cjs",".mjs"],h=(o,s)=>{process.send&&process.send({type:"dependency",path:s});const n=D.some(t=>s.endsWith(t)),r=G.some(t=>s.endsWith(t));if(!n&&!r)return C(o,s);let e=F.readFileSync(s,"utf8");if(s.endsWith(".cjs")){const t=M(s,e);t&&(e=v(t,s))}else if(n||A(e)){const t=P(e,s,{tsconfigRaw:T==null?void 0:T(s)});e=v(t,s)}o._compile(e,s)};[".js",".ts",".tsx",".jsx"].forEach(o=>{l[o]=h}),Object.defineProperty(l,".mjs",{value:h,enumerable:!1});const p=m._resolveFilename.bind(m);m._resolveFilename=(o,s,n,r)=>{var e;const t=o.indexOf("?");if(t!==-1&&(o=o.slice(0,t)),_&&!N.test(o)&&!((e=s==null?void 0:s.filename)!=null&&e.includes(I))){const i=_(o);for(const d of i){const u=x(d,s,n,r);if(u)return u;try{return p(d,s,n,r)}catch{}}}const c=x(o,s,n,r);return c||p(o,s,n,r)};const x=(o,s,n,r)=>{const e=b(o);if(s!=null&&s.filename&&R.test(s.filename)&&e)for(const t of e)try{return p(t,s,n,r)}catch(c){const{code:i}=c;if(i!=="MODULE_NOT_FOUND"&&i!=="ERR_PACKAGE_PATH_NOT_EXPORTED")throw c}};
1
+ import f from"path";import y from"fs";import m from"module";import{parseTsconfig as F,getTsconfig as S,createFilesMatcher as j,createPathsMatcher as E}from"get-tsconfig";import{installSourceMapSupport as O}from"../source-map.mjs";import{p as g,t as P,a as M}from"../index-a0bec4d2.mjs";import{r as A}from"../resolve-ts-path-eb3847f5.mjs";import"url";import"esbuild";import"crypto";import"os";const N=t=>{if(t.includes("import")||t.includes("export"))try{const[s,r]=g(t);return s.length>0||r.length>0}catch{return!0}return!1},R=/^\.{1,2}\//,b=/\.[cm]?tsx?$/,I=`${f.sep}node_modules${f.sep}`,a=process.env.TSX_TSCONFIG_PATH?{path:f.resolve(process.env.TSX_TSCONFIG_PATH),config:F(process.env.TSX_TSCONFIG_PATH)}:S(),T=a&&j(a),_=a&&E(a),h=O(),l=m._extensions,C=l[".js"],D=[".cts",".mts",".ts",".tsx",".jsx"],G=[".js",".cjs",".mjs"],v=(t,s)=>{process.send&&process.send({type:"dependency",path:s});const r=D.some(e=>s.endsWith(e)),n=G.some(e=>s.endsWith(e));if(!r&&!n)return C(t,s);let o=y.readFileSync(s,"utf8");if(s.endsWith(".cjs")){const e=P(s,o);e&&(o=h(e))}else if(r||N(o)){const e=M(o,s,{tsconfigRaw:T==null?void 0:T(s)});o=h(e)}t._compile(o,s)};[".js",".ts",".tsx",".jsx"].forEach(t=>{l[t]=v}),Object.defineProperty(l,".mjs",{value:v,enumerable:!1});const p=m._resolveFilename.bind(m);m._resolveFilename=(t,s,r,n)=>{var o;const e=t.indexOf("?");if(e!==-1&&(t=t.slice(0,e)),_&&!R.test(t)&&!((o=s==null?void 0:s.filename)!=null&&o.includes(I))){const i=_(t);for(const d of i){const u=x(d,s,r,n);if(u)return u;try{return p(d,s,r,n)}catch{}}}const c=x(t,s,r,n);return c||p(t,s,r,n)};const x=(t,s,r,n)=>{const o=A(t);if(s!=null&&s.filename&&b.test(s.filename)&&o)for(const e of o)try{return p(e,s,r,n)}catch(c){const{code:i}=c;if(i!=="MODULE_NOT_FOUND"&&i!=="ERR_PACKAGE_PATH_NOT_EXPORTED")throw c}};