Skip to content

fix!: refuse to pack when overrides apply to bundled packages#9271

Merged
owlstronaut merged 1 commit intolatestfrom
fix-bundled-overrides-publish
Apr 28, 2026
Merged

fix!: refuse to pack when overrides apply to bundled packages#9271
owlstronaut merged 1 commit intolatestfrom
fix-bundled-overrides-publish

Conversation

@owlstronaut
Copy link
Copy Markdown
Contributor

@owlstronaut owlstronaut commented Apr 22, 2026

Follow up to #9235.

When a package defines overrides that apply to one or more of its bundledDependencies (or bundleDependencies), the resulting bundled tree is invalid from the perspective of any consumer: consumers do not apply the publishing package's overrides when validating the bundled tree, so npm ls will always show invalid edges for the affected bundled packages.

This PR refuses to pack (and therefore publish) such packages with a clear EBUNDLEOVERRIDE error that lists the offending bundled package names. Defining both overrides and bundledDependencies is still allowed — the error only fires when an override actually targets a package inside the bundled subtree. Cases that are now correctly accepted include:

  • overrides that target dev dependencies (which are not bundled),
  • overrides that target packages outside the bundled subtree, and
  • packages that bundle some deps but override only unrelated ones.

The check uses Arborist's own inBundle / inDepBundle / overridden semantics on the actual on-disk tree (the same tree pacote uses to build the tarball), so it stays consistent with what npm-packlist actually publishes.

The check lives in libnpmpack, so it covers npm pack, npm publish, and any direct consumers of the library.

Closes npm/statusboard#1102.

BREAKING CHANGE: npm pack and npm publish now error when a package's overrides apply to one or more of its bundled packages (bundledDependencies / bundleDependencies). Defining both fields is still allowed as long as no override actually targets a bundled package. To resolve the error, remove the affected entries from either overrides or the bundle.

@owlstronaut owlstronaut requested a review from a team as a code owner April 22, 2026 19:37
@wraithgar
Copy link
Copy Markdown
Member

What if we have overridden dev dependencies?
What if we only bundle some of our dependencies and none of them are overridden?

@owlstronaut
Copy link
Copy Markdown
Contributor Author

What if we have overridden dev dependencies? What if we only bundle some of our dependencies and none of them are overridden?

those are good points. I'll need to make this a little more flexible

@owlstronaut owlstronaut force-pushed the fix-bundled-overrides-publish branch from 8cf2689 to 700f297 Compare April 23, 2026 15:21
@owlstronaut owlstronaut changed the title fix!: refuse to pack with bundled dependencies AND overrides fix!: refuse to pack when overrides apply to bundled packages Apr 23, 2026
@owlstronaut owlstronaut force-pushed the fix-bundled-overrides-publish branch from 700f297 to f6981d5 Compare April 23, 2026 15:31
Comment thread workspaces/libnpmpack/lib/index.js Outdated
Comment thread workspaces/libnpmpack/lib/index.js Outdated
Comment thread workspaces/libnpmpack/lib/index.js
Comment thread workspaces/libnpmpack/lib/index.js Outdated
Comment thread workspaces/libnpmpack/lib/index.js Outdated
@owlstronaut owlstronaut force-pushed the fix-bundled-overrides-publish branch from f6981d5 to 649aaad Compare April 28, 2026 17:48
Comment thread workspaces/libnpmpack/lib/index.js Outdated
BREAKING CHANGE: npm pack and npm publish now error when a package's overrides apply to one or more of its bundled packages (bundledDependencies / bundleDependencies). Defining both fields is still allowed as long as no override actually targets a bundled package. To resolve the error, remove the affected entries from either overrides or the bundle.
@owlstronaut owlstronaut force-pushed the fix-bundled-overrides-publish branch from 649aaad to 4568721 Compare April 28, 2026 17:56
@owlstronaut owlstronaut merged commit b1965d6 into latest Apr 28, 2026
16 checks passed
@owlstronaut owlstronaut deleted the fix-bundled-overrides-publish branch April 28, 2026 17:59
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.

Refuse to publish package with bundled dependencies AND overrides

2 participants