forked from electron/electron
-
Notifications
You must be signed in to change notification settings - Fork 1
/
fix_do_not_register_the_esm_loader_in_renderer_processes.patch
29 lines (24 loc) · 1.48 KB
/
fix_do_not_register_the_esm_loader_in_renderer_processes.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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