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

fix: allow root repositories to override esbuild toolchain version under bzlmod #164

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

satajo
Copy link
Contributor

@satajo satajo commented Nov 19, 2023

Fixes the problem where overriding the default esbuild version in MODULE.bazel results in the error Multiple conflicting toolchains declared for name esbuild.

The solution is an adapted copy of @kormide's fix to a similar problem under rules_nodejs.

@satajo
Copy link
Contributor Author

satajo commented Nov 19, 2023

For context, I ran into this issue by wanting to use css-modules with esbuild. After some confusion about why the class name substitutions did not work in the bundled output, it turned out that esbuild was defaulting to version 0.16.7 which does not support css-modules.

Attempting a simple version override with the following configuration resulted in the error about conflicting toolchain names.

bazel_dep(
    name = "aspect_rules_esbuild",
    version = "0.15.3",
)

esbuild = use_extension("@aspect_rules_esbuild//esbuild:extensions.bzl", "esbuild")

esbuild.toolchain(name = "esbuild", esbuild_version = "0.19.2")

Defining a toolchain with some other name than "esbuild" did work, but I was not able to figure out how to actually use the alternative toolchain with the esbuild rule. I did not check whether override using WORKSPACE syntax would have worked because I am trying to stick with MODULE.bazel usage if possible.

After finding out about the similar issue regarding rules_nodejs, the fix seemed simple enough and now the override definition above works, as do my css-modules.

Copy link
Member

@alexeagle alexeagle left a comment

Choose a reason for hiding this comment

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

thanks!

@alexeagle alexeagle merged commit fe7efca into aspect-build:main Nov 20, 2023
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants