@@ -42,6 +42,10 @@ const {
42
42
} = require ( 'internal/modules/helpers' ) ;
43
43
let defaultResolve , defaultLoad , defaultLoadSync , importMetaInitializer ;
44
44
45
+ /**
46
+ * @typedef {import('url').URL } URL
47
+ */
48
+
45
49
/**
46
50
* Lazy loads the module_map module and returns a new instance of ResolveCache.
47
51
* @returns {import('./module_map.js').ResolveCache }
@@ -77,6 +81,10 @@ function getTranslators() {
77
81
*/
78
82
let hooksProxy ;
79
83
84
+ /**
85
+ * @typedef {import('../cjs/loader.js').Module } CJSModule
86
+ */
87
+
80
88
/**
81
89
* @typedef {Record<string, any> } ModuleExports
82
90
*/
@@ -257,11 +265,11 @@ class ModuleLoader {
257
265
/**
258
266
* This constructs (creates, instantiates and evaluates) a module graph that
259
267
* 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.
261
269
* @param {string } filename Resolved filename of the module being require()'d
262
270
* @param {string } source Source code. TODO(joyeecheung): pass the raw buffer.
263
271
* @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.
265
273
* @returns {{ModuleWrap} }
266
274
*/
267
275
importSyncForRequire ( mod , filename , source , isMain , parent ) {
@@ -343,7 +351,7 @@ class ModuleLoader {
343
351
}
344
352
throw new ERR_REQUIRE_CYCLE_MODULE ( message ) ;
345
353
}
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
347
355
// completed (e.g. the require call is lazy) so it's okay. We will return the
348
356
// module now and check asynchronicity of the entire graph later, after the
349
357
// graph is instantiated.
@@ -352,8 +360,12 @@ class ModuleLoader {
352
360
353
361
defaultLoadSync ??= require ( 'internal/modules/esm/load' ) . defaultLoadSync ;
354
362
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
+
357
369
this . validateLoadResult ( url , finalFormat ) ;
358
370
if ( finalFormat === 'wasm' ) {
359
371
assert . fail ( 'WASM is currently unsupported by require(esm)' ) ;
@@ -725,11 +737,11 @@ function getOrInitializeCascadedLoader() {
725
737
726
738
/**
727
739
* 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
730
742
* `specifier` is absolute. Same as `options.parentUrl`, just inline
731
743
* @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`
733
745
* @param {any } [options.data] Arbitrary data passed to the loader's `initialize` hook
734
746
* @param {any[] } [options.transferList] Objects in `data` that are changing ownership
735
747
* @returns {void } We want to reserve the return value for potential future extension of the API.
0 commit comments