Open adamsmasher opened 1 year ago
Makes sense; it is compiling the JS and generating a new sourcemap. Possible workarounds:
dist
directories from compilation by configuring ignore
allowJs
, perhaps via a ts-node-specific override that does not affect tsc
nor other toolssrc
files, not the dist
files
Search Terms
I searched for
allowJs
and didn't see anything clearly related in either open or closed issues.Expected Behavior
When executing transpiled
.js
files with a source map usingallowJs
,ts-node
should work likenode --enable-source-maps
: stack traces should show the original source file/line number, not the transpiled file/line number.Actual Behavior
The opposite:
ts-node
shows the transpiled file/line number. This only happens whenallowJs
is on - turning it off causests-node
to work correctly.Steps to reproduce the problem
Enable
allowJs
andsourceMaps
intsconfig.json
. Transpile files usingtsc
. Run the transpiled files usingts-node
. When an exception is thrown, note that the stack trace refers to the transpiled files and not the original.ts
files. Compare to running withnode --enable-source-maps
, which does the right thing.Minimal reproduction
I've put up a yarn 1 repo here showing this in action. After running
yarn tsc
,yarn ts-node dist/index.js
produces:where as
yarn node --enable-stack-traces dist/index.js
produces:Specifications
ts-node v10.9.1 node v16.13.0 compiler v4.8.4
tsconfig.json, if you're using one: