Skip to content

Commit

Permalink
fix: pnpm prune misses root dependency (vercel#3483)
Browse files Browse the repository at this point in the history
Fixes vercel#2798 which comprised of two issues:
- We eagerly checked if a version specifier was already resolved in the
package list. This can lead to grabbing a version of the package that
doesn't have the expected peer dependencies. This was as easy as moving
this check after we have gone down the happy path.
- Not copying internal dependencies of the monorepo root. We now
internally add `//` to the prune scope to make sure we get any internal
dependencies.

For reviewers: I highly recommend reviewing the first commit in this PR
initially as it unifies the pnpm lockfile implementations. I realized
that my code split was unnecessary and made fixing bugs for lockfile v5
and v6 very difficult.
  • Loading branch information
chris-olszewski authored Jan 30, 2023
1 parent b0aef82 commit 480ee44
Show file tree
Hide file tree
Showing 14 changed files with 299 additions and 295 deletions.
10 changes: 10 additions & 0 deletions cli/integration_tests/prune/includes_root_deps.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Setup
$ . ${TESTDIR}/../setup.sh
$ . ${TESTDIR}/setup.sh $(pwd)

Make sure that the internal util package is part of the prune output
$ ${TURBO} prune --scope=web
Generating pruned monorepo for web in .*/out (re)
- Added shared
- Added util
- Added web
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "docs",
"dependencies": {
"shared": "workspace:*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "web",
"dependencies": {
"shared": "workspace:*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "monorepo",
"packageManager": "[email protected]",
"devDependencies": {
"util": "workspace:*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "shared"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "util"
}
27 changes: 27 additions & 0 deletions cli/integration_tests/prune/monorepo_with_root_dep/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
packages:
- "apps/*"
- "packages/*"
4 changes: 4 additions & 0 deletions cli/integration_tests/prune/monorepo_with_root_dep/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {}
}
5 changes: 5 additions & 0 deletions cli/integration_tests/prune/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
TARGET_DIR=$1
cp -a ${SCRIPT_DIR}/monorepo_with_root_dep/. ${TARGET_DIR}/
Loading

0 comments on commit 480ee44

Please sign in to comment.