Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: redirect subsequent imports of "source-map-support" to this… #23

Merged
merged 12 commits into from Oct 6, 2021
Merged
15 changes: 13 additions & 2 deletions source-map-support.js
Expand Up @@ -555,6 +555,19 @@ exports.install = function(options) {
}
}

// Use dynamicRequire to avoid including in browser bundles
var Module = dynamicRequire(module, 'module');

// Redirect subsequent imports of "source-map-support"
// to this package
const originalResolveFilename = Module._resolveFilename;
Module._resolveFilename = function resolveFilenameProxy(request, parent, isMain, options) {
if (request === 'source-map-support') {
request = '@cspotcode/source-map-support';
ejose19 marked this conversation as resolved.
Show resolved Hide resolved
}
return originalResolveFilename.call(this, request, parent, isMain, options);
}

// Allow sources to be found by methods other than reading the files
// directly from disk.
if (options.retrieveFile) {
Expand All @@ -577,8 +590,6 @@ exports.install = function(options) {

// Support runtime transpilers that include inline source maps
if (options.hookRequire && !isInBrowser()) {
// Use dynamicRequire to avoid including in browser bundles
var Module = dynamicRequire(module, 'module');
var $compile = Module.prototype._compile;

if (!$compile.__sourceMapSupport) {
Expand Down