Skip to content
Draft
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

- Fix pnpm workspace detection. ([#1528](https://github.com/heroku/heroku-buildpack-nodejs/pull/1528))

## [v323] - 2026-01-09

Expand Down
24 changes: 23 additions & 1 deletion lib/dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ pnpm_prune_devdependencies() {
echo "Skipping because PNPM_SKIP_PRUNING is '$PNPM_SKIP_PRUNING'"
build_data::set_raw "skipped_prune" "true"
return 0
elif [ -f "$build_dir/pnpm-workspace.yaml" ] || [ -f "$build_dir/pnpm-workspace.yml" ]; then
elif [[ "$(pnpm_workspace_configured "$build_dir")" == "true" ]]; then
echo "Skipping because pruning is not supported for pnpm workspaces (https://pnpm.io/cli/prune)"
build_data::set_raw "skipped_prune" "true"
return 0
Expand Down Expand Up @@ -385,3 +385,25 @@ pnpm_prune_devdependencies() {

build_data::set_raw "skipped_prune" "false"
}

pnpm_workspace_configured() {
local build_dir=${1:-}
local workspace_file="$build_dir/pnpm-workspace.yaml"
local yq
local result

yq="$BP_DIR/lib/vendor/yq-$(get_os)"

if [[ -f "$workspace_file" ]]; then
# prior to pnpm 10.5.0, the `packages` key was mandatory, but now, you can store
# other pnpm-related config settings in `pnpm-workspace.yaml`.
result=$($yq r "$workspace_file" 'packages' 2>&1)

if [[ -n "$result" && "$result" != "null" ]]; then
echo "true"
return
fi
fi

echo "false"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "pnpm-workspace-file-exists-but-not-configured-as-workspace",
"version": "1.0.0",
"packageManager": "[email protected]+sha512.11106a5916c7406fe4b8cb8e3067974b8728f47308a4f5ac5e850304afa6f57e2847d7950dfe78877d8d36bfb401d381c4215db3a4c3547ffa63c14333a6fa51",
"engines": {
"node": "20.x"
},
"devDependencies": {
"dotenv": "^17.2.3"
}
}

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,2 @@
# just a random config setting that shouldn't affect anything, the important thing is there's no `packages` field
peersSuffixMaxLength: 1001
7 changes: 7 additions & 0 deletions test/run
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,13 @@ testPnpmWorkspaceBinaries() {
assertCapturedSuccess
}

testPnpmWorkspaceFileExistsButNotConfiguredAsWorkspace() {
compile "pnpm-workspace-file-exists-but-not-configured-as-workspace"
assertCaptured "+ dotenv"
assertCaptured "- dotenv"
assertCapturedSuccess
}

testWarningNode_22_5_0() {
compile "node-22.5.0-warning"
assertCaptured "Issues with Node.js v22.5.0"
Expand Down