Skip to content

Commit 878f184

Browse files
trop[bot]MarshallOfSoundjkleinsc
authored
fix: do not resolve electron entrypoints on disk (#39248)
* fix: do not resolve electron entrypoints on disk Co-authored-by: Samuel Attard <marshallofsound@electronjs.org> * chore: fixup .patches file after trop --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard <marshallofsound@electronjs.org> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
1 parent bbe9d8b commit 878f184

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

patches/node/.patches

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ chore_enable_c_17_for_native_modules.patch
5555
enable_crashpad_linux_node_processes.patch
5656
cherry-pick-09ae62b.patch
5757
allow_embedder_to_control_codegenerationfromstringscallback.patch
58+
fix_do_not_resolve_electron_entrypoints.patch
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Samuel Attard <marshallofsound@electronjs.org>
3+
Date: Wed, 26 Jul 2023 17:03:15 -0700
4+
Subject: fix: do not resolve electron entrypoints
5+
6+
This wastes fs cycles and can result in strange behavior if this path actually exists on disk
7+
8+
diff --git a/lib/internal/modules/run_main.js b/lib/internal/modules/run_main.js
9+
index 5a50d5d6afab6e6648f72a1c0efa1df4cd80bcd9..0be45309028b00a6957ee473322a9452a7fa7d67 100644
10+
--- a/lib/internal/modules/run_main.js
11+
+++ b/lib/internal/modules/run_main.js
12+
@@ -13,6 +13,12 @@ const {
13+
} = require('internal/modules/esm/handle_process_exit');
14+
15+
function resolveMainPath(main) {
16+
+ // For built-in modules used as the main entry point we _never_
17+
+ // want to waste cycles resolving them to file paths on disk
18+
+ // that actually might exist
19+
+ if (typeof main === 'string' && main.startsWith('electron/js2c')) {
20+
+ return main;
21+
+ }
22+
// Note extension resolution for the main entry point can be deprecated in a
23+
// future major.
24+
// Module._findPath is monkey-patchable here.

0 commit comments

Comments
 (0)