Closed ceremcem closed 5 years ago
You can add a key called map
to the options object passed to compile
. The valid values are the same as for the --map
option on the command line. compile
will return an object instead of a string, with code
and map
fields. If you're passing the code
on to something that understands //# sourceMappingURL
directives, then using the 'embedded'
option will stuff the source map into code
, so at that point you're done. If not, you'll want to use 'linked-src'
, and process the map
yourself; I think it's an instance of SourceMapGenerator.
You may also want to add a filename
key to your compile options, since otherwise your source map will reference unnamed-xxxxxxxx.js
.
Thanks for your help. It turns out that this (my) problem was containing multiple issues: Explanation
TL;DR;
Executing a dynamically created code while keeping your current app working involves using try/catch
block, which prevents debugger (Chromium's at least) from hit to the correct exception point.
Both including the sourcemaps (embedded
option worked for me) and enabling Pause on exceptions in debugger window (see this) makes the debugger hit the exact exception line.
In my app, dynamically generated code is run (just like in livescript.net) in browser. How can we add sourcemaps for those dynamically generated scripts?