Skip to content

Commit

Permalink
Migrates resources example to prerender_component2.
Browse files Browse the repository at this point in the history
Refs #40.
  • Loading branch information
dgp1130 committed Jul 22, 2023
1 parent ea3300a commit 5f0ba89
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 24 deletions.
24 changes: 13 additions & 11 deletions examples/resources/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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",
)
Expand All @@ -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(
Expand Down
20 changes: 13 additions & 7 deletions examples/resources/component/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
16 changes: 10 additions & 6 deletions examples/resources/transitive/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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(
Expand Down

0 comments on commit 5f0ba89

Please sign in to comment.