diff --git a/packages/rules_prerender/css/css_group.bzl b/packages/rules_prerender/css/css_group.bzl index d4f0673b..c97c1e1f 100644 --- a/packages/rules_prerender/css/css_group.bzl +++ b/packages/rules_prerender/css/css_group.bzl @@ -1,6 +1,6 @@ """Defines `css_group()` to group multiple `css_library()` targets like `filegroup()`.""" -load(":css_providers.bzl", "CssImportMapInfo") +load(":css_providers.bzl", "CssImportMapInfo", "CssInfo") visibility(["//packages/rules_prerender/..."]) @@ -10,22 +10,37 @@ def _css_group_impl(ctx): files = depset([], transitive = [dep[DefaultInfo].files for dep in ctx.attr.deps]), ), + CssInfo( + direct_sources = depset([]), + transitive_sources = depset( + direct = [], + transitive = [dep[CssInfo].transitive_sources + for dep in ctx.attr.deps + if CssInfo in dep], + ), + ), CssImportMapInfo( - import_map = _merge_import_maps([dep[CssImportMapInfo] - for dep in ctx.attr.deps - if CssImportMapInfo in dep]), + import_map = merge_import_maps([dep[CssImportMapInfo] + for dep in ctx.attr.deps + if CssImportMapInfo in dep]), ), ] css_group = rule( implementation = _css_group_impl, attrs = { - "deps": attr.label_list(mandatory = True), + "deps": attr.label_list( + mandatory = True, + providers = [CssInfo, CssImportMapInfo], + ), }, - doc = "Like a `filegroup()`, but for `css_library()` targets.", + doc = """ + Merges `CssInfo` and `CssImportMapInfo` providers from multiple targets. + Like a `filegroup()`, but for `css_library()` targets. + """, ) -def _merge_import_maps(css_import_maps): +def merge_import_maps(css_import_maps): """Merges a list of `CssImportMapInfo` into a single `CssImportMapInfo`. Fails the build if the same import path appears as a key in two maps. diff --git a/packages/rules_prerender/link_prerender_component.bzl b/packages/rules_prerender/link_prerender_component.bzl index 9cc29e67..a97be5c9 100644 --- a/packages/rules_prerender/link_prerender_component.bzl +++ b/packages/rules_prerender/link_prerender_component.bzl @@ -1,4 +1,5 @@ load("@aspect_rules_js//js:providers.bzl", "JsInfo") +load("//packages/rules_prerender/css:css_group.bzl", "css_group") load("//tools/typescript:defs.bzl", "ts_project") load("//packages/rules_prerender:web_resources.bzl", "WebResourceInfo") @@ -57,11 +58,11 @@ def link_prerender_component(name, package, visibility = None, testonly = None): testonly = testonly, ) - native.filegroup( + css_group( name = "%s_styles" % name, - srcs = [], # Empty. visibility = visibility, testonly = testonly, + deps = [], # Empty for now, styles aren't supported. ) _empty_web_resources( diff --git a/tools/binaries/css_bundler/css_bundle.bzl b/tools/binaries/css_bundler/css_bundle.bzl index 3d7c5205..b709eb3f 100644 --- a/tools/binaries/css_bundler/css_bundle.bzl +++ b/tools/binaries/css_bundler/css_bundle.bzl @@ -35,6 +35,10 @@ def _css_bundle_impl(ctx): return [ DefaultInfo(files = depset(outputs)), + CssInfo( + direct_sources = depset(outputs), + transitive_sources = depset(outputs), + ), CssImportMapInfo(import_map = _make_import_map(ctx, sources, outputs)), ]