Open
Description
For a complete MRE of this issue including a VS Code devcontainer see: https://github.com/allsey87/aspect_rules_js_mre
This issue arises when a custom rule generate a single Javascript file that needs to be tested. For example, assume in the following BUILD file that custom_rule
with name output
returns a DefaultInfo
provider with a single file output.js
.
load("@aspect_rules_js//js:defs.bzl", "js_test")
load("//:custom_rule.bzl", "custom_rule")
custom_rule(
name = "output",
)
js_test(
name = "validate",
entry_point = "output.js",
data = [":output"],
timeout = "short",
)
If data is omitted, we get an error:
Copying file output.js failed: missing input file '//:output.js'
If data is provided, we get the error:
file 'output.js' is generated by these conflicting actions:
Label: //:output, //:validate
For now, the only workaround (that I know of) is to create a custom wrapper that launches output.js:
load("@aspect_rules_js//js:defs.bzl", "js_test")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("//:custom_rule.bzl", "custom_rule")
custom_rule(
name = "output",
)
write_file(
name = "wrapper",
out = "wrapper.js",
content = [
"require('./output.js')"
]
)
js_test(
name = "validate",
entry_point = "wrapper.js",
data = [":output"],
timeout = "short",
)