Closed jwalton closed 4 days ago
This also impacts debugging through VSCode's built in debugger, which relies on sourcemaps.
This finally bothered me enough so I took a look.
Finding:
Unlike https://github.com/swc-project/swc-node/blob/e34f006484d89c53dd4cac7cface3c4d70841e34/packages/register/register.ts#L115, esm.mts does not call the installSourceMapSupport
to enable source map support.
I then tried adding the following in esm.mts
, as documented at https://nodejs.org/docs/latest-v20.x/api/module.html#initialize. Sadly, it does not work.
export async function initialize() {
console.log("This function is indeed called without error, but source map does not apply");
installSourceMapSupport();
}
Solution: I finally found this to be working (tested on Node 20). https://nodejs.org/docs/latest-v20.x/api/module.html#source-map-v3-support.
$ node --enable-source-maps --loader @swc-node/register/esm index.ts
Yep, stumbled upon this too.
@Xinkai thank you for a great workaround.
Happy new year :)
index.ts:
@swc-node/register gives us sourcemap support:
But @swc-node/register/esm does not: