Skip to content

fix: bundle dependencies so npm installs the tested tree @W-24750342@ - #3013

Merged
WillieRuemmele merged 4 commits into
mainfrom
wr/bundleDependencies
Nov 3, 2026
Merged

WillieRuemmele merged 4 commits into
mainfrom
wr/bundleDependencies

Conversation

@WillieRuemmele

@WillieRuemmele WillieRuemmele commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Work Item

@W-24750342@

Summary

npm 12 (now npm@latest) no longer reads or writes npm-shrinkwrap.json, so npm install -g @salesforce/cli floats every transitive dependency and ignores our yarn resolutions. That breaks the guarantee that what we tested for two weeks in nightly/RC is what ships to latest. Today npm users get, for example, basic-ftp@5.3.1 (vulnerable to GHSA-c475-qrg2-pj4r) instead of the resolved 6.2.5, plus duplicate @opentelemetry/* copies.

This PR bundles every dependency (bundleDependencies), so the published tarball contains the exact node_modules tree that yarn installed and that we tested. npm installs bundled trees as-is and never re-resolves them.

Changes

  • Add an explicit bundleDependencies list containing every dependency. It isn't true, because yarn v1 crashes (TypeError: true is not iterable!) when installing a package that depends on one with bundleDependencies: true.
  • Remove prepublishOnly: npm shrinkwrap (npm 12 has no shrinkwrap command).

Files Changed

  • package.json
  • test/package.test.ts

Test Plan

  • npm pack (npm 12.2.1) from a full yarn install, dev deps included: 38.0 MB tarball (was ~112 KB) containing exactly the 830-package prod closure at the same paths and versions as yarn's tree, with no dev-only packages
  • npm i -g <tarball> on npm 12.2.1 and npm 11.21.1: identical tree, sf --version works, single basic-ftp@6.2.5, @opentelemetry/core@3.0.0, SDR and core, install about 22s
  • sf plugins install @salesforce/plugin-community (JIT) works on the bundled install
  • oclif pack:tarballs --targets darwin-arm64: installer node_modules is identical to one built from main (951 packages, 0 differences)
  • yarn v1 consumer yarn add <tarball> installs and runs
  • Prod closure scan: 0 os/cpu-restricted, 0 native addons, 0 missing optional deps (nothing platform-specific is baked into the bundle)
  • yarn test (76 passing) and yarn lint
  • Nightly publish and npm i -g @salesforce/cli@nightly smoke test on macOS, Linux and Windows

Notes / trade-offs

  • Bundled deps can't be patched by users with overrides or npm dedupe. Transitive CVE fixes ship through a CLI release (on npm 12 the shrinkwrap already didn't help here).
  • The tarball grows from ~112 KB to ~38 MB (unpacked ~188 MB, about the same as an unbundled install).
  • Follow-ups (separate PRs): yarn install --frozen-lockfile in the github-workflows publish job; JIT plugins.

npm 12 no longer reads or writes npm-shrinkwrap.json, so npm installs of
the CLI float every transitive dependency and ignore our yarn resolutions.
Bundle every dependency instead: the published tarball contains the exact
node_modules tree that was tested in nightly/rc.

Changes:
- add explicit bundleDependencies (all dependencies; not `true`, which
  breaks yarn v1 consumers)
- remove prepublishOnly npm shrinkwrap
- add a unit test that keeps bundleDependencies in sync with dependencies
@iowillhoit

Copy link
Copy Markdown
Contributor

ansis and @inquirer/select should be bundled too. The CLI imports them. It "still works" because they happen it get pulled in via other deps, but if those deps ever removed them from the dep tree, the import would fail

Should we add the test back that ensures all deps are also in the bundled list?

…4750342@

- fix @inquirer/select typo in bundleDependencies
- check every @salesforce/@oclif dependency is bundled and every bundled name is a dependency
@WillieRuemmele
WillieRuemmele merged commit 73803e3 into main Nov 3, 2026
38 checks passed
@WillieRuemmele
WillieRuemmele deleted the wr/bundleDependencies branch November 3, 2026 21:30
WillieRuemmele added a commit that referenced this pull request Nov 3, 2026
…#3013)

* fix: bundle dependencies so npm installs the tested tree @W-24750342@

npm 12 no longer reads or writes npm-shrinkwrap.json, so npm installs of
the CLI float every transitive dependency and ignore our yarn resolutions.
Bundle every dependency instead: the published tarball contains the exact
node_modules tree that was tested in nightly/rc.

Changes:
- add explicit bundleDependencies (all dependencies; not `true`, which
  breaks yarn v1 consumers)
- remove prepublishOnly npm shrinkwrap
- add a unit test that keeps bundleDependencies in sync with dependencies

* chore: manual changes

* chore: restore ansis/inquierer

* test: verify bundleDependencies covers our plugins and libraries @W-24750342@

- fix @inquirer/select typo in bundleDependencies
- check every @salesforce/@oclif dependency is bundled and every bundled name is a dependency
WillieRuemmele added a commit that referenced this pull request Nov 3, 2026
* chore(release): bump to 2.157.8

* fix: bundle dependencies so npm installs the tested tree @W-24750342@ (#3013)

* fix: bundle dependencies so npm installs the tested tree @W-24750342@

npm 12 no longer reads or writes npm-shrinkwrap.json, so npm installs of
the CLI float every transitive dependency and ignore our yarn resolutions.
Bundle every dependency instead: the published tarball contains the exact
node_modules tree that was tested in nightly/rc.

Changes:
- add explicit bundleDependencies (all dependencies; not `true`, which
  breaks yarn v1 consumers)
- remove prepublishOnly npm shrinkwrap
- add a unit test that keeps bundleDependencies in sync with dependencies

* chore: manual changes

* chore: restore ansis/inquierer

* test: verify bundleDependencies covers our plugins and libraries @W-24750342@

- fix @inquirer/select typo in bundleDependencies
- check every @salesforce/@oclif dependency is bundled and every bundled name is a dependency

---------

Co-authored-by: Willie Ruemmele <william.ruemmele@salesforce.com>
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.

2 participants