Skip to content

Commit 0b87f64

Browse files
authored
Configure Node CNB to skip pruning (#439)
* Configure Node CNB to skip pruning The Node.js CNB is often used by the Ruby CNB to handle asset compilation for Rails apps. A recent change to the Node.js CNB made it so that dev dependencies are pruned at the end of its build phase, but these dev dependencies are then needed when the Ruby CNB wants to do asset compilation. To support this use case, the Node.js CNB exposes a buildplan configuration that can control how some of these features work. This PR includes that required buildplan whenever Node.js tooling is required + modifies an integration test to verify that the configuration is working. * Update CHANGELOG.md Signed-off-by: Colin Casey <[email protected]> * Only include Node.js buildplan config if `yarn` is required. --------- Signed-off-by: Colin Casey <[email protected]>
1 parent fd29cad commit 0b87f64

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

buildpacks/ruby/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- When Node.js tooling is required, buildplan configuration is added to disable dev dependency pruning. ([#439](https://github.com/heroku/buildpacks-ruby/pull/439))
13+
1014
## [10.0.1] - 2025-06-09
1115

1216
### Fixed

buildpacks/ruby/src/main.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use fs_err::PathExt;
1111
use fun_run::CmdError;
1212
use layers::ruby_install_layer::RubyInstallError;
1313
use libcnb::build::{BuildContext, BuildResult, BuildResultBuilder};
14-
use libcnb::data::build_plan::BuildPlanBuilder;
14+
use libcnb::data::build_plan::{BuildPlanBuilder, Require};
1515
use libcnb::data::launch::LaunchBuilder;
1616
use libcnb::data::layer_name;
1717
use libcnb::detect::{DetectContext, DetectResult, DetectResultBuilder};
@@ -33,7 +33,7 @@ mod user_errors;
3333
use libcnb_test as _;
3434
#[cfg(test)]
3535
use pretty_assertions as _;
36-
36+
use toml::toml;
3737
use ureq as _;
3838

3939
use crate::target_id::OsDistribution;
@@ -90,6 +90,14 @@ impl Buildpack for RubyBuildpack {
9090
.map_err(RubyBuildpackError::BuildpackDetectionError)?
9191
{
9292
plan_builder = plan_builder.requires("yarn");
93+
94+
let mut node_configuration = Require::new("node_build_scripts");
95+
node_configuration.metadata = toml! {
96+
// This needs to be disabled so that dev dependencies are available for
97+
// Ruby apps that need to perform asset compilation.
98+
skip_pruning = true
99+
};
100+
plan_builder = plan_builder.requires(node_configuration);
93101
}
94102

95103
if fs_err::read_to_string(lockfile)

buildpacks/ruby/tests/integration_test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ fn test_ruby_app_with_yarn_app() {
374374
]),
375375
|context| {
376376
println!("{}", context.pack_stderr);
377+
assert_contains!(context.pack_stderr, "pruning was disabled by a participating buildpack");
377378
assert_contains!(context.pack_stderr, "# Heroku Ruby Buildpack");
378379
assert_contains!(
379380
context.pack_stderr,

0 commit comments

Comments
 (0)