You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix!: refuse to pack when overrides apply to bundled packages
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.
// Only refuse when an override rule actually applies to a package that is bundled by the root.
24
+
// Overrides targeting dev dependencies or any package outside the bundled tree are harmless to consumers, because consumers do not apply the publishing package's overrides.
25
+
// We rely on Arborist's own semantics (inBundle/inDepBundle/overridden) rather than reimplementing what npm-packlist/arborist already knows.
26
+
constarb=newArborist({path: spec.fetchSpec})
27
+
consttree=awaitarb.loadActual()
28
+
constoffenders=newSet()
29
+
for(constnodeoftree.inventory.values()){
30
+
if(node.isRoot){
31
+
continue
32
+
}
33
+
// Only packages bundled by the root are at risk: nested dep-bundles are published as-is and arborist already treats them as immune to the root's overrides (see Edge#satisfiedBy).
34
+
if(!node.inBundle||node.inDepBundle){
35
+
continue
36
+
}
37
+
if(node.overridden){
38
+
offenders.add(node.name)
39
+
}
40
+
}
41
+
if(offenders.size){
42
+
constnames=[...offenders].sort()
43
+
constlist=names.join(', ')
44
+
constisOne=names.length===1
45
+
throwObject.assign(
46
+
newError(`Cannot pack or publish: "overrides" ${isOne ? 'affects a bundled package' : 'affect bundled packages'} (${list}). Consumers do not apply your package's overrides, so the published bundle will produce invalid dependency edges. Remove ${isOne ? 'this package' : 'these packages'} from "bundledDependencies"/"bundleDependencies" or from "overrides" before publishing.`),
0 commit comments