@@ -113,6 +113,16 @@ function getConditionsSet(conditions) {
113
113
*/
114
114
const moduleRegistries = new SafeWeakMap ( ) ;
115
115
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
+
116
126
/**
117
127
* V8 would make sure that as long as import() can still be initiated from
118
128
* the referrer, the symbol referenced by |host_defined_option_symbol| should
@@ -127,7 +137,7 @@ const moduleRegistries = new SafeWeakMap();
127
137
* referrer wrap is still around and can be passed into the callbacks.
128
138
* 2 is only there so that we can get the id symbol to configure the
129
139
* weak map.
130
- * @param {ModuleWrap|ContextifyScript|Function } referrer The referrer to
140
+ * @param {Referrer } referrer The referrer to
131
141
* get the id symbol from. This is different from callbackReferrer which
132
142
* could be set by the caller.
133
143
* @param {ModuleRegistry } registry
@@ -163,20 +173,20 @@ function initializeImportMetaObject(symbol, meta) {
163
173
164
174
/**
165
175
* 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 .
167
177
* @param {string } specifier - The module specifier string.
168
178
* @param {Record<string, string> } attributes - The import attributes object.
169
179
* @returns {Promise<import('internal/modules/esm/loader.js').ModuleExports> } - The imported module object.
170
180
* @throws {ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING } - If the callback function is missing.
171
181
*/
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 ) ;
175
185
if ( importModuleDynamically !== undefined ) {
176
186
return importModuleDynamically ( specifier , callbackReferrer , attributes ) ;
177
187
}
178
188
}
179
- if ( symbol === vm_dynamic_import_missing_flag ) {
189
+ if ( referrerSymbol === vm_dynamic_import_missing_flag ) {
180
190
throw new ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING_FLAG ( ) ;
181
191
}
182
192
throw new ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING ( ) ;
0 commit comments