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

Use node's shorter filenames in REPL, eval, and stdin stack traces

Open cspotcode opened this issue 4 years ago • 0 comments

Related to #1282 Tracking as a separate issue because I don't think this is worth fixing, but I want to document my research.

In node's <repl>, [eval], and [stdin] there are 2x filenames used depending on the situation: the short [eval] and a longer absolute path /this/is/the/cwd/[eval] (ts-node also adds the .ts extension to the absolute path)

In vanilla node, stack traces use the shorter name. In ts-node they use the absolute path.

This is controlled by the filename option to new Script(). However, I think changing the filename will break stack traces. To preserve stack trace functionality, we must add a mapping from the short names to the full, absolute path. When source-map-support tries to look up the sourcemap for [eval] it should get the sourcemap for /this/is/the/cwd/[eval].ts

The short names in vanilla node appear to be [eval], [stdin], and REPL1

cspotcode avatar Jun 03 '21 05:06 cspotcode