Fix @electron/rebuild pnpm issue

This commit is contained in:
Fedor Indutny
2025-04-09 15:14:47 -07:00
committed by GitHub
parent 7783d9ed38
commit 775a17c677
3 changed files with 37 additions and 3 deletions

View File

@@ -375,7 +375,8 @@
"@types/websocket@1.0.0": "patches/@types+websocket+1.0.0.patch",
"backbone@1.6.0": "patches/backbone+1.6.0.patch",
"node-fetch@2.6.7": "patches/node-fetch+2.6.7.patch",
"zod@3.23.8": "patches/zod+3.23.8.patch"
"zod@3.23.8": "patches/zod+3.23.8.patch",
"@electron/rebuild": "patches/@electron__rebuild.patch"
},
"onlyBuiltDependencies": [
"@indutny/mac-screen-share",

View File

@@ -0,0 +1,30 @@
diff --git a/lib/module-walker.js b/lib/module-walker.js
index b36e35c968c85b625f2080466f6518b1d355e4ef..427e81b7ada4f01e8712c4c6c8353fe0ff4f7cab 100644
--- a/lib/module-walker.js
+++ b/lib/module-walker.js
@@ -89,11 +89,22 @@ class ModuleWalker {
// Ignore the magical .bin directory
if (modulePath === '.bin')
continue;
+ const subPath = path_1.default.resolve(nodeModulesPath, modulePath);
// Ensure that we don't mark modules as needing to be rebuilt more than once
// by ignoring / resolving symlinks
- const realPath = await fs_extra_1.default.realpath(path_1.default.resolve(nodeModulesPath, modulePath));
- if (this.realModulePaths.has(realPath)) {
- continue;
+ let realPath;
+ try {
+ realPath = await fs_extra_1.default.realpath(subPath);
+ }
+ catch (error) {
+ // pnpm leaves dangling symlinks when modules are removed
+ if (error.code === 'ENOENT') {
+ const stat = await fs_extra_1.default.lstat(subPath);
+ if (stat.isSymbolicLink()) {
+ continue;
+ }
+ }
+ throw error;
}
this.realModulePaths.add(realPath);
if (this.prodDeps[`${prefix}${modulePath}`] && (!this.onlyModules || this.onlyModules.includes(modulePath))) {

7
pnpm-lock.yaml generated
View File

@@ -15,6 +15,9 @@ overrides:
'@electron/rebuild@3.7.0>@electron/node-gyp': 10.2.0-electron.2
patchedDependencies:
'@electron/rebuild':
hash: 31649378d7bedcb532b7f379773ffc7df45968de1ac73c6d1b9f06cc521071fa
path: patches/@electron__rebuild.patch
'@types/backbone@1.4.22':
hash: 9dace206a9f53e0e3b0203051b26aec1e92ad49744b156ad8076946356c6c8e7
path: patches/@types+backbone+1.4.22.patch
@@ -10124,7 +10127,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
'@electron/rebuild@3.7.0':
'@electron/rebuild@3.7.0(patch_hash=31649378d7bedcb532b7f379773ffc7df45968de1ac73c6d1b9f06cc521071fa)':
dependencies:
'@electron/node-gyp': 10.2.0-electron.2
'@malept/cross-spawn-promise': 2.0.0
@@ -13420,7 +13423,7 @@ snapshots:
'@electron/fuses': 1.8.0
'@electron/notarize': 2.5.0
'@electron/osx-sign': 1.3.1
'@electron/rebuild': 3.7.0
'@electron/rebuild': 3.7.0(patch_hash=31649378d7bedcb532b7f379773ffc7df45968de1ac73c6d1b9f06cc521071fa)
'@electron/universal': 2.0.1
'@malept/flatpak-bundler': 0.4.0
'@types/fs-extra': 9.0.13