Skip to content

Add flag to disable launch dependency on node_modules - #755

Open
ZephireNZ wants to merge 12 commits into
paketo-buildpacks:mainfrom
ZephireNZ:feature/disable-node-modules
Open

Add flag to disable launch dependency on node_modules#755
ZephireNZ wants to merge 12 commits into
paketo-buildpacks:mainfrom
ZephireNZ:feature/disable-node-modules

Conversation

@ZephireNZ

@ZephireNZ ZephireNZ commented Sep 6, 2025

Copy link
Copy Markdown

Summary

Adds a flag BP_NODE_LAUNCH_REQUIRES_MODULES to disable the launch dependncy on node_modules layer, which is not required for bundled applications (eg Nuxt).

Doing so means npm-install buildpack won't add setup-symlinks startup hook, which would otherwise fail if the folder was removed eg using source-removal.

Fixes #736

Use Cases

Enables significant reduction in ouput image size, in conjunction with paketo-buildpacks/source-removal. Refer to the error in above issue for what happens when you try to remove node_modules folder in the current state.

Example from app I was working on - 493MB down to just 20MB by removing the workspace node_modules folder.

Checklist

  • I have viewed, signed, and submitted the Contributor License Agreement.
  • I have linked issue(s) that this PR should close using keywords or the Github UI (See docs)
  • I have added an integration test, if necessary.
  • I have reviewed the styleguide for guidance on my code quality.
  • I'm happy with the commit history on this PR (I have rebased/squashed as needed).

@ZephireNZ
ZephireNZ requested a review from a team as a code owner September 6, 2025 00:51
@linux-foundation-easycla

linux-foundation-easycla Bot commented Sep 6, 2025

Copy link
Copy Markdown

CLA Signed

The committers listed above are authorized under a signed CLA.

@ZephireNZ
ZephireNZ requested a review from a team as a code owner April 4, 2026 23:50
Comment thread integration/init_test.go
suite("WithNodeModules", testNodeModules)

// nitro results in a a segfault on UBI builders using the extension for some reason...
if builder.BuilderName != "paketobuildpacks/builder-ubi8-buildpackless-base" && builder.BuilderName != "paketobuildpacks/ubi-9-builder-buildpackless" {

@ZephireNZ ZephireNZ Apr 5, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the life of me, I couldn't undestand why the UBI extension caused grief for nitro... Enabling all the debug flags I could find didn't help either 😅

@pacostas

Copy link
Copy Markdown
Member

Hello,
I think it would be more clear to exclude the exec.d from running by adding an env on npm-install. This is more clear on what an option does.

@pacostas

Copy link
Copy Markdown
Member

This solution does not handle the SBOM, practically the sbom is being generated from npm-install, and if later on you remove the node_modules the SBOM has the information of the removed node_modules, which practically should point to the node_modules under .output

@pacostas

Copy link
Copy Markdown
Member

Seems like general rule for the buildpacks, is that dependencies should be on a layer and not on the workspace. the node_modules under the .output are on the workspace. The ideal would be to have them on a layer, this is useful especially for caching.

@pacostas

Copy link
Copy Markdown
Member

In regards to testing, I think is not a good idea to include an application that is not being built correctly

@pacostas

Copy link
Copy Markdown
Member

@ZephireNZ Any updates on the suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to remove dependency on node_modules at runtime

2 participants