Skip to content

fix: declare ms + debug as direct deps to unblock packaged auto-updater#66

Merged
aicayzer merged 1 commit into
mainfrom
fix/pnpm-electron-builder-packaging
May 18, 2026
Merged

fix: declare ms + debug as direct deps to unblock packaged auto-updater#66
aicayzer merged 1 commit into
mainfrom
fix/pnpm-electron-builder-packaging

Conversation

@aicayzer
Copy link
Copy Markdown
Owner

Summary

  • Promote debug and ms from transitive deps of electron-updater to direct dependencies in package.json so electron-builder reliably packages them.
  • Add nodeLinker: hoisted + shamefullyHoist: true in pnpm-workspace.yaml (pnpm 10+ ignores these in .npmrc).
  • Document the workaround in electron-builder.yml.

Why

electron-builder has a known dep-walker bug (electron-userland/electron-builder#9654) where, on a pnpm project, its asar packaging drops transitives of bundled packages even when node_modules is hoisted flat. The result: node_modules/ms/package.json exists 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:

Uncaught Exception: Error: Cannot find module 'ms'
Require stack:
- .../app.asar/node_modules/debug/src/common.js
- .../app.asar/node_modules/debug/src/node.js
- .../app.asar/node_modules/debug/src/index.js
- .../app.asar/node_modules/builder-util-runtime/out/httpExecutor.js
- .../app.asar/node_modules/builder-util-runtime/out/index.js
- .../app.asar/node_modules/electron-updater/out/AppUpdater.js
- .../app.asar/node_modules/electron-updater/out/BaseUpdater.js
- .../app.asar/node_modules/electron-updater/out/main.js
- .../app.asar/out/main/index.js

The bug has been latent on main since #47 (the auto-updater wiring) merged 90 seconds after v0.2.1 was tagged. No shipped release has exercised the electron-updater import 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.yml points future maintainers at the upstream issue so the workaround can be removed once it's fixed.

Test plan

  • pnpm typecheck clean
  • pnpm lint clean
  • pnpm test — 84 tests pass
  • pnpm build:mac succeeds
  • npx asar list dist/mac-arm64/SuperWhisper\ Analytics.app/Contents/Resources/app.asar includes /node_modules/ms/package.json
  • Built .app launches without the Cannot find module 'ms' exception (main process plus renderer/GPU/network helpers all spawn)
  • After merge: tag v0.3.0, watch CI release workflow, install the resulting signed + notarised .dmg, confirm clean launch and "Check for updates" returns up-to-date

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.
@aicayzer aicayzer merged commit 7ed0b38 into main May 18, 2026
3 checks passed
@aicayzer aicayzer deleted the fix/pnpm-electron-builder-packaging branch May 18, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant