Adds the hookRequire option which monkey patches _compile to support require extension hooks that use inline source maps. This is necessary because the default retrieveFile implementations point to the original source file when doing runtime transpilation and thus don’t have the source map attached.
This allows for multiple libraries to utilize this without stepping on each other’s toes.
This makes the retrieve helpers additive, giving priority to the last retrieve method registered. In the event of a miss, the next method is called up to and including the default behavior. The `overrideRetriveFile` and `overrideRetrieveSourceMap` flags are added if this behavior is not desired but this is something that most libraries should avoid to be good citizens.
Flagged behaviors will now be on if any of the install calls dictate that they would be.
Fix for #91
Without this check, missing sourcemaps cause the package to continue as
if the 404 message is the sourcemap, leading to crashes when responses
like "Not Found" cannot be parsed as source maps.
mapSourcePosition() will try to load the compiled script’s text and
extract its source map. When the source map is found, the module will
cache it, but when the script just doesn’t have any source map at all,
the module doesn’t remember that, and will load the script text again at
every subsequent call.
NodeJS outputs errors to stderr. Making use of console.error(...) instead of console.log(...) makes node-source-map-support compatible with IDEs like Webstorm to get stack traces.
If you have your own uncaughtException handler, you might still like the
pretty source display from handleUncaughtExceptions: true; therefore
expose it as exports.getErrorSource(err)
I have a problem using this module in my unit tests, because I don't
have a central place to put the
require('source-map-support').install();
statement. So I end up having to put it in every unit test, and once
I've written enough tests, I start getting an annoying error about using
up too much memory.
This change makes is so if you call install() multiple times in the same
vm, it only actually installs once.