Skip to content

Commit 48d7b0a

Browse files
committed
refactor: change implementation to hook on Module._resolveFilename
1 parent ce6eafe commit 48d7b0a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

source-map-support.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -560,12 +560,12 @@ exports.install = function(options) {
560560

561561
// Redirect subsequent imports of "source-map-support"
562562
// to this package
563-
const originalRequire = Module.prototype.require;
564-
Module.prototype.require = function requireProxy(id) {
565-
if (id === 'source-map-support') {
566-
id = '@cspotcode/source-map-support';
563+
const originalResolveFilename = Module._resolveFilename;
564+
Module._resolveFilename = function resolveFilenameProxy(...args) {
565+
if (args[0] === 'source-map-support') {
566+
args[0] = '@cspotcode/source-map-support';
567567
}
568-
return originalRequire.call(this, id);
568+
return originalResolveFilename.call(this, ...args);
569569
}
570570

571571
// Allow sources to be found by methods other than reading the files

0 commit comments

Comments
 (0)