@@ -42,6 +42,10 @@ const {
4242} = require ( 'internal/modules/helpers' ) ;
4343let defaultResolve , defaultLoad , defaultLoadSync , importMetaInitializer ;
4444
45+ /**
46+ * @typedef {import('url').URL } URL
47+ */
48+
4549/**
4650 * Lazy loads the module_map module and returns a new instance of ResolveCache.
4751 * @returns {import('./module_map.js').ResolveCache') }
@@ -77,6 +81,10 @@ function getTranslators() {
7781 */
7882let hooksProxy ;
7983
84+ /**
85+ * @typedef {import('../cjs/loader.js').Module } CJSModule
86+ */
87+
8088/**
8189 * @typedef {Record<string, any> } ModuleExports
8290 */
@@ -257,11 +265,11 @@ class ModuleLoader {
257265 /**
258266 * This constructs (creates, instantiates and evaluates) a module graph that
259267 * is require()'d.
260- * @param {import('../cjs/loader.js').Module } mod CJS module wrapper of the ESM.
268+ * @param {CJSModule } mod CJS module wrapper of the ESM.
261269 * @param {string } filename Resolved filename of the module being require()'d
262270 * @param {string } source Source code. TODO(joyeecheung): pass the raw buffer.
263271 * @param {string } isMain Whether this module is a main module.
264- * @param {import('../cjs/loader.js').Module |undefined } parent Parent module, if any.
272+ * @param {CJSModule |undefined } parent Parent module, if any.
265273 * @returns {{ModuleWrap} }
266274 */
267275 importSyncForRequire ( mod , filename , source , isMain , parent ) {
@@ -343,7 +351,7 @@ class ModuleLoader {
343351 }
344352 throw new ERR_REQUIRE_CYCLE_MODULE ( message ) ;
345353 }
346- // Othersie the module could be imported before but the evaluation may be already
354+ // Otherwise the module could be imported before but the evaluation may be already
347355 // completed (e.g. the require call is lazy) so it's okay. We will return the
348356 // module now and check asynchronicity of the entire graph later, after the
349357 // graph is instantiated.
@@ -352,8 +360,12 @@ class ModuleLoader {
352360
353361 defaultLoadSync ??= require ( 'internal/modules/esm/load' ) . defaultLoadSync ;
354362 const loadResult = defaultLoadSync ( url , { format, importAttributes } ) ;
355- const { responseURL, source } = loadResult ;
356- const { format : finalFormat } = loadResult ;
363+ const {
364+ format : finalFormat ,
365+ responseURL,
366+ source,
367+ } = loadResult ;
368+
357369 this . validateLoadResult ( url , finalFormat ) ;
358370 if ( finalFormat === 'wasm' ) {
359371 assert . fail ( 'WASM is currently unsupported by require(esm)' ) ;
@@ -725,11 +737,11 @@ function getOrInitializeCascadedLoader() {
725737
726738/**
727739 * Register a single loader programmatically.
728- * @param {string|import('url'). URL } specifier
729- * @param {string|import('url'). URL } [parentURL] Base to use when resolving `specifier`; optional if
740+ * @param {string|URL } specifier
741+ * @param {string|URL } [parentURL] Base to use when resolving `specifier`; optional if
730742 * `specifier` is absolute. Same as `options.parentUrl`, just inline
731743 * @param {object } [options] Additional options to apply, described below.
732- * @param {string|import('url'). URL } [options.parentURL] Base to use when resolving `specifier`
744+ * @param {string|URL } [options.parentURL] Base to use when resolving `specifier`
733745 * @param {any } [options.data] Arbitrary data passed to the loader's `initialize` hook
734746 * @param {any[] } [options.transferList] Objects in `data` that are changing ownership
735747 * @returns {void } We want to reserve the return value for potential future extension of the API.
0 commit comments