[FR]: provide select constraints for optional dependencies that define specific platforms #714
Labels
enhancement
New feature or request
funding needed
Contribute to https://opencollective.com/aspect-build
What is the current behavior?
Currently when an NPM package contains optional dependencies, and
npm_translate_lock
hasno_optional = False
, all of the optional dependencies of a package are added without constraints to the deps attribute of the rerespectivenpm_package_store_internal
for the desired package.In the case of nextjs, for example, it means that all of these optional dependencies will be added to the deps. This results in all of the various platform binaries for @next/swc being installed on the user's machine.
Describe the feature
I am looking for something similar to this pnpm PR for rules_js: pnpm/pnpm#3672
In short, I'd expect that all optional dependencies that provide a platform constraint, have the constraint mapped into a proper bazel select when adding the dependencies to the store target. We should be able to achieve this using the pnpm-lock file, as seen on this example swc-linux package: https://github.com/aspect-build/bazel-examples/blob/ec19825e711ef2d1db68352ed8b152cad65cd257/next.js/pnpm-lock.yaml#L268-L275
The end goal is that the build stage would only depend on dependencies that match the allowed host, which would result in fewer unneeded binaries from being installed when using packages like nextjs.
I can provide more information if necessary.
Fund our work
The text was updated successfully, but these errors were encountered: