Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR]: provide select constraints for optional dependencies that define specific platforms #714

Open
1 task
qtica opened this issue Dec 14, 2022 · 3 comments
Labels
enhancement New feature or request funding needed Contribute to https://opencollective.com/aspect-build

Comments

@qtica
Copy link

qtica commented Dec 14, 2022

What is the current behavior?

Currently when an NPM package contains optional dependencies, and npm_translate_lock has no_optional = False, all of the optional dependencies of a package are added without constraints to the deps attribute of the rerespective npm_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

@qtica qtica added the enhancement New feature or request label Dec 14, 2022
@gregmagolan
Copy link
Member

gregmagolan commented Jan 13, 2023

For reference, there is some discussion on this feature and how to implement it in Bazel Slack here https://bazelbuild.slack.com/archives/CEZUUKQ6P/p1670931838633139

@gregmagolan gregmagolan moved this to 📋 Backlog in Open Source Feb 4, 2023
@SinimaWath
Copy link
Contributor

Would be greate to have some solution or idea to solution. Bumped in same issue

@gregmagolan
Copy link
Member

Related to evanw/esbuild#789

@gregmagolan gregmagolan added the funding needed Contribute to https://opencollective.com/aspect-build label Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request funding needed Contribute to https://opencollective.com/aspect-build
Projects
Status: 📋 Backlog
Development

No branches or pull requests

3 participants