Skip to content

Commit

Permalink
Merge pull request #994 from heroku/revert/v193_yarn_dependency_pruning
Browse files Browse the repository at this point in the history
Revert changes introduced in #990
  • Loading branch information
colincasey authored Mar 30, 2022
2 parents f0175ef + 52cf70c commit 66aa7b0
Show file tree
Hide file tree
Showing 17 changed files with 6 additions and 10,970 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## main

## v194 (2022-03-30)
- Revert fix for pruning yarn 2 cache due to an edge case that would cause all devDependencies to be installed ([#990](https://github.com/heroku/heroku-buildpack-nodejs/pull/990))

## v193 (2022-03-28)
- Added Yarn 1.22.18 to `inventory/yarn.toml` ([#992](https://github.com/heroku/heroku-buildpack-nodejs/pull/992))
- Fix issue with pruning yarn 2 cache when using the workspaces plugin ([#990](https://github.com/heroku/heroku-buildpack-nodejs/pull/990))
Expand Down
21 changes: 3 additions & 18 deletions lib/dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,10 @@ yarn_prune_devdependencies() {
echo "Running 'yarn workspaces focus --all --production'"
meta_set "workspace-plugin-present" "true"

# The cache is removed beforehand because the command is running an install on devDeps, and
# it will not remove the existing dependencies beforehand.
rm -rf "$cache_dir"
monitor "yarn-prune" yarn workspaces focus --all --production
yarn_prune_devdependencies_for_each_workspace "$build_dir"
meta_set "skipped-prune" "false"
else
meta_set "workspace-plugin-present" "false"
Expand All @@ -187,23 +189,6 @@ yarn_prune_devdependencies() {
fi
}

# removing all devDependencies this way *should* work but it would be nice if yarn supported
# devDependency pruning like npm does when running `npm install --production`
yarn_prune_devdependencies_for_each_workspace() {
local build_dir=${1:-}
local workspace_list=$(yarn workspaces list --json)
while IFS= read -r workspace; do
local name=$(echo "${workspace}" | jq -r '.name')
local location=$(echo "${workspace}" | jq -r '.location')
local devDependencies=$(cat "${build_dir}/${location}/package.json" | jq -r '.devDependencies | try keys | join(" ")')
if [ "${location}" == "." ]; then
monitor "yarn-prune" yarn remove ${devDependencies}
else
monitor "yarn-prune" yarn workspace "${name}" remove ${devDependencies}
fi
done <<< "${workspace_list}"
}

has_npm_lock() {
local build_dir=${1:-}

Expand Down
Loading

0 comments on commit 66aa7b0

Please sign in to comment.