aspect-build / rules_esbuild

Bazel rules for https://esbuild.github.io/ JS bundler
https://docs.aspect.build/rules/aspect_rules_esbuild
Apache License 2.0
27 stars 27 forks source link

[FR]: Should `output_dir` use `output` as the dir name rather than `name? #170

Open surma opened 9 months ago

surma commented 9 months ago

What is the current behavior?

It seems that if output_dir is true, a directory artifact is declared using the rule name as the folder name.

https://github.com/aspect-build/rules_esbuild/blob/cede902c94e2313a3ea183b6a5e1dbbbfcf40347/esbuild/private/esbuild.bzl#L255-L257

Describe the feature

I was surprised that when I defined output = "dist" with output_dir = True, that the rule would fail with “The following files have no generating action: .../dist". After digging into the code, it seems that name is used for the folder name. Is that intentional?

jbedard commented 6 months ago

I believe this is because the output attribute is a predeclared output file and can not be a directory.

Would an error message have helped if both output and output_dir are set? I think that would be harmless and maybe improve the DX. Want to open a PR adding that?