@@ -32,7 +32,6 @@ const {
3232 ArrayPrototypeJoin,
3333 Error,
3434 JSONParse,
35- Map,
3635 Number,
3736 ObjectCreate,
3837 ObjectDefineProperty,
@@ -113,8 +112,6 @@ const {
113112} = require ( 'internal/util/types' ) ;
114113
115114const asyncESM = require ( 'internal/process/esm_loader' ) ;
116- const ModuleJob = require ( 'internal/modules/esm/module_job' ) ;
117- const { ModuleWrap, kInstantiated } = internalBinding ( 'module_wrap' ) ;
118115const {
119116 encodedSepRegEx,
120117 packageInternalResolve
@@ -374,7 +371,7 @@ function tryPackage(requestPath, exts, isMain, originalPath) {
374371// In order to minimize unnecessary lstat() calls,
375372// this cache is a list of known-real paths.
376373// Set to an empty Map to reset.
377- const realpathCache = new Map ( ) ;
374+ const realpathCache = new SafeMap ( ) ;
378375
379376// Check if the file exists and is not a directory
380377// if using --preserve-symlinks and isMain is false,
@@ -1118,31 +1115,6 @@ Module.prototype.load = function(filename) {
11181115 }
11191116 Module . _extensions [ extension ] ( this , filename ) ;
11201117 this . loaded = true ;
1121-
1122- const ESMLoader = asyncESM . ESMLoader ;
1123- const url = `${ pathToFileURL ( filename ) } ` ;
1124- const module = ESMLoader . moduleMap . get ( url ) ;
1125- // Create module entry at load time to snapshot exports correctly
1126- const exports = this . exports ;
1127- // Called from cjs translator
1128- if ( module !== undefined && module . module !== undefined ) {
1129- if ( module . module . getStatus ( ) >= kInstantiated )
1130- module . module . setExport ( 'default' , exports ) ;
1131- } else {
1132- // Preemptively cache
1133- // We use a function to defer promise creation for async hooks.
1134- ESMLoader . moduleMap . set (
1135- url ,
1136- // Module job creation will start promises.
1137- // We make it a function to lazily trigger those promises
1138- // for async hooks compatibility.
1139- ( ) => new ModuleJob ( ESMLoader , url , ( ) =>
1140- new ModuleWrap ( url , undefined , [ 'default' ] , function ( ) {
1141- this . setExport ( 'default' , exports ) ;
1142- } )
1143- , false /* isMain */ , false /* inspectBrk */ )
1144- ) ;
1145- }
11461118} ;
11471119
11481120
@@ -1262,7 +1234,7 @@ Module.prototype._compile = function(content, filename) {
12621234 const exports = this . exports ;
12631235 const thisValue = exports ;
12641236 const module = this ;
1265- if ( requireDepth === 0 ) statCache = new Map ( ) ;
1237+ if ( requireDepth === 0 ) statCache = new SafeMap ( ) ;
12661238 if ( inspectorWrapper ) {
12671239 result = inspectorWrapper ( compiledWrapper , thisValue , exports ,
12681240 require , module , filename , dirname ) ;
0 commit comments