feat: add phase 6 js_library and ts_library bootstrap
This commit is contained in:
committed by
copilot-swe-agent[bot]
parent
a4f6b55d43
commit
8463e94e00
40
internal/js_library.bzl
Normal file
40
internal/js_library.bzl
Normal file
@@ -0,0 +1,40 @@
|
||||
"""Lightweight JS/TS source grouping rules."""
|
||||
|
||||
BunSourcesInfo = provider(fields = ["transitive_sources"])
|
||||
|
||||
|
||||
def _bun_library_impl(ctx):
|
||||
transitive_sources = [
|
||||
dep[BunSourcesInfo].transitive_sources
|
||||
for dep in ctx.attr.deps
|
||||
if BunSourcesInfo in dep
|
||||
]
|
||||
all_sources = depset(
|
||||
direct = ctx.files.srcs,
|
||||
transitive = transitive_sources,
|
||||
)
|
||||
return [
|
||||
BunSourcesInfo(transitive_sources = all_sources),
|
||||
DefaultInfo(files = all_sources),
|
||||
]
|
||||
|
||||
|
||||
js_library = rule(
|
||||
implementation = _bun_library_impl,
|
||||
attrs = {
|
||||
"srcs": attr.label_list(
|
||||
allow_files = [".js", ".jsx", ".mjs", ".cjs"],
|
||||
),
|
||||
"deps": attr.label_list(),
|
||||
},
|
||||
)
|
||||
|
||||
ts_library = rule(
|
||||
implementation = _bun_library_impl,
|
||||
attrs = {
|
||||
"srcs": attr.label_list(
|
||||
allow_files = [".ts", ".tsx"],
|
||||
),
|
||||
"deps": attr.label_list(),
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user