forked from electron/electron
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not register the node ESM loader in renderer processes (elect…
- Loading branch information
1 parent
71ce7f1
commit 6dfcdbb
Showing
5 changed files
with
32 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
29 changes: 29 additions & 0 deletions
29
patches/node/fix_do_not_register_the_esm_loader_in_renderer_processes.patch
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Samuel Attard <samuel.r.attard@gmail.com> | ||
Date: Thu, 25 Jun 2020 09:29:04 -0700 | ||
Subject: fix: do not register the ESM loader in renderer processes | ||
|
||
Only one ESM loader can be registered per isolate, in renderer processes this should be blink. This patches node so that it won't register it's handler (overriding blinks) in non-browser processes. | ||
|
||
This has been upstreamed in: | ||
* https://github.com/nodejs/node/pull/34060 | ||
* https://github.com/nodejs/node/pull/34127 | ||
|
||
We can't easily rebase on that accepted solution here but we can as soon as we upgrade to | ||
Node.js v14, since we need to leverage the new version of node::CreateEnvironment | ||
introduced in https://github.com/nodejs/node/pull/30467. | ||
|
||
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js | ||
index b4a0f71af5853f427a10449b52509052fbe3facd..ba5b0b6e51bcddbc5b9dd9c31231585d61b131a0 100644 | ||
--- a/lib/internal/bootstrap/pre_execution.js | ||
+++ b/lib/internal/bootstrap/pre_execution.js | ||
@@ -411,6 +411,9 @@ function initializeESMLoader() { | ||
// Create this WeakMap in js-land because V8 has no C++ API for WeakMap. | ||
internalBinding('module_wrap').callbackMap = new SafeWeakMap(); | ||
|
||
+ // Do not hook the ESM loader in renderer processes as it overrides blinks loader | ||
+ if (typeof process.type === 'string' && process.type !== 'browser') return; | ||
+ | ||
const { | ||
setImportModuleDynamicallyCallback, | ||
setInitializeImportMetaObjectCallback |
This file contains 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
This file contains 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
This file contains 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