-
Notifications
You must be signed in to change notification settings - Fork 522
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
Ability to stop propagation of link_node_modules
aspect information
#2941
Comments
devversion
added a commit
to devversion/rules_nodejs
that referenced
this issue
Sep 15, 2021
…ules` aspect This commit does two things: 1. It switches the `link_node_modules` aspect from the deprecated struct provider variant to the provider list return value. 2. The aspect no longer collects aspect results from dependencies if the target already provides explicit mapping information for the linker. This is an API for advanced use-cases as outlined in bazel-contrib#2941.
devversion
added a commit
to devversion/rules_nodejs
that referenced
this issue
Sep 15, 2021
…ules` aspect This commit does two things: 1. It switches the `link_node_modules` aspect from the deprecated struct provider variant to the provider list return value. 2. The aspect no longer collects aspect results from dependencies if the target already provides explicit mapping information for the linker. This is an API for advanced use-cases as outlined in bazel-contrib#2941.
alexeagle
pushed a commit
that referenced
this issue
Sep 17, 2021
…ules` aspect This commit does two things: 1. It switches the `link_node_modules` aspect from the deprecated struct provider variant to the provider list return value. 2. The aspect no longer collects aspect results from dependencies if the target already provides explicit mapping information for the linker. This is an API for advanced use-cases as outlined in #2941.
fixed by #2947 |
thanks @alexeagle! 🎉 |
12 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
link_node_modules
aspect is currently used for capturing mappings that the linker can consume. The aspect is applied on the target relying on the linker (such as anodejs_test
). It would be beneficial to have an API that allows for a target to skip the module mapping collection. This is useful if a target applies an outgoing transition and therefore results in transitive dependencies being built under a different output directory (compared tobazel-out
).This is problematic because a test target for example cannot rely on the target applying the transition (e.g. a
pkg_npm
target), as well as on the non-transitioned original dependency (such as thets_library
used for the NPM package). e.g.As it can be observed above: There are two conflicting mappings because
core
dependency on thepkg_npm_wrapped
target is also considered as linker mapping for the test. This is unexpected and itwould be fixable if there was a way for the
pkg_npm_wrapped
/ng_package
rule to return an emptyset of mappings / or disable the propagation of the e.g.
deps
attribute. The mappings fromthe transitive dependencies are not desirable anyway because the NPM package is supposed to be the
mapping if at all.
Workaround tried:
I have tried working around it by manually setting the
link_node_modules__aspect_result
property on the NPM packagerule. e.g.
This does not work because the link_node_modules aspect does not check if the property is already set and Bazel will error because an already-existing "provider" is re-assigned. A solution would be to check for the presence in the aspect before. This will allow for advanced cases like described.
Ideally the
link_node_modules
aspect should not use the deprecated? struct approach for providers to begin with. Then it should check for the presence of the provider before trying to set it in the aspect (allowing for a solution like in the snippet above). This will allow for advanced use-cases. Alternatively, the aspect could look for an attribute on the target it visits. Though I like the idea of having manual control over mappings.I'm happy to send a PR. Might send a proposal tomorrow.
The text was updated successfully, but these errors were encountered: