diff --git a/docs/swc.md b/docs/swc.md index 2554f9d..2b49512 100644 --- a/docs/swc.md +++ b/docs/swc.md @@ -1,6 +1,15 @@ -swc rule +API for running SWC under Bazel + +Simplest usage: + +```starlark +load("@aspect_rules_swc//swc:swc.bzl", "swc") + +swc(name = "transpile") +``` + @@ -12,8 +21,10 @@ swc_rule(name, args, < Underlying rule for the `swc` macro. - Use this if you need more control over how the rule is called, - for example to set your own output labels for `js_outs`. +Most users should just use [swc](#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`. **ATTRIBUTES** @@ -23,8 +34,8 @@ Underlying rule for the `swc` macro. | 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 labels | optional | | -| map_outs | - | List of labels | optional | | +| js_outs | list of expected JavaScript output files | List of labels | optional | | +| map_outs | list of expected source map output files | List of labels | optional | | | output_dir | whether to produce a directory output rather than individual files | Boolean | 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 | diff --git a/examples/rc/src/BUILD.bazel b/examples/rc/src/BUILD.bazel index 7600b6d..69f76e7 100644 --- a/examples/rc/src/BUILD.bazel +++ b/examples/rc/src/BUILD.bazel @@ -21,4 +21,4 @@ diff_test( name = "test_map", file1 = "in.js.map", file2 = "expected.js.map", -) \ No newline at end of file +) diff --git a/examples/rc/src/expected.js b/examples/rc/src/expected.js index a92fc70..0fdabf8 100644 --- a/examples/rc/src/expected.js +++ b/examples/rc/src/expected.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.a = void 0; -const a = 'foo'; +const a = "foo"; exports.a = a; diff --git a/examples/rc/src/expected.js.map b/examples/rc/src/expected.js.map index d4d1d5e..49df85b 100644 --- a/examples/rc/src/expected.js.map +++ b/examples/rc/src/expected.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../../../../../examples/rc/src/in.ts"],"names":[],"mappings":";;;;;AAAO,KAAK,CAAC,CAAC,GAAW,CAAK;QAAjB,CAAC,GAAD,CAAC","file":"in.js","sourcesContent":["export const a: string = 'foo'\n"]} \ No newline at end of file +{"version":3,"sources":["../../../../../../examples/rc/src/in.ts"],"names":[],"mappings":";;;;;AAAO,KAAK,CAAC,CAAC,GAAW,CAAK;QAAjB,CAAC,GAAD,CAAC","file":"in.js","sourcesContent":["export const a: string = \"foo\";\n"]} \ No newline at end of file diff --git a/examples/rc/src/in.ts b/examples/rc/src/in.ts index 0dce35a..7064c3e 100644 --- a/examples/rc/src/in.ts +++ b/examples/rc/src/in.ts @@ -1 +1 @@ -export const a: string = 'foo' +export const a: string = "foo"; diff --git a/swc/private/swc.bzl b/swc/private/swc.bzl index b11dc78..a8aa847 100644 --- a/swc/private/swc.bzl +++ b/swc/private/swc.bzl @@ -17,8 +17,8 @@ _attrs = { } _outputs = { - "js_outs": attr.output_list(), - "map_outs": attr.output_list(), + "js_outs": attr.output_list(doc = "list of expected JavaScript output files"), + "map_outs": attr.output_list(doc = "list of expected source map output files"), } def _impl(ctx): diff --git a/swc/swc.bzl b/swc/swc.bzl index 31b05c8..07c815b 100644 --- a/swc/swc.bzl +++ b/swc/swc.bzl @@ -1,4 +1,13 @@ -"swc rule" +"""API for running SWC under Bazel + +Simplest usage: + +```starlark +load("@aspect_rules_swc//swc:swc.bzl", "swc") + +swc(name = "transpile") +``` +""" load("//swc/private:swc.bzl", _swc_lib = "swc") load("@bazel_skylib//lib:paths.bzl", "paths") @@ -6,8 +15,10 @@ load("@bazel_skylib//lib:paths.bzl", "paths") swc_rule = rule( doc = """Underlying rule for the `swc` macro. - Use this if you need more control over how the rule is called, - for example to set your own output labels for `js_outs`.""", +Most users should just use [swc](#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`.""", implementation = _swc_lib.implementation, attrs = _swc_lib.attrs, toolchains = _swc_lib.toolchains,