mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
* chore: bump node in DEPS to v20.19.0 * deps, src: simplifying base64 encoding https://github.com/nodejs/node/pull/52714 * module: simplify --inspect-brk handling https://github.com/nodejs/node/pull/55679 * test: make test-crypto-hash compatible with OpenSSL > 3.4.0 https://github.com/nodejs/node/pull/56160 * module: refactor ESM loader for adding future synchronous hooks https://github.com/nodejs/node/pull/54769 * module: detect ESM syntax by trying to recompile as SourceTextModule https://github.com/nodejs/node/pull/52413 * worker: add postMessageToThread https://github.com/nodejs/node/pull/53682 * backport unflagging of require(esm) to v20 https://github.com/nodejs/node/pull/56927 * module: detect ESM syntax by trying to recompile as SourceTextModule https://github.com/nodejs/node/pull/52413 * chore: fixup patch indices * chore: handle filename.json changes - https://github.com/nodejs/node/pull/51711 - https://github.com/nodejs/node/pull/53573 * src: refactor embedded entrypoint loading https://github.com/nodejs/node/pull/53573 * lib: allow CJS source map cache to be reclaimed https://github.com/nodejs/node/pull/51711 * test: make eval snapshot tests more flexible --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
75 lines
3.1 KiB
Diff
75 lines
3.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samuel Attard <marshallofsound@electronjs.org>
|
|
Date: Wed, 26 Jul 2023 17:03:15 -0700
|
|
Subject: fix: do not resolve electron entrypoints
|
|
|
|
This wastes fs cycles and can result in strange behavior if this path actually exists on disk
|
|
|
|
diff --git a/lib/internal/modules/esm/load.js b/lib/internal/modules/esm/load.js
|
|
index 41daab801d67689b50cc5e10a0e167701da301f8..227d31d19317ec94348c67029b407b3e534ab1b6 100644
|
|
--- a/lib/internal/modules/esm/load.js
|
|
+++ b/lib/internal/modules/esm/load.js
|
|
@@ -134,7 +134,7 @@ async function defaultLoad(url, context = kEmptyObject) {
|
|
source = null;
|
|
format ??= 'builtin';
|
|
} else if (format !== 'commonjs' || defaultType === 'module') {
|
|
- if (source == null) {
|
|
+ if (format !== 'electron' && source == null) {
|
|
({ responseURL, source } = await getSource(urlInstance, context));
|
|
context = { __proto__: context, source };
|
|
}
|
|
diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js
|
|
index 27cf7d0ae4a9e07897f8b1faef2884aec29d3975..6943c7973b4ae5246f4b019331c45aa9619eb017 100644
|
|
--- a/lib/internal/modules/esm/translators.js
|
|
+++ b/lib/internal/modules/esm/translators.js
|
|
@@ -322,6 +322,9 @@ function cjsPreparseModuleExports(filename, source) {
|
|
if (module && module[kModuleExportNames] !== undefined) {
|
|
return { module, exportNames: module[kModuleExportNames] };
|
|
}
|
|
+ if (filename === 'electron') {
|
|
+ return { module, exportNames: new SafeSet(['default', ...Object.keys(module.exports)]) };
|
|
+ }
|
|
const loaded = Boolean(module);
|
|
if (!loaded) {
|
|
module = new CJSModule(filename);
|
|
diff --git a/lib/internal/modules/run_main.js b/lib/internal/modules/run_main.js
|
|
index a22bddf635f5e6270554ac87f11f4e12f540a84c..b0543b4ca1ddcf289d9c4162e6641f0b4af8b7bd 100644
|
|
--- a/lib/internal/modules/run_main.js
|
|
+++ b/lib/internal/modules/run_main.js
|
|
@@ -2,6 +2,7 @@
|
|
|
|
const {
|
|
StringPrototypeEndsWith,
|
|
+ StringPrototypeStartsWith,
|
|
} = primordials;
|
|
|
|
const { getOptionValue } = require('internal/options');
|
|
@@ -21,6 +22,13 @@ const {
|
|
* @param {string} main - Entry point path
|
|
*/
|
|
function resolveMainPath(main) {
|
|
+ // For built-in modules used as the main entry point we _never_
|
|
+ // want to waste cycles resolving them to file paths on disk
|
|
+ // that actually might exist
|
|
+ if (typeof main === 'string' && StringPrototypeStartsWith(main, 'electron/js2c')) {
|
|
+ return main;
|
|
+ }
|
|
+
|
|
const defaultType = getOptionValue('--experimental-default-type');
|
|
/** @type {string} */
|
|
let mainPath;
|
|
@@ -57,6 +65,13 @@ function resolveMainPath(main) {
|
|
* @param {string} mainPath - Absolute path to the main entry point
|
|
*/
|
|
function shouldUseESMLoader(mainPath) {
|
|
+ // For built-in modules used as the main entry point we _never_
|
|
+ // want to waste cycles resolving them to file paths on disk
|
|
+ // that actually might exist
|
|
+ if (typeof mainPath === 'string' && StringPrototypeStartsWith(mainPath, 'electron/js2c')) {
|
|
+ return false;
|
|
+ }
|
|
+
|
|
if (getOptionValue('--experimental-default-type') === 'module') { return true; }
|
|
|
|
/**
|