aspect-build / rules_js

High-performance Bazel rules for running Node.js tools and building JavaScript projects
https://docs.aspect.build/rules/aspect_rules_js
Apache License 2.0
299 stars 103 forks source link

[Bug]: lifecycle_hooks_exclude does not work with pnpm.neverBuiltDependencies #1913

Open scttdavs opened 1 week ago

scttdavs commented 1 week ago

What happened?

I think this could be considered a feature request, but given what I needed to do to work around it, it feels more like a bug, or maybe missed requirement.

When using lifecycle_hooks_exclude with npm_translate_lock, it gets converted to the equivalent lifecycle_hooks definition under the hood. That's nice, but with pnpm v9, I now need to add pnpm.onlyBuiltDependencies. However, since this is an allow list, I now need to add every other package that has install scripts, even when I just want to exclude a few.

Pnpm has a nicer alternative when you just want to exclude and that's pnpm.neverBuiltDependencies. Rules_js doesn't check for this though, and still enforces you add onlyBuiltDependencies, which now requires us to maintain an ongoing allow list of all packages with install scripts, just so we can exclude a few.

Version

Development (host) and target OS/architectures:

Output of bazel --version: 6.5

Version of the Aspect rules, or other relevant rules from your WORKSPACE or MODULE.bazel file: WORKSPACE

Language(s) and/or frameworks involved: JavaScript

How to reproduce

Create a JavaScript project with pnpm v9 or higher, add a package to `lifecycle_hooks_exclude` and add `pnpm.neverBuiltDependencies` with the same packages. Rules_js fails saying you must use `pnpm.onlyBuiltDependencies`.

Any other information?

No response

jbedard commented 1 week ago

The problem is that pnpm 9+ no longer specifies what packages require a build, the requiresBuild attribute was removed.

So I think pnpm.neverBuiltDependencies is useless when we don't know which packages require a build in the first place.