lib: always initialize esm loader callbackMap#34127
Closed
codebytere wants to merge 1 commit intonodejs:masterfrom
Closed
lib: always initialize esm loader callbackMap#34127codebytere wants to merge 1 commit intonodejs:masterfrom
codebytere wants to merge 1 commit intonodejs:masterfrom
Conversation
5281e84 to
faa8083
Compare
Collaborator
Member
|
Would it maybe make more sense to provide diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js
index a51dbf05ec4f..8d4c44922ac0 100644
--- a/lib/internal/bootstrap/pre_execution.js
+++ b/lib/internal/bootstrap/pre_execution.js
@@ -60,9 +60,7 @@ function prepareMainThreadExecution(expandArgv1 = false) {
initializeWASI();
initializeCJSLoader();
- if (!shouldNotRegisterESMLoader) {
- initializeESMLoader();
- }
+ initializeESMLoader();
const CJSLoader = require('internal/modules/cjs/loader');
assert(!CJSLoader.hasLoadedAnyUserCJSModule);
@@ -406,6 +404,8 @@ function initializeESMLoader() {
// Create this WeakMap in js-land because V8 has no C++ API for WeakMap.
internalBinding('module_wrap').callbackMap = new SafeWeakMap();
+ if (!shouldNotRegisterESMLoader) return;
+
const {
setImportModuleDynamicallyCallback,
setInitializeImportMetaObjectCallbackThat requires a smaller patch and would also make things easier in case we do figure out a good way to mix ESM loaders (e.g. by making them per-Context)? |
Member
Author
|
That also works! Will do :) |
faa8083 to
35ea6de
Compare
addaleax
approved these changes
Jul 1, 2020
devsnek
approved these changes
Jul 1, 2020
Collaborator
Member
Author
|
Landed in 37fc587 |
codebytere
added a commit
that referenced
this pull request
Jul 3, 2020
PR-URL: #34127 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host>
MylesBorins
pushed a commit
that referenced
this pull request
Jul 14, 2020
PR-URL: #34127 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host>
Merged
MylesBorins
pushed a commit
that referenced
this pull request
Jul 16, 2020
PR-URL: #34127 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host>
addaleax
pushed a commit
that referenced
this pull request
Sep 23, 2020
PR-URL: #34127 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #34060.
We should instead unilaterally initialize the
callbackMapand return early if an embedder is choosing to not use the Node.js esm loader is in an embedder context.I also updated the corresponding tests to more directly check
importModuleDynamicallyfunctionality affected by a decision to not use the esm loader provided by Node.js.cc @addaleax @joyeecheung
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes