Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.3k
vm: support using the default loader to handle dynamic import()#51244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
4f055d24a483450e47585edbd1d40c45167File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -68,23 +68,31 @@ function prepareWorkerThreadExecution(){ | ||
| } | ||
| function prepareShadowRealmExecution(){ | ||
| const{registerRealm } = require('internal/modules/esm/utils'); | ||
joyeecheung marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| // Patch the process object with legacy properties and normalizations. | ||
| // Do not expand argv1 as it is not available in ShadowRealm. | ||
| patchProcessObject(false); | ||
| setupDebugEnv(); | ||
| // Disable custom loaders in ShadowRealm. | ||
| setupUserModules(true); | ||
| registerRealm(globalThis,{ | ||
joyeecheung marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| __proto__: null, | ||
| importModuleDynamically: (specifier, _referrer, attributes) =>{ | ||
| // The handler for `ShadowRealm.prototype.importValue`. | ||
| const{esmLoader } = require('internal/process/esm_loader'); | ||
| // `parentURL` is not set in the case of a ShadowRealm top-level import. | ||
| return esmLoader.import(specifier, undefined, attributes); | ||
| const{ | ||
| privateSymbols:{ | ||
| host_defined_option_symbol, | ||
| }, | ||
| }); | ||
| } = internalBinding('util'); | ||
| const{ | ||
| vm_dynamic_import_default_internal, | ||
| } = internalBinding('symbols'); | ||
| // For ShadowRealm.prototype.importValue(), the referrer name is | ||
| // always null, so the native ImportModuleDynamically() callback would | ||
| // always fallback to look up the host-defined option from the | ||
| // global object using host_defined_option_symbol. Using | ||
| // vm_dynamic_import_default_internal as the host-defined option | ||
| // instructs the JS-land importModuleDynamicallyCallback() to | ||
| // proxy the request to defaultImportModuleDynamically(). | ||
| globalThis[host_defined_option_symbol] = | ||
| vm_dynamic_import_default_internal; | ||
| } | ||
| function prepareExecution(options){ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -107,12 +107,10 @@ function extractSourceMapURLMagicComment(content){ | ||
| function maybeCacheSourceMap(filename, content, cjsModuleInstance, isGeneratedSource, sourceURL, sourceMapURL){ | ||
| const sourceMapsEnabled = getSourceMapsEnabled(); | ||
| if (!(process.env.NODE_V8_COVERAGE || sourceMapsEnabled)) return; | ||
| try{ | ||
| const{normalizeReferrerURL } = require('internal/modules/helpers'); | ||
| filename = normalizeReferrerURL(filename); | ||
| } catch (err){ | ||
| const{normalizeReferrerURL } = require('internal/modules/helpers'); | ||
| filename = normalizeReferrerURL(filename); | ||
| if (filename === undefined){ | ||
Comment on lines 107 to +112 Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function could really use a JSDoc, if you know what it should be. What is This feature should support MemberAuthor
| ||
| // This is most likely an invalid filename in sourceURL of [eval]-wrapper. | ||
| debug(err); | ||
| return; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.