Source map support for rewriting error
In Den the user have an option to include a Typescript transpiler (https://github.com/swc-project/swc) and the file will get transpiled to Javascript and also have an option to include the source map as a comment so that stack traces can be correctly remapped, however currently QuickJS does not take account into this and will the location of the error is often shifted away due to transpilation. Would be nice to include a basic support for source map so we can correctly print the right stack trace location.
Maybe related to https://github.com/bellard/quickjs/issues/235
In order to get that you need a couple of things in place. We have them over at the friendly fork:
- Support for column numbers: https://github.com/quickjs-ng/quickjs/commit/bace4f635e668917712a53c80286c8d2b566a4dc
- Support for Error.prepareStackTrace: https://github.com/quickjs-ng/quickjs/commit/555d8373342b03eca9a45b01b56a86da734a495b
With those 2 thins in place you can use your own Error.prepareStackTrace hook and read the source map and replace the current trace.
@saghul cool thanks! did not know about that one...