@@ -62,7 +62,7 @@ const {
6262 loadWithHooks : loadWithSyncHooks ,
6363 validateLoadSloppy,
6464} = require ( 'internal/modules/customization_hooks' ) ;
65- let defaultResolve , defaultLoadSync , importMetaInitializer ;
65+ let importMetaInitializer ;
6666
6767const { tracingChannel } = require ( 'diagnostics_channel' ) ;
6868const onImport = tracingChannel ( 'module.import' ) ;
@@ -97,19 +97,9 @@ function newLoadCache() {
9797 return new LoadCache ( ) ;
9898}
9999
100- let _translators ;
101- function lazyLoadTranslators ( ) {
102- _translators ??= require ( 'internal/modules/esm/translators' ) ;
103- return _translators ;
104- }
105-
106- /**
107- * Lazy-load translators to avoid potentially unnecessary work at startup (ex if ESM is not used).
108- * @returns {import('./translators.js').Translators }
109- */
110- function getTranslators ( ) {
111- return lazyLoadTranslators ( ) . translators ;
112- }
100+ const { translators } = require ( 'internal/modules/esm/translators' ) ;
101+ const { defaultResolve } = require ( 'internal/modules/esm/resolve' ) ;
102+ const { defaultLoadSync, throwUnknownModuleFormat } = require ( 'internal/modules/esm/load' ) ;
113103
114104/**
115105 * Generate message about potential race condition caused by requiring a cached module that has started
@@ -178,18 +168,6 @@ class ModuleLoader {
178168 */
179169 loadCache = newLoadCache ( ) ;
180170
181- /**
182- * Methods which translate input code or other information into ES modules
183- */
184- translators = getTranslators ( ) ;
185-
186- /**
187- * Truthy to allow the use of `import.meta.resolve`. This is needed
188- * currently because the `Hooks` class does not have `resolveSync`
189- * implemented and `import.meta.resolve` requires it.
190- */
191- allowImportMetaResolve ;
192-
193171 /**
194172 * @see {AsyncLoaderHooks.isForAsyncLoaderHookWorker}
195173 * Shortcut to this.#asyncLoaderHooks.isForAsyncLoaderHookWorker.
@@ -464,7 +442,7 @@ class ModuleLoader {
464442 #translate( url , translateContext , parentURL ) {
465443 const { translatorKey, format } = translateContext ;
466444 this . validateLoadResult ( url , format ) ;
467- const translator = getTranslators ( ) . get ( translatorKey ) ;
445+ const translator = translators . get ( translatorKey ) ;
468446
469447 if ( ! translator ) {
470448 throw new ERR_UNKNOWN_MODULE_FORMAT ( translatorKey , url ) ;
@@ -715,7 +693,7 @@ class ModuleLoader {
715693 if ( cachedResult != null ) {
716694 return cachedResult ;
717695 }
718- defaultResolve ??= require ( 'internal/modules/esm/resolve' ) . defaultResolve ;
696+
719697 const result = defaultResolve ( specifier , context ) ;
720698 this . #resolveCache. set ( requestKey , parentURL , result ) ;
721699 return result ;
@@ -792,7 +770,6 @@ class ModuleLoader {
792770 if ( this . #asyncLoaderHooks?. loadSync ) {
793771 return this . #asyncLoaderHooks. loadSync ( url , context ) ;
794772 }
795- defaultLoadSync ??= require ( 'internal/modules/esm/load' ) . defaultLoadSync ;
796773 return defaultLoadSync ( url , context ) ;
797774 }
798775
@@ -818,7 +795,7 @@ class ModuleLoader {
818795
819796 validateLoadResult ( url , format ) {
820797 if ( format == null ) {
821- require ( 'internal/modules/esm/load' ) . throwUnknownModuleFormat ( url , format ) ;
798+ throwUnknownModuleFormat ( url , format ) ;
822799 }
823800 }
824801
0 commit comments