fix: declare ms + debug as direct deps to unblock packaged auto-updater#66
Merged
Merged
Conversation
electron-builder + pnpm has a known dep-walker bug (electron-userland/electron-builder#9654) that drops `ms` from the packaged asar even when node_modules is hoisted flat. Without `ms`, packaged builds crash on launch the moment `electron-updater` loads — the require chain is `electron-updater → builder-util-runtime → debug → ms`. The bug has been latent on main since #47 merged 90s after v0.2.1 was tagged, so no shipped release has exercised it. Workaround: promote `debug` and `ms` from transitives of `electron-updater` to direct dependencies. electron-builder includes direct deps reliably regardless of its pnpm walker behaviour. Also set `nodeLinker: hoisted` + `shamefullyHoist: true` in pnpm-workspace.yaml (pnpm 10+ ignores these in .npmrc). With the explicit deps the hoisted linker isn't strictly required, but it keeps the layout predictable for any other electron-builder traversal. Verified locally: `npx asar list` on the built .app now shows `/node_modules/ms/package.json`, and the installed .app launches without the `Cannot find module 'ms'` exception. Remove these explicit deps when #9654 is fixed upstream.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
debugandmsfrom transitive deps ofelectron-updaterto direct dependencies inpackage.jsonso electron-builder reliably packages them.nodeLinker: hoisted+shamefullyHoist: trueinpnpm-workspace.yaml(pnpm 10+ ignores these in.npmrc).electron-builder.yml.Why
electron-builderhas a known dep-walker bug (electron-userland/electron-builder#9654) where, on a pnpm project, its asar packaging drops transitives of bundled packages even whennode_modulesis hoisted flat. The result:node_modules/ms/package.jsonexists on disk at the top level but doesn't end up in the asar.For this app the practical consequence is fatal: any packaged build crashes on launch with:
The bug has been latent on
mainsince #47 (the auto-updater wiring) merged 90 seconds after v0.2.1 was tagged. No shipped release has exercised theelectron-updaterimport path. Without this fix, the next tagged release would crash on launch.How
Declaring transitives as direct deps is electron-builder's documented workaround for #9654. Direct deps are walked reliably regardless of pnpm-specific behaviour. The explanatory comment in
electron-builder.ymlpoints future maintainers at the upstream issue so the workaround can be removed once it's fixed.Test plan
pnpm typecheckcleanpnpm lintcleanpnpm test— 84 tests passpnpm build:macsucceedsnpx asar list dist/mac-arm64/SuperWhisper\ Analytics.app/Contents/Resources/app.asarincludes/node_modules/ms/package.json.applaunches without theCannot find module 'ms'exception (main process plus renderer/GPU/network helpers all spawn)v0.3.0, watch CI release workflow, install the resulting signed + notarised.dmg, confirm clean launch and "Check for updates" returns up-to-date