I'm trying to compile my TS files to JS with SWC in Bazel. I'm unfortunately unable to use the rules_js library (which has rules_swc), so I need to hand roll it. So far I have:
load("@npm//@swc/cli:index.bzl", "swc")
SRC_FILES = glob(["**/*.ts"])
swc(
name = "compile_ts",
outs = [s.replace(".ts", ".js") for s in SRC_FILES],
args = [
"$(location %s)" % s
for s in SRC_FILES
],
data = SRC_FILES,
)
I get
Successfully compiled 96 files with swc.
but no output and the following error
ERROR: output {file} was not created
for each src file I passed in. How do I get the compiled files to output to the bazel-out folder so they can be used as inputs to other rules?
You can use Bazel's
--output_basestartup option to override the default output base directory. For example,bazel --output_base=/tmp/bazel/output build x/y:zPlease refer the Bazel open source doc for output-directories.