@@ -113,6 +113,16 @@ function getConditionsSet(conditions) {
113113 */
114114const moduleRegistries = new SafeWeakMap ( ) ;
115115
116+ /**
117+ * @typedef {ContextifyScript|Function|ModuleWrap|ContextifiedObject } Referrer
118+ * A referrer can be a Script Record, a Cyclic Module Record, or a Realm Record
119+ * as defined in https://tc39.es/ecma262/#sec-HostLoadImportedModule.
120+ *
121+ * In Node.js, a referrer is represented by a wrapper object of these records.
122+ * A referrer object has a field |host_defined_option_symbol| initialized with
123+ * a symbol.
124+ */
125+
116126/**
117127 * V8 would make sure that as long as import() can still be initiated from
118128 * the referrer, the symbol referenced by |host_defined_option_symbol| should
@@ -127,7 +137,7 @@ const moduleRegistries = new SafeWeakMap();
127137 * referrer wrap is still around and can be passed into the callbacks.
128138 * 2 is only there so that we can get the id symbol to configure the
129139 * weak map.
130- * @param {ModuleWrap|ContextifyScript|Function } referrer The referrer to
140+ * @param {Referrer } referrer The referrer to
131141 * get the id symbol from. This is different from callbackReferrer which
132142 * could be set by the caller.
133143 * @param {ModuleRegistry } registry
@@ -163,20 +173,20 @@ function initializeImportMetaObject(symbol, meta) {
163173
164174/**
165175 * Asynchronously imports a module dynamically using a callback function. The native callback.
166- * @param {symbol } symbol - Reference to the module.
176+ * @param {symbol } referrerSymbol - Referrer symbol of the registered script, function, module, or contextified object .
167177 * @param {string } specifier - The module specifier string.
168178 * @param {Record<string, string> } attributes - The import attributes object.
169179 * @returns {Promise<import('internal/modules/esm/loader.js').ModuleExports> } - The imported module object.
170180 * @throws {ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING } - If the callback function is missing.
171181 */
172- async function importModuleDynamicallyCallback ( symbol , specifier , attributes ) {
173- if ( moduleRegistries . has ( symbol ) ) {
174- const { importModuleDynamically, callbackReferrer } = moduleRegistries . get ( symbol ) ;
182+ async function importModuleDynamicallyCallback ( referrerSymbol , specifier , attributes ) {
183+ if ( moduleRegistries . has ( referrerSymbol ) ) {
184+ const { importModuleDynamically, callbackReferrer } = moduleRegistries . get ( referrerSymbol ) ;
175185 if ( importModuleDynamically !== undefined ) {
176186 return importModuleDynamically ( specifier , callbackReferrer , attributes ) ;
177187 }
178188 }
179- if ( symbol === vm_dynamic_import_missing_flag ) {
189+ if ( referrerSymbol === vm_dynamic_import_missing_flag ) {
180190 throw new ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG ( ) ;
181191 }
182192 throw new ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING ( ) ;
0 commit comments