diff --git a/examples/resources/BUILD.bazel b/examples/resources/BUILD.bazel index dd21bbf1..00814685 100644 --- a/examples/resources/BUILD.bazel +++ b/examples/resources/BUILD.bazel @@ -1,7 +1,7 @@ load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin") load( "//:index.bzl", - "prerender_pages", + prerender_pages = "prerender_pages2", "web_resources", "web_resources_devserver", ) @@ -15,21 +15,23 @@ copy_to_bin( prerender_pages( name = "site", - src = "site.tsx", - tsconfig = "//:tsconfig", - source_map = True, + entry_point = "./site.js", + prerender = ":prerender", + bundle_js = False, # Optimization: No client-side JavaScript on this site. + resources = ":resources", +) + +ts_project( + name = "prerender", + srcs = ["site.tsx"], # Need `"type": "module"` to load `*.js` files output by `*.tsx` compilation. data = [":package"], - bundle_js = False, # Optimization: No client-side JavaScript on this site. - resources = [":resources"], - lib_deps = [ + deps = [ + "//examples/resources/component:component_prerender", + "//examples/resources/transitive:transitive_prerender", "//:node_modules/@rules_prerender/preact", "//:node_modules/preact", ], - deps = [ - "//examples/resources/component", - "//examples/resources/transitive", - ], ) web_resources( diff --git a/examples/resources/component/BUILD.bazel b/examples/resources/component/BUILD.bazel index 101bacbb..4359af15 100644 --- a/examples/resources/component/BUILD.bazel +++ b/examples/resources/component/BUILD.bazel @@ -1,15 +1,21 @@ load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin") -load("//:index.bzl", "prerender_component", "web_resources") +load("//:index.bzl", prerender_component = "prerender_component2", "web_resources") +load("//tools/typescript:defs.bzl", "ts_project") prerender_component( name = "component", - srcs = ["component.tsx"], - tsconfig = "//:tsconfig", - source_map = True, - resources = [":resources"], + prerender = ":prerender", + resources = ":resources", visibility = ["//examples/resources:__subpackages__"], - lib_deps = ["//:node_modules/preact"], - deps = ["//examples/resources/transitive"], +) + +ts_project( + name = "prerender", + srcs = ["component.tsx"], + deps = [ + "//:node_modules/preact", + "//examples/resources/transitive:transitive_prerender", + ], ) web_resources( diff --git a/examples/resources/transitive/BUILD.bazel b/examples/resources/transitive/BUILD.bazel index 52ee3393..f0913bcb 100644 --- a/examples/resources/transitive/BUILD.bazel +++ b/examples/resources/transitive/BUILD.bazel @@ -1,13 +1,17 @@ -load("//:index.bzl", "prerender_component", "web_resources") +load("//:index.bzl", prerender_component = "prerender_component2", "web_resources") +load("//tools/typescript:defs.bzl", "ts_project") prerender_component( name = "transitive", - srcs = ["transitive.tsx"], - tsconfig = "//:tsconfig", - source_map = True, - resources = [":resources"], + prerender = ":prerender", + resources = ":resources", visibility = ["//examples/resources:__subpackages__"], - lib_deps = ["//:node_modules/preact"], +) + +ts_project( + name = "prerender", + srcs = ["transitive.tsx"], + deps = ["//:node_modules/preact"], ) web_resources(