Skip to content

Preserve bundled npm dependencies in desktop artifacts - #3590

Merged
SawyerHood merged 1 commit into
mainfrom
bb/3566-fix-desktop-npm-bundling-thr_jr49kcavnh
Sep 12, 2026
Merged

SawyerHood merged 1 commit into
mainfrom
bb/3566-fix-desktop-npm-bundling-thr_jr49kcavnh

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Sep 12, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Desktop 0.43.0 ships npm 11.16.0 without its bundled dependencies. Electron-builder's pnpm collector treats npm as a leaf, and its dependency copier excludes nested node_modules. Source builds and the separate bb-app tarball smoke pass, while packaged npm exits 7 with missing proc-log and cannot install or update plugin dependencies.

What changed

Preserve npm's complete nested dependency tree through an explicit shared electron-builder file set, before signing. The same file-set approach was proposed in closed, unmerged #3587.

Gate native-host packaging in afterPack on an artifact smoke test, and repeat it in packaged desktop smoke. The test runs the shipped npm through bundled Electron with an empty PATH and isolated HOME/cache/config. It audits required CJS/ESM dependency resolution and version ranges, imports ESM dependencies, and performs an offline disposable plugin dependency install and update from 1.0.0 to 2.0.0. Lockfile contents and actual ESM imports verify both operations; resource hashes reject bundle mutations. Document standalone npm smoke and add Turbo prerequisites for local packaging.

No server/daemon wire or public SDK changes.

How you verified

  • On a MacBook Air, both a freshly downloaded signed macOS 0.43.0 release and current-main packaged output lacked 60/65 direct npm dependencies and exited 7 through their own Electron runtime with no executables on PATH.
  • Fixed real macOS arm64 packaging passes: all 65 direct dependencies, 144 packages including npm, and 348 required CJS/ESM dependency edges. Offline install/update succeeds and resources remain unchanged. An ad hoc signed disposable copy still passes strict codesign verification afterward.
  • Negative controls reject removal of the new file set during real packaging, a missing Chalk ESM implementation file, and a nested dependency omission that resolves an incompatible minipass version.
  • pnpm exec turbo run package --filter=@bb/desktop: passed, including the pre-signing npm gate.
  • pnpm exec turbo run typecheck test --filter=@bb/desktop: passed; 322 tests passed, 1 existing skip. The sandbox initially aborted the existing Electron preload test; the macOS-process-enabled rerun passed.
  • Formatting, git diff --check, and the public-content scan passed.
  • The reported self-repair was not reproduced on the shipped dependency-install path: two attempts failed, all 9,225 release bundle files remained unchanged, and strict codesign verification still passed.

Independent Linux verification on x86_64/glibc 2.44 at commit 1d1ec370a90d53d97dc76d5b3998368ecf8aba88:

  • A freshly downloaded official 0.43.0 AppImage reproduces 60/65 missing dependencies and exit 7 for both version and real offline dependency-install commands through bundled Electron with an empty PATH. A repeated install also fails without changing resource hashes; no self-repair was observed.
  • Real Turbo Linux packaging and the final extracted AppImage executable pass all 65 direct dependency, 144 package, and 348 CJS/ESM dependency-edge checks, including version ranges, offline install/update, and unchanged resources. Final AppImage SHA256: f17e6bf79d3a26b92b6ce26ad2825b81fb5541a1a3d361cc60188d2a3c31024d.
  • Extracted AppImage GUI preload smoke passes under disposable Xvfb; the official-release baseline passes too.
  • Both artifact negative controls fail as intended: missing Chalk ESM implementation and missing nested minipass dependencies with an incompatible fallback version.
  • Turbo typecheck passes; 322 desktop tests and 81 bb-app tests pass, with one existing desktop skip. No PR-caused defects or source changes were needed.

Limitations: Linux AppImage FUSE lifecycle testing is blocked identically before and after (exit 127; host lacks /dev/fuse and fusermount); extracted-artifact checks above pass. macOS packaged GUI readiness timed out on both before and after artifacts. Developer ID signing/notarization and full Extensions UI activation were not tested. The new runtime gate requires a native target host. All verification used disposable artifacts and fixtures; no installed production app or store was modified.

Fixes #3566
Fixes #3581
Fixes #3584

AGENT GENERATED

Copy npm's complete nested dependency tree before signing and gate packaging on artifact dependency/version resolution, ESM imports, and offline plugin dependency install/update through bundled Electron. Verify packaged resources remain unchanged.

The explicit file-set approach was also proposed in unmerged PR #3587. Covers reports #3566, #3581, and #3584.
@SawyerHood
SawyerHood marked this pull request as ready for review September 12, 2026 15:41
@SawyerHood
SawyerHood merged commit 9a68828 into main Sep 12, 2026
16 checks passed
@SawyerHood
SawyerHood deleted the bb/3566-fix-desktop-npm-bundling-thr_jr49kcavnh branch September 12, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant