From bc2afb15c0f22bf5b2e81917ad1194d36e949755 Mon Sep 17 00:00:00 2001 From: Jeff Widman Date: Wed, 14 Oct 2026 22:15:20 -0700 Subject: [PATCH] fix(arborist): skip bundle checks without an applicable override Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- workspaces/arborist/lib/edge.js | 10 +++++----- workspaces/arborist/test/edge.js | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/workspaces/arborist/lib/edge.js b/workspaces/arborist/lib/edge.js index 1ed2446c8090a..b563e8ca4c38c 100644 --- a/workspaces/arborist/lib/edge.js +++ b/workspaces/arborist/lib/edge.js @@ -108,16 +108,16 @@ class Edge { return false } + // If there's no override we just use the spec. + if (!this.overrides?.keySpec) { + return depValid(node, this.spec, this.#accept, this.#from) + } + // NOTE: this condition means we explicitly do not support overriding // bundled dependencies if (node.inDepBundle) { return depValid(node, this.rawSpec, this.#accept, this.#from) } - - // If there's no override we just use the spec. - if (!this.overrides?.keySpec) { - return depValid(node, this.spec, this.#accept, this.#from) - } // There's some override. If the target node satisfies the overriding spec // then it's okay. if (depValid(node, this.spec, this.#accept, this.#from)) { diff --git a/workspaces/arborist/test/edge.js b/workspaces/arborist/test/edge.js index f5ea071553195..e950c363df131 100644 --- a/workspaces/arborist/test/edge.js +++ b/workspaces/arborist/test/edge.js @@ -1212,6 +1212,32 @@ t.test('edge with overrides should not crash when target has no overrides', t => t.end() }) +t.test('satisfiedBy does not check bundling without an applicable override', t => { + const Node = require('../lib/node.js') + for (const overrides of [undefined, new OverrideSet({ overrides: { other: '2.x' } })]) { + const from = new Node({ + path: '/root', + pkg: { name: 'root', dependencies: { child: '1.x' } }, + }) + const edge = from.edgesOut.get('child') + edge.overrides = overrides + for (const version of ['1.0.0', '2.0.0']) { + const candidate = new Node({ + path: '/child', + pkg: { name: 'child', version }, + }) + Object.defineProperty(candidate, 'inDepBundle', { + get: () => { + t.fail('bundling cannot affect an edge without an applicable override') + return false + }, + }) + t.equal(edge.satisfiedBy(candidate), version === '1.0.0') + } + } + t.end() +}) + t.test('overrides and bundled deps in satisfiedBy', t => { const makeNode = (name, version, extras = {}) => ({ name,