ts-node icon indicating copy to clipboard operation
ts-node copied to clipboard

Add flag to skip source-map-support `install()`

Open cspotcode opened this issue 3 years ago • 2 comments

Related: https://github.com/TypeStrong/ts-node/issues/796 https://github.com/TypeStrong/ts-node/issues/1473 https://github.com/cspotcode/node-source-map-support/pull/23

Add a configuration option, perhaps named installSourceMapSupport or sourceMapHooks, which can be used to disable require('@cspotcode/source-map-support').install()

Important things to consider:

  • Do we continue to generate sourcemaps when compiling? Probably the best answer is "yes" to be compatible with node's built-in --enable-source-maps
    • Maybe we should obey the user's tsconfig? If they have sourcemaps turned on/off in tsconfig, then we do/don't generate sourcemaps?
  • Clearly document default behavior:
    • with --enable-source-maps enabled, default is "off"
    • without --enable-source-maps, default is "on"
    • When set to true or false via config, overrides the default

cspotcode avatar Oct 27 '21 18:10 cspotcode

~~Just confirming my understanding: This new option will be configurable within a tsconfig.json as well? I ask because in some scenarios we have no control over how a library invokes ts-node. As an example, Karma automatically invokes ts-node when a Karma config is written in TypeScript. Since I can't control how it invokes ts-node, it would be nice if I could throw this new flag into my tsconfig.json and have Karma pick up the flag automatically.~~

It's in the README.

pe8ter avatar Oct 28 '21 21:10 pe8ter

@cspotcode is this https://github.com/TypeStrong/ts-node/pull/2004 a good entry point for this, disregarding docs and the node's own --enable-source-maps? If so, what would be a good place to document the full behavior?

krigga avatar May 01 '23 17:05 krigga