mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
* chore: bump node in DEPS to v24.12.0 * src: use CP_UTF8 for wide file names on win32 https://github.com/nodejs/node/pull/60575 * test,crypto: handle a few more BoringSSL tests https://github.com/nodejs/node/pull/59030 * chore: fixup patch indices * chore: re-add accidentally removed sslv23 test * chore: fixup crypto patch rebase * test: make buffer sizes 32bit-aware in test-internal-util-construct-sab https://github.com/nodejs/node/pull/61026 * src: add internal binding for constructing SharedArrayBuffers https://github.com/nodejs/node/pull/60497 * chore: bump node in DEPS to v24.13.0 * chore: fixup patch indices * chore: fixup sandboxed pointers patch * tls: route callback exceptions through error handlers https://github.com/nodejs-private/node-private/pull/782 --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
63 lines
2.4 KiB
Diff
63 lines
2.4 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/translators.js b/lib/internal/modules/esm/translators.js
|
|
index e4d5579565eea07013c8260fa3c4aa3b266a4b35..fbcef937b26023e0f6f97a0e58ac7350e7616f58 100644
|
|
--- a/lib/internal/modules/esm/translators.js
|
|
+++ b/lib/internal/modules/esm/translators.js
|
|
@@ -407,6 +407,10 @@ function cjsPreparseModuleExports(filename, source, format) {
|
|
return { module, exportNames: module[kModuleExportNames] };
|
|
}
|
|
|
|
+ if (filename === 'electron') {
|
|
+ return { module, exportNames: new SafeSet(['default', ...Object.keys(module.exports)]) };
|
|
+ }
|
|
+
|
|
if (source === undefined) {
|
|
({ source } = loadSourceForCJSWithHooks(module, filename, format));
|
|
}
|
|
diff --git a/lib/internal/modules/run_main.js b/lib/internal/modules/run_main.js
|
|
index 2974459755ec25139aefdab7f36811e036ac4204..593235acacd266ba7d6f1925032cd5ba455c29da 100644
|
|
--- a/lib/internal/modules/run_main.js
|
|
+++ b/lib/internal/modules/run_main.js
|
|
@@ -2,6 +2,7 @@
|
|
|
|
const {
|
|
StringPrototypeEndsWith,
|
|
+ StringPrototypeStartsWith,
|
|
globalThis,
|
|
} = primordials;
|
|
|
|
@@ -27,6 +28,13 @@ const {
|
|
* @returns {string|undefined}
|
|
*/
|
|
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;
|
|
+ }
|
|
+
|
|
/** @type {string} */
|
|
let mainPath;
|
|
// Extension searching for the main entry point is supported for backward compatibility.
|
|
@@ -50,6 +58,13 @@ function resolveMainPath(main) {
|
|
* @returns {boolean}
|
|
*/
|
|
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;
|
|
+ }
|
|
+
|
|
/**
|
|
* @type {string[]} userLoaders A list of custom loaders registered by the user
|
|
* (or an empty list when none have been registered).
|