Skip to content

Commit

Permalink
refactor: rename transpile to compile in most places
Browse files Browse the repository at this point in the history
matches the rename of swc_compile rule
  • Loading branch information
alexeagle committed Jan 7, 2023
1 parent 744e00c commit 5fedde5
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions e2e/workspace/BUILD
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@aspect_rules_swc//swc:defs.bzl", "swc")

swc(name = "transpile")
swc(name = "compile")

build_test(
name = "test",
targets = [":transpile"],
targets = [":compile"],
)
2 changes: 1 addition & 1 deletion examples/custom_outs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ load("@bazel_skylib//rules:write_file.bzl", "write_file")

[
swc_compile(
name = "transpile_" + format,
name = "compile_" + format,
srcs = ["a.ts"],
# The extension of the outputs can be modified using js_outs
js_outs = [format + "/a." + ("cjs" if format == "commonjs" else "js")],
Expand Down
8 changes: 4 additions & 4 deletions examples/filegroup/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ filegroup(
)

swc(
name = "transpile",
name = "compile",
srcs = ["srcs"],
source_maps = "true",
swcrc = ".swcrc",
)

# Since the srcs were in a filegroup, the swc macro cannot pre-declare the outputs.
# So there is no label ":a.js" that we can reference from the build file.
# However, a.js is still produced as one of the default outputs of the transpile rule.
# We can verify this in an action that depends on the ":transpile" rule and reads the files.
# However, a.js is still produced as one of the default outputs of the compile rule.
# We can verify this in an action that depends on the ":compile" rule and reads the files.
sh_test(
name = "check_outputs",
srcs = ["check_outputs.sh"],
data = [":transpile"],
data = [":compile"],
)
6 changes: 3 additions & 3 deletions examples/opaque_src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ filegroup(

# In this case we pass a target containing sources so the swc macro can't pre-declare the .js output targets
swc(
name = "transpile",
name = "compile",
srcs = [":opaque_src"],
)

# But we can extract the opaque outputs using output_files to make a friendly label for the output .js file (used below)
output_files(
name = "in.js",
paths = ["%s/in.js" % package_name()],
target = ":transpile",
target = ":compile",
)

# Assert that the output of "transpile" rule matches the expected file.
# Assert that this predeclared output of "compile" rule matches the expected file.
write_source_files(
name = "test",
files = {"expected.js": ":in.js"},
Expand Down
8 changes: 4 additions & 4 deletions examples/out_dir/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@aspect_rules_swc//swc:defs.bzl", "swc")
load("@aspect_bazel_lib//lib:testing.bzl", "assert_outputs")

swc(
name = "transpile",
name = "compile",
srcs = [
"a.ts",
"b.ts",
Expand All @@ -13,11 +13,11 @@ swc(

# Since the srcs were in a filegroup, the swc macro cannot pre-declare the outputs.
# So there is no label ":a.js" that we can reference from the build file.
# However, a.js is still produced as one of the default outputs of the transpile rule.
# We can verify this in an action that depends on the ":transpile" rule and reads the files.
# However, a.js is still produced as one of the default outputs of the compile rule.
# We can verify this in an action that depends on the ":compile" rule and reads the files.
assert_outputs(
name = "check_outputs",
actual = "transpile",
actual = "compile",
expected = [
"examples/out_dir/out/a.js",
"examples/out_dir/out/a.js.map",
Expand Down
2 changes: 1 addition & 1 deletion examples/paths/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@aspect_rules_swc//swc:defs.bzl", "swc")

swc(
name = "transpile",
name = "compile",
swcrc = ".swcrc",
)

Expand Down
4 changes: 2 additions & 2 deletions examples/rc/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@aspect_rules_swc//swc:defs.bzl", "swc")

# Runs `swc in.ts > ../../bazel-bin/examples/simple/in.js`
# You can run `bazel build --subcommands //examples/simple:transpile`
# You can run `bazel build --subcommands //examples/simple:compile`
# to see the exact command line Bazel runs.
# Note that by default, sources are found by glob(["**/*.ts"])
swc(
name = "transpile",
name = "compile",
source_maps = True,
swcrc = "//examples/rc:.swcrc",
)
Expand Down
8 changes: 4 additions & 4 deletions examples/root_dir/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@aspect_rules_swc//swc:defs.bzl", "swc")
load("@aspect_bazel_lib//lib:testing.bzl", "assert_outputs")

swc(
name = "transpile",
name = "compile",
srcs = [
"src/a.ts",
"src/b.ts",
Expand All @@ -14,11 +14,11 @@ swc(

# Since the srcs were in a filegroup, the swc macro cannot pre-declare the outputs.
# So there is no label ":a.js" that we can reference from the build file.
# However, a.js is still produced as one of the default outputs of the transpile rule.
# We can verify this in an action that depends on the ":transpile" rule and reads the files.
# However, a.js is still produced as one of the default outputs of the compile rule.
# We can verify this in an action that depends on the ":compile" rule and reads the files.
assert_outputs(
name = "check_outputs",
actual = "transpile",
actual = "compile",
expected = [
"examples/root_dir/out/a.js",
"examples/root_dir/out/a.js.map",
Expand Down
8 changes: 4 additions & 4 deletions examples/simple/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@aspect_rules_swc//swc:defs.bzl", "swc")

# Runs `swc in.ts > ../../bazel-bin/examples/simple/in.js`
# You can run `bazel build --subcommands //examples/simple:transpile`
# You can run `bazel build --subcommands //examples/simple:compile`
# to see the exact command line Bazel runs.
# Note that by default, sources are found by glob(["**/*.ts"])
swc(name = "transpile")
swc(name = "compile")

# Assert that the output of "transpile" rule matches the expected file.
# Assert that the output of "compile" rule matches the expected file.
write_source_files(
name = "test",
# This is a pre-declared output of the "transpile" rule, so we can refer to it directly using a Bazel label
# This is a pre-declared output of the "compile" rule, so we can refer to it directly using a Bazel label
# even though the file itself is generated by Bazel in ../../bazel-bin/examples/simple/in.js
files = {"expected.js": ":in.js"},
)
2 changes: 1 addition & 1 deletion examples/transitive/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Test transitive dependencies between typescript files
which are transpiled separately as "libraries" but which
which are compiled separately as "libraries" but which
have runtime dependencies.
"""

Expand Down

0 comments on commit 5fedde5

Please sign in to comment.