Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions workspaces/arborist/lib/arborist/build-ideal-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,15 @@ module.exports = cls => class IdealTreeBuilder extends cls {
for (const edge of node.edgesOut.values()) {
children.push(edge.to)
}
// An unlinked workspace is unreachable from the root, so walk into what it has installed; walking the workspace itself would queue it ahead of the root, bypassing the workspaces filter.
if (node === tree.target && node.workspaces) {
for (const path of node.workspaces.values()) {
const ws = node.inventory.get(relpath(node.realpath, path))
for (const { to } of ws?.edgesOut.values() ?? []) {
children.push(to)
}
}
}
return children
},
filter: node => node,
Expand Down
21 changes: 21 additions & 0 deletions workspaces/arborist/test/arborist/build-ideal-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -2312,6 +2312,27 @@ t.test('peer dep that needs to be replaced', async t => {
t.matchSnapshot(await printIdeal(path))
})

t.test('no lockfile or root node_modules, but packages installed under a workspace', async t => {
const path = t.testdir({
'package.json': JSON.stringify({ name: 'root', workspaces: ['packages/a'] }),
packages: {
a: {
'package.json': JSON.stringify({ name: 'a', version: '1.0.0', dependencies: { foo: '1.0.0' } }),
node_modules: {
foo: {
'package.json': JSON.stringify({ name: 'foo', version: '1.0.0', dependencies: { baz: '1.0.0' } }),
},
},
},
},
})
const registry = createRegistry(t, false)
const bazPackuments = registry.packuments(['1.0.0'], 'baz')
await registry.package({ manifest: registry.manifest({ name: 'baz', packuments: bazPackuments }) })
const tree = await buildIdeal(path)
t.equal(tree.children.get('baz')?.version, '1.0.0', 'dep of the package under the workspace is added')
})

t.test('transitive conflicted peer dependency', async t => {
// see test/fixtures/testing-transitive-conflicted-peer/README.md
// for a thorough explanation.
Expand Down