@@ -77,9 +77,12 @@ var sharedData = initializeSharedData({
77
77
errorPrepareStackTraceHook : undefined ,
78
78
/** @type {HookState } */
79
79
processEmitHook : undefined ,
80
- /** @type {HookState & { onConflictingLibraryRedirectArr: Array<(request: string, parent: any, isMain: boolean, redirectedRequest: string) => void> } } */
80
+ /** @type {HookState } */
81
81
moduleResolveFilenameHook : undefined ,
82
82
83
+ /** @type {Array<(request: string, parent: any, isMain: boolean, redirectedRequest: string) => void> } */
84
+ onConflictingLibraryRedirectArr : [ ] ,
85
+
83
86
// If true, the caches are reset before a stack trace formatting operation
84
87
emptyCacheBetweenOperations : false ,
85
88
@@ -644,14 +647,13 @@ exports.install = function(options) {
644
647
if ( redirectConflictingLibrary ) {
645
648
if ( ! sharedData . moduleResolveFilenameHook ) {
646
649
const originalValue = Module . _resolveFilename ;
647
- sharedData . moduleResolveFilenameHook = {
650
+ const moduleResolveFilenameHook = sharedData . moduleResolveFilenameHook = {
648
651
enabled : true ,
649
652
originalValue,
650
653
installedValue : undefined ,
651
- onConflictingLibraryRedirectArr : [ ]
652
654
}
653
655
Module . _resolveFilename = sharedData . moduleResolveFilenameHook . installedValue = function ( request , parent , isMain , options ) {
654
- if ( sharedData . moduleResolveFilenameHook && sharedData . moduleResolveFilenameHook . enabled ) {
656
+ if ( moduleResolveFilenameHook . enabled ) {
655
657
// Match all source-map-support entrypoints: source-map-support, source-map-support/register
656
658
let requestRedirect ;
657
659
if ( request === 'source-map-support' ) {
@@ -662,7 +664,7 @@ exports.install = function(options) {
662
664
663
665
if ( requestRedirect !== undefined ) {
664
666
const newRequest = require . resolve ( requestRedirect ) ;
665
- for ( const cb of sharedData . moduleResolveFilenameHook . onConflictingLibraryRedirectArr ) {
667
+ for ( const cb of sharedData . onConflictingLibraryRedirectArr ) {
666
668
cb ( request , parent , isMain , options , newRequest ) ;
667
669
}
668
670
request = newRequest ;
@@ -673,7 +675,7 @@ exports.install = function(options) {
673
675
}
674
676
}
675
677
if ( onConflictingLibraryRedirect ) {
676
- sharedData . moduleResolveFilenameHook . onConflictingLibraryRedirectArr . push ( onConflictingLibraryRedirect ) ;
678
+ sharedData . onConflictingLibraryRedirectArr . push ( onConflictingLibraryRedirect ) ;
677
679
}
678
680
}
679
681
@@ -790,6 +792,7 @@ exports.uninstall = function() {
790
792
}
791
793
sharedData . moduleResolveFilenameHook = undefined ;
792
794
}
795
+ sharedData . onConflictingLibraryRedirectArr . length = 0 ;
793
796
}
794
797
795
798
exports . resetRetrieveHandlers = function ( ) {
0 commit comments