Skip to content

Conversation

@dzbarsky
Copy link
Contributor

The providers the rule is using were deleted (I believe in bazel-contrib/rules_nodejs#3655).
It seems the community has standardized on https://github.com/aspect-build/rules_js as the future.

I removed the JS dependency from the bzl_lib as well, I didn't see an easy way to pull in the bzl_lib from providers, but please let me know if I missed something.

cd examples && bazel test //wasm/... works for me with this branch.

@dzbarsky
Copy link
Contributor Author

@UebelAndre @illicitonion I saw you messing with this previously in #1311, could you review?

@dzbarsky dzbarsky force-pushed the main branch 3 times, most recently from 479e07a to 568ecd7 Compare August 19, 2023 19:25
@dzbarsky
Copy link
Contributor Author

I see there is one CI job failing but I'm not sure what's up with the RBE ubuntu16 config, any ideas?

Copy link
Collaborator

@UebelAndre UebelAndre left a comment

Choose a reason for hiding this comment

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

Hi! Sorry for the delay in the review, thanks so much for putting this together! Do you know if it'd be possible to maintain both? I thought the wasm_bindgen rules only relied on the core rules_nodejs repo which is stated to be in use within rules_js.

@dzbarsky
Copy link
Contributor Author

dzbarsky commented Sep 4, 2023

rules_js only uses rules_nodejs to define the hermetic node toolchain. The JSInfo providers have changed and live in rules_js. From the rules_nodejs README: "This ruleset provides a NodeJS development toolchain and runtime with Bazel. It does not have any rules for using NodeJS, such as nodejs_binary. For that, we recommend rules_js."

Concretely, here is the current state of the world:

So if you want to use a newish nodejs version, you need to load your own (newer) rules_nodejs, which breaks wasm_bindgen unless you apply patches to rules_rust (basically what I submitted here).

It seems our options are:

  1. Do nothing, stay with current state. This prioritizes projects that are using the deprecated JS rules, others can apply a patch like this one.
  2. Apply this patch. This prioritizes projects using the non-deprecated JS rules, legacy users can apply the reverse of this patch.

Personally I think (2) is better, especially because projects that are not upgrading their rulesets probably won't upgrade this one either. I'm also happy to continue carrying this patch locally (I have other rules_rust patches anyway), but I figured this would help the majority of users who are using bazel for JS.

Re: supporting both, since the issue here is a load of an undefined symbol, I'm not aware of a way to handle/recover that failure in Starlark, do you have any ideas? Failing that, I don't think it's feasible to support both.`

Copy link
Collaborator

@UebelAndre UebelAndre left a comment

Choose a reason for hiding this comment

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

Just one question 😄

)

load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories")
load("@bazel_features//:deps.bzl", "bazel_features_deps")
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is this? The repo seems to come out of nowhere. Is it required to use aspect_rules_js?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tl;dr This is a bit of a wart, yes.

The package we load the JsInfo provider from depends on that repo to define a config setting: https://github.com/aspect-build/rules_js/blob/63862adcfb565b0a53fb45c60dded0f8a7893c49/js/BUILD.bazel#L3C1-L15 This seems designed to support multiple Bazel versions so hopefully it can go away at some point. That repo also has a small usability trick - it automatically calls bazel_features_deps if you use npm_translate_lock, and since the vast majority of JS projects use npm packages, they don't have to do anything special here.

I do agree it's a bit weird to have to pull this in just to use the provider, @alexeagle perhaps you can consider rearranging the layout to make the providers more standalone?

Copy link
Contributor Author

@dzbarsky dzbarsky Sep 16, 2023

Choose a reason for hiding this comment

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

@UebelAndre What do you think? (BTW once we are using bzlmod I think this wouldn't be necessary)

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, yeah I see why this is undesirable. We had to make those part of the public API in aspect-build/rules_js#1187 - but maybe rules_rust can load() the providers without having to load that package? providers.bzl is in its own file for this reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is the //docs:docs_deps rule in this repo. The bzl_library requires depending on "@aspect_rules_js//js:providers" to satisfy the stardoc rules/lint, which means anything loaded in //js:BUILD is a dependency. I think if you moved the providers.bzl to its own package (say //js/providers/defs.bzl) it would work.

Copy link
Contributor

Choose a reason for hiding this comment

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

The bzl_library here can just depend on the bzl file directly in srcs to avoid that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I'm following the suggestion, do you mean like so?

bzl_library(
    name = "docs_deps",
    srcs = [
        "@aspect_rules_js//js:providers.bzl",
        "@bazel_tools//tools:bzl_srcs",
        "@com_google_protobuf//:bzl_srcs",
    ],
   deps = [...]
)

That hits visibility issues: https://github.com/aspect-build/rules_js/blob/main/js/BUILD.bazel#L6-L9
Even ignoring visibility, it will have a problem with missing the js_info bzl

com.google.devtools.build.skydoc.SkydocMain$StarlarkEvaluationException: File /private/var/tmp/_bazel_zbarsky/e27223f43abb18db045469720c4d6593/sandbox/darwin-sandbox/28/execroot/rules_rust_docs/bazel-out/darwin-opt-exec-2B5CBBC6/bin/rust_repositories_md_stardoc.runfiles/aspect_rules_js/js/providers.bzl imported '//js/private:js_info.bzl', yet /private/var/tmp/_bazel_zbarsky/e27223f43abb18db045469720c4d6593/sandbox/darwin-sandbox/28/execroot/rules_rust_docs/bazel-out/darwin-opt-exec-2B5CBBC6/bin/rust_repositories_md_stardoc.runfiles/aspect_rules_js/js/private/js_info.bzl was not found.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@UebelAndre ping? What can I do to get this PR moving?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I’ll try to make time this weekend to do another pass. Sorry for the delay!

@dzbarsky dzbarsky requested a review from UebelAndre September 7, 2023 00:41
@dzbarsky dzbarsky requested a review from alexeagle September 18, 2023 04:10
@UebelAndre
Copy link
Collaborator

I have not forgotten about this change. I have uses of these rules that are still reliant on rules_nodejs and this would be a breaking change to projects that are unfortunately extremely hard to migrate. I feel a good path forward is to separate the rust_wasm_bindgen rules from any external implementation of javascript bazel rules. Maybe it'd be good to have subdirectories in //wasm_bindgen for rules_js and rules_nodejs that provide the interface to each ruleset. If I can find the time I will incorporate these changes into something like this. Admittedly my behavior here is something I strongly dislike where a single maintainer prevents community progress. For that I apologize. https://github.com/UebelAndre/rules_rust/tree/wasm/wasm_bindgen is the branch I'd be using to make these changes in case it provides any insights. If the code paths for raw wasm-bindgen, rules_js, and rules_nodejs were independent then I think there would be absolutely no hesitation to accept any change to the rules_js section as I understand that to be an active community.

@dzbarsky
Copy link
Contributor Author

I have not forgotten about this change

No problem, thanks for the heads up! The approach you're taking in the branch seems reasonable to me

@UebelAndre
Copy link
Collaborator

Closing in favor of #2284

@UebelAndre UebelAndre closed this Nov 27, 2023
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.

3 participants