-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support srcs with DefaultInfo producing .ts
For example, filegroup can now be used to yield the sources we pass to swc. Like with ts_project, this means we don't pre-declare outputs, since Bazel doesn't support that.
- Loading branch information
Showing
12 changed files
with
135 additions
and
47 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
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
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,25 @@ | ||
load("@aspect_rules_swc//swc:swc.bzl", "swc") | ||
|
||
filegroup( | ||
name = "srcs", | ||
srcs = [ | ||
"a.ts", | ||
"b.ts", | ||
], | ||
) | ||
|
||
swc( | ||
name = "transpile", | ||
srcs = ["srcs"], | ||
source_maps = "true", | ||
) | ||
|
||
# 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. | ||
sh_test( | ||
name = "check_outputs", | ||
srcs = ["check_outputs.sh"], | ||
data = [":transpile"], | ||
) |
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 = "a"; |
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 b: string = "b"; |
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,7 @@ | ||
#!/usr/bin/env bash | ||
set -o errexit | ||
|
||
cd "$TEST_SRCDIR/$TEST_WORKSPACE/$(dirname $TEST_TARGET)" | ||
grep "export var a" filegroup/a.js | ||
grep "sourceMappingURL=a.js.map" filegroup/a.js | ||
grep "../../../../../examples/filegroup/a.ts" filegroup/a.js.map |
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
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
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