-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle opaque targets in swc srcs (#110)
- Loading branch information
1 parent
daae45d
commit edc6421
Showing
9 changed files
with
90 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ var a = "a"; | |
exports.a = a; | ||
|
||
|
||
//# sourceMappingURL=out.cjs.map | ||
//# sourceMappingURL=a.cjs.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Simple use case for swc: transpiling TypeScript using the `swc` rule | ||
Note that this example also depends on the setup in /WORKSPACE at the root of this repository. | ||
""" | ||
|
||
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files") | ||
load("@aspect_bazel_lib//lib:output_files.bzl", "output_files") | ||
load("@aspect_rules_swc//swc:defs.bzl", "swc") | ||
|
||
filegroup( | ||
name = "opaque_src", | ||
srcs = ["in.ts"], | ||
) | ||
|
||
# In this case we pass a target containing sources so the swc macro can't pre-declare the .js output targets | ||
swc( | ||
name = "transpile", | ||
srcs = [":opaque_src"], | ||
) | ||
|
||
# But we can extract the opaque outputs using output_files to make a friendly label for the output .js file | ||
output_files( | ||
name = "in.js", | ||
paths = ["%s/in.js" % package_name()], | ||
target = ":transpile", | ||
) | ||
|
||
# Assert that the output of "transpile" 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 | ||
# even though the file itself is generated by Bazel in ../../bazel-bin/examples/simple/in.js | ||
files = {"expected.js": ":in.js"}, | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const a: string = "simple"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters