API for running SWC under Bazel
Simplest usage:
load("@aspect_rules_swc//swc:defs.bzl", "swc")
swc(name = "transpile")
Known issues:
- import statements improperly transformed when using symlinks: swc#4057
See https://github.com/aspect-build/rules_swc/issues/31.
You can add this to your
.bazelrc
to workaround by disabling sandboxing for SWC actions:build --modify_execution_info=SWCTranspile=+no-sandbox
Rules
swc_transpiler
Underlying rule for the swc
macro.
Most users should just use swc instead.
Use this if you need more control over how the rule is called,
for example to set your own output labels for js_outs
.
This rule is also suitable for the ts_project#transpiler attribute.
Example usage (generated)
load("@rules_swc//swc:defs.bzl", "swc_transpiler")
swc_transpiler(
# A unique name for this target.
name = "",
# source files, typically .ts files in the source tree
srcs = [],
)
name
A unique name for this target.
args
additional arguments to pass to swc cli, see https://swc.rs/docs/usage/cli
data
runtime dependencies propagated to binaries that depend on this
js_outs
list of expected JavaScript output files.
There must be one for each entry in srcs, and in the same order.
map_outs
list of expected source map output files.
Can be empty, meaning no source maps should be produced. If non-empty, there must be one for each entry in srcs, and in the same order.
out_dir
base directory for output files
output_dir
whether to produce a directory output rather than individual files
source_maps
srcs
source files, typically .ts files in the source tree
swc_cli
binary that executes the swc CLI
swcrc
label of a configuration file for swc, see https://swc.rs/docs/configuration/swcrc
Macros and Functions
swc
Execute the swc compiler
Example usage (generated)
load("@rules_swc//swc:defs.bzl", "swc")
swc(
# A name for the target
name = "",
)
name
A name for the target
srcs
source files, typically .ts files in the source tree
args
additional arguments to pass to swc cli, see https://swc.rs/docs/usage/cli
data
runtime dependencies to be propagated in the runfiles
output_dir
whether to produce a directory output rather than individual files
swcrc
label of a configuration file for swc, see https://swc.rs/docs/configuration/swcrc
source_maps
If set, the --source-maps argument is passed to the swc cli with the value. See https://swc.rs/docs/usage/cli#--source-maps--s True/False are automaticaly converted to "true"/"false" string values the cli expects.
out_dir
base directory for output files relative to the output directory for this package
kwargs
additional named parameters like tags or visibility