Skip to content

Commit 123baaa

Browse files
committed
Enable devDependency pruning for Yarn 2
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.
1 parent 83aa0de commit 123baaa

19 files changed

+31
-10931
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
## main
44

5-
## v195 (2022-04-12)
5+
## v196 (2022-05-18)
6+
- Enable Yarn 2 `devDependency` pruning using a custom plugin for all customers ([#1001](https://github.com/heroku/heroku-buildpack-nodejs/pull/1001))
7+
8+
## v195 (2022-04-13)
69
- Enable Yarn 2 `devDependency` pruning using a custom plugin for 20% of customers ([#999](https://github.com/heroku/heroku-buildpack-nodejs/pull/999))
710
- Set xtrace mode in buildpack when BUILDPACK_XTRACE environment variable is set ([#925](https://github.com/heroku/heroku-buildpack-nodejs/pull/925))
811

buildpack.toml

+21-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,29 @@ name = "Node.js"
33

44
[publish.Ignore]
55
files = [
6-
".circle/",
6+
".circleci/",
77
".github/",
8+
".git2gus/",
89
"etc/",
910
"spec/",
1011
"test/",
11-
"makefile"
12+
"makefile",
13+
"Gemfile.lock",
14+
"Gemfile",
15+
"hatchet.json",
16+
"go.mod",
17+
"go.sum",
18+
"hatchet.lock",
19+
"cmd/",
20+
# TODO: get rid of these ignores once the yarn plugins are moved into a separate repo
21+
# for now we just need the compiled plugin in yarn2-plugin/prune-dev-dependencies/bundles
22+
"yarn2-plugins/prune-dev-dependencies/.editorconfig",
23+
"yarn2-plugins/prune-dev-dependencies/package-lock.json",
24+
"yarn2-plugins/prune-dev-dependencies/.gitignore",
25+
"yarn2-plugins/prune-dev-dependencies/package.json",
26+
"yarn2-plugins/prune-dev-dependencies/tsconfig.json",
27+
"yarn2-plugins/prune-dev-dependencies/README.md",
28+
"yarn2-plugins/prune-dev-dependencies/tests",
29+
"yarn2-plugins/prune-dev-dependencies/jest.config.js",
30+
"yarn2-plugins/prune-dev-dependencies/src",
1231
]

features

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
cache-native-yarn-cache=100
2-
use-heroku-yarn-prune-plugin=20

lib/dependencies.sh

+4-20
Original file line numberDiff line numberDiff line change
@@ -168,26 +168,10 @@ yarn_prune_devdependencies() {
168168
return 0
169169
elif $YARN_2; then
170170
cd "$build_dir" || return
171-
meta_set "use-heroku-yarn-prune-plugin" "$(features_get_with_blank "use-heroku-yarn-prune-plugin")"
172-
if [[ $(features_get_with_blank "use-heroku-yarn-prune-plugin") == "true" ]]; then
173-
echo "Running 'yarn heroku prune'"
174-
export YARN_PLUGINS="${buildpack_dir}/yarn2-plugins/prune-dev-dependencies/bundles/@yarnpkg/plugin-prune-dev-dependencies.js"
175-
monitor "yarn-prune" yarn heroku prune
176-
meta_set "workspace-plugin-present" "false"
177-
meta_set "skipped-prune" "false"
178-
elif has_yarn_workspace_plugin_installed "$build_dir"; then
179-
echo "Running 'yarn workspaces focus --all --production'"
180-
meta_set "workspace-plugin-present" "true"
181-
182-
# The cache is removed beforehand because the command is running an install on devDeps, and
183-
# it will not remove the existing dependencies beforehand.
184-
rm -rf "$cache_dir"
185-
monitor "yarn-prune" yarn workspaces focus --all --production
186-
meta_set "skipped-prune" "false"
187-
else
188-
meta_set "workspace-plugin-present" "false"
189-
echo "Skipping because the Yarn workspace plugin is not present. Add the plugin to your source code with 'yarn plugin import workspace-tools'."
190-
fi
171+
echo "Running 'yarn heroku prune'"
172+
export YARN_PLUGINS="${buildpack_dir}/yarn2-plugins/prune-dev-dependencies/bundles/@yarnpkg/plugin-prune-dev-dependencies.js"
173+
monitor "yarn-prune" yarn heroku prune
174+
meta_set "skipped-prune" "false"
191175
else
192176
cd "$build_dir" || return
193177
monitor "yarn-prune" yarn install --frozen-lockfile --ignore-engines --ignore-scripts --prefer-offline 2>&1

0 commit comments

Comments
 (0)