Skip to content

Commit

Permalink
Enable devDependency pruning for Yarn 2
Browse files Browse the repository at this point in the history
After monitoring the custom Yarn 2 plugin for a period of time there doesn't seem to be any issues from the 20% of builds that it has been active on.  This PR enables this feature completely and removes the old code path that used to handle pruning for Yarn 2.
  • Loading branch information
colincasey committed May 18, 2022
1 parent 83aa0de commit 123baaa
Show file tree
Hide file tree
Showing 19 changed files with 31 additions and 10,931 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

## main

## v195 (2022-04-12)
## v196 (2022-05-18)
- Enable Yarn 2 `devDependency` pruning using a custom plugin for all customers ([#1001](https://github.com/heroku/heroku-buildpack-nodejs/pull/1001))

## v195 (2022-04-13)
- Enable Yarn 2 `devDependency` pruning using a custom plugin for 20% of customers ([#999](https://github.com/heroku/heroku-buildpack-nodejs/pull/999))
- Set xtrace mode in buildpack when BUILDPACK_XTRACE environment variable is set ([#925](https://github.com/heroku/heroku-buildpack-nodejs/pull/925))

Expand Down
23 changes: 21 additions & 2 deletions buildpack.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,29 @@ name = "Node.js"

[publish.Ignore]
files = [
".circle/",
".circleci/",
".github/",
".git2gus/",
"etc/",
"spec/",
"test/",
"makefile"
"makefile",
"Gemfile.lock",
"Gemfile",
"hatchet.json",
"go.mod",
"go.sum",
"hatchet.lock",
"cmd/",
# TODO: get rid of these ignores once the yarn plugins are moved into a separate repo
# for now we just need the compiled plugin in yarn2-plugin/prune-dev-dependencies/bundles
"yarn2-plugins/prune-dev-dependencies/.editorconfig",
"yarn2-plugins/prune-dev-dependencies/package-lock.json",
"yarn2-plugins/prune-dev-dependencies/.gitignore",
"yarn2-plugins/prune-dev-dependencies/package.json",
"yarn2-plugins/prune-dev-dependencies/tsconfig.json",
"yarn2-plugins/prune-dev-dependencies/README.md",
"yarn2-plugins/prune-dev-dependencies/tests",
"yarn2-plugins/prune-dev-dependencies/jest.config.js",
"yarn2-plugins/prune-dev-dependencies/src",
]
1 change: 0 additions & 1 deletion features
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
cache-native-yarn-cache=100
use-heroku-yarn-prune-plugin=20
24 changes: 4 additions & 20 deletions lib/dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,26 +168,10 @@ yarn_prune_devdependencies() {
return 0
elif $YARN_2; then
cd "$build_dir" || return
meta_set "use-heroku-yarn-prune-plugin" "$(features_get_with_blank "use-heroku-yarn-prune-plugin")"
if [[ $(features_get_with_blank "use-heroku-yarn-prune-plugin") == "true" ]]; then
echo "Running 'yarn heroku prune'"
export YARN_PLUGINS="${buildpack_dir}/yarn2-plugins/prune-dev-dependencies/bundles/@yarnpkg/plugin-prune-dev-dependencies.js"
monitor "yarn-prune" yarn heroku prune
meta_set "workspace-plugin-present" "false"
meta_set "skipped-prune" "false"
elif has_yarn_workspace_plugin_installed "$build_dir"; then
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
meta_set "skipped-prune" "false"
else
meta_set "workspace-plugin-present" "false"
echo "Skipping because the Yarn workspace plugin is not present. Add the plugin to your source code with 'yarn plugin import workspace-tools'."
fi
echo "Running 'yarn heroku prune'"
export YARN_PLUGINS="${buildpack_dir}/yarn2-plugins/prune-dev-dependencies/bundles/@yarnpkg/plugin-prune-dev-dependencies.js"
monitor "yarn-prune" yarn heroku prune
meta_set "skipped-prune" "false"
else
cd "$build_dir" || return
monitor "yarn-prune" yarn install --frozen-lockfile --ignore-engines --ignore-scripts --prefer-offline 2>&1
Expand Down
Loading

0 comments on commit 123baaa

Please sign in to comment.