-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accepts JS sources in
prerender_component()
and a js_library()
as…
… a scripts dependency. This chooses to generate either a `ts_library()` or `js_library()` based on the sources provided to `prerender_component()`. Whatever is given, is re-exported via `js_reexport()` which propagates both `JSModuleInfo` and `JSEcmaScriptModuleInfo`. This needs to be custom because `js_library()` only returns `JSModuleInfo` while `ts_library()` returns both, but a `js_library()` that depends on a `ts_library()` will drop its dependency's `JSEcmaScriptModuleInfo`, meaning there is no clean way of re-exporting a target which may be a `js_library()` or a `ts_library()`.
- Loading branch information
Showing
9 changed files
with
213 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"""Utilities based around file paths.""" | ||
|
||
def is_js_file(src): | ||
"""Returns whether or not the given src path is a JavaScript file.""" | ||
return src.endswith(".js") or src.endswith(".mjs") or src.endswith(".cjs") |
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,22 @@ | ||
"""Tests for `paths.bzl`.""" | ||
|
||
load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest") | ||
load(":paths.bzl", "is_js_file") | ||
|
||
def _is_js_file_impl(ctx): | ||
env = unittest.begin(ctx) | ||
|
||
asserts.equals(env, True, is_js_file("foo/bar/baz.js")) | ||
asserts.equals(env, True, is_js_file("foo/bar/baz.mjs")) | ||
asserts.equals(env, True, is_js_file("foo/bar/baz.cjs")) | ||
|
||
asserts.equals(env, False, is_js_file("foo/bar/baz.ts")) | ||
asserts.equals(env, False, is_js_file("foo/bar/baz.d.ts")) | ||
asserts.equals(env, False, is_js_file("foo/bar/baz.test")) | ||
|
||
return unittest.end(env) | ||
|
||
_is_js_file_test = unittest.make(_is_js_file_impl) | ||
|
||
def paths_test_suite(name): | ||
unittest.suite(name, _is_js_file_test) |
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
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