Conversation
The npm-packlist v10 upgrade in pnpm 11 changed its API to require the caller to pre-populate the dependency tree's edgesOut Map. Our wrapper passed an empty Map, causing gatherBundles() to silently skip every bundled dep. Populate edgesOut from bundleDependencies / bundledDependencies (plus transitive deps for nested bundled packages, walking up parent node_modules to find hoisted deps), and normalize bundleDependencies: true to an explicit array since npm-packlist iterates it directly.
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
📝 WalkthroughWalkthroughThis PR fixes ChangesBundle Dependencies Fix
Possibly related issues
Possibly related PRs
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
Fixes a pnpm 11 regression where pnpm pack stopped including dependencies declared via bundleDependencies/bundledDependencies by rebuilding the dependency tree data (edgesOut) required by npm-packlist v10.
Changes:
- Build a dependency-tree structure in
@pnpm/fs.packlistthat pre-populatesedgesOutfor bundled deps (including transitives) and normalizesbundleDependenciesto an iterable value. - Add pack tests covering bundling of direct and transitive bundled dependencies under a hoisted layout.
- Add a changeset to release the fix as a patch for
@pnpm/fs.packlistandpnpm.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
fs/packlist/src/index.ts |
Builds/populates the npm-packlist tree so bundled deps are discoverable and included in pack output. |
releasing/commands/test/publish/pack.ts |
Adds regression tests ensuring bundled deps (and transitives) are included in produced tarballs. |
.changeset/pack-bundle-dependencies.md |
Declares patch releases for the fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address Copilot review comment on #11524: add a test that verifies a package with bundleDependencies: true bundles its declared dependencies and excludes other entries in node_modules.
Replace the isProjectRoot boolean parameter with two dedicated entry points: buildRootTree applies the project-root specifics (read bundleDependencies/bundledDependencies, normalize the manifest field that npm-packlist iterates), and buildBundledTree handles nested bundled deps (their own dependencies + optionalDependencies). Edge population is shared via populateEdges, node creation via makeNode, and the dep-name selection split into getRootBundledDeps / getNestedBundledDeps.
The tree-building loop is sequential by design (the shared `seen` map deduplication relies on it), so async fs adds Promise overhead and no-await-in-loop lint suppressions for no benefit. Switch the internal helpers to fs.readFileSync / fs.statSync; only the public packlist() remains async because npm-packlist itself is async.
- Fixes [#11519](#11519): `pnpm pack` in pnpm 11 silently dropped every package listed in `bundleDependencies` / `bundledDependencies`, producing tarballs that no longer contained the bundled `node_modules/<dep>` files that v10 produced. - Root cause: the npm-packlist v10 upgrade ([#10658](#10658)) changed its API to require the caller to pre-populate the dependency tree's `edgesOut` Map. The wrapper in `fs/packlist` passed an empty Map, so npm-packlist's `gatherBundles()` looked up each declared name, found nothing, and skipped them all. - Fix: `fs/packlist` now reads each bundled dep's `package.json` (walking up parent `node_modules` to support hoisted layouts), recursively populates `edgesOut` for transitive deps of bundled packages, and normalizes `bundleDependencies: true` to an explicit array (npm-packlist iterates the field directly).
Summary
pnpm packin pnpm 11 silently dropped every package listed inbundleDependencies/bundledDependencies, producing tarballs that no longer contained the bundlednode_modules/<dep>files that v10 produced.edgesOutMap. The wrapper infs/packlistpassed an empty Map, so npm-packlist'sgatherBundles()looked up each declared name, found nothing, and skipped them all.fs/packlistnow reads each bundled dep'spackage.json(walking up parentnode_modulesto support hoisted layouts), recursively populatesedgesOutfor transitive deps of bundled packages, and normalizesbundleDependencies: trueto an explicit array (npm-packlist iterates the field directly).Test plan
pack: bundles dependencies listed in bundleDependenciestest inreleasing/commands/test/publish/pack.ts— verifies a declared dep is included and an undeclared dep is excluded.pack: bundles transitive dependencies of bundled dependencies (hoisted)test — verifies transitive bundling under a hoisted layout.releasing/commands/test/publish/pack.tscontinue to pass.pnpm/dist/pnpm.mjs: a fixture matching the issue's reproduction now shipsnode_modules/foo/foo.jsandnode_modules/foo/package.jsonin the tarball, matching v10 behavior.Written by an agent (Claude Code, claude-opus-4-7).
Summary by CodeRabbit
Bug Fixes
Tests