API for running SWC under Bazel
Simplest usage:
load("@aspect_rules_swc//swc:swc.bzl", "swc")
swc(name = "transpile")
swc_transpiler(name, args, data, js_outs, map_outs, output_dir, source_maps, srcs, swc_cli, swcrc)
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.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
args | additional arguments to pass to swc cli, see https://swc.rs/docs/usage/cli | List of strings | optional | [] |
data | runtime dependencies propagated to binaries that depend on this | List of labels | optional | [] |
js_outs | list of expected JavaScript output files. There must be one for each entry in srcs, and in the same order. |
List of labels | optional | |
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. |
List of labels | optional | |
output_dir | whether to produce a directory output rather than individual files | Boolean | optional | False |
source_maps | see https://swc.rs/docs/usage/cli#--source-maps--s | String | optional | "false" |
srcs | source files, typically .ts files in the source tree | List of labels | required | |
swc_cli | binary that executes the swc CLI | Label | optional | @aspect_rules_swc//swc:cli |
swcrc | label of a configuration file for swc, see https://swc.rs/docs/configuration/swcrc | Label | optional | None |
swc(name, srcs, args, data, output_dir, swcrc, source_maps, kwargs)
Execute the swc compiler
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | A name for the target | none |
srcs | source files, typically .ts files in the source tree | None |
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 | False |
swcrc | label of a configuration file for swc, see https://swc.rs/docs/configuration/swcrc | None |
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. | False |
kwargs | additional named parameters like tags or visibility | none |