2023-07-27 05:10:58 +00:00
|
|
|
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/run_main.js b/lib/internal/modules/run_main.js
|
2023-09-20 20:13:43 +00:00
|
|
|
index daaa153516c424334c18b5dfa35e0e55e1fbcce4..6181cc21bf303c41ed9c65681a34f6393223fb67 100644
|
2023-07-27 05:10:58 +00:00
|
|
|
--- a/lib/internal/modules/run_main.js
|
|
|
|
+++ b/lib/internal/modules/run_main.js
|
2023-08-09 07:32:00 +00:00
|
|
|
@@ -3,6 +3,7 @@
|
|
|
|
const {
|
|
|
|
ObjectCreate,
|
|
|
|
StringPrototypeEndsWith,
|
|
|
|
+ StringPrototypeStartsWith,
|
|
|
|
} = primordials;
|
|
|
|
const CJSLoader = require('internal/modules/cjs/loader');
|
|
|
|
const { Module, toRealPath, readPackageScope } = CJSLoader;
|
|
|
|
@@ -13,6 +14,13 @@ const {
|
2023-07-27 05:10:58 +00:00
|
|
|
} = require('internal/modules/esm/handle_process_exit');
|
|
|
|
|
|
|
|
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
|
2023-08-09 07:32:00 +00:00
|
|
|
+ if (typeof main === 'string' && StringPrototypeStartsWith(main, 'electron/js2c')) {
|
2023-07-27 05:10:58 +00:00
|
|
|
+ return main;
|
|
|
|
+ }
|
2023-08-09 07:32:00 +00:00
|
|
|
+
|
2023-07-27 05:10:58 +00:00
|
|
|
// Note extension resolution for the main entry point can be deprecated in a
|
|
|
|
// future major.
|
|
|
|
// Module._findPath is monkey-patchable here.
|
2023-08-09 07:32:00 +00:00
|
|
|
@@ -28,6 +36,13 @@ function resolveMainPath(main) {
|
|
|
|
}
|
|
|
|
|
|
|
|
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).
|