Skip to content

Commit

Permalink
Renames prerender_multi_page_bundled() -> prerender_pages().
Browse files Browse the repository at this point in the history
This is a simpler name which doesn't beg the question of "Where is `prerender_page_bundled()`?" and draws users to prefer it to the soon-to-be-renamed `prerender_pages_unbundled()`.
  • Loading branch information
dgp1130 committed Apr 8, 2021
1 parent 73bdbc9 commit c414b05
Show file tree
Hide file tree
Showing 24 changed files with 60 additions and 63 deletions.
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ bzl_library(
"//packages/rules_prerender:inject_resources",
"//packages/rules_prerender:prerender_component",
"//packages/rules_prerender:prerender_multi_page",
"//packages/rules_prerender:prerender_multi_page_bundled",
"//packages/rules_prerender:prerender_pages",
"//packages/rules_prerender:web_resources",
"//packages/rules_prerender:web_resources_devserver",
],
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export default function* render(): Generator<PrerenderResource, void, void> {

load(
"@npm//rules_prerender:index.bzl",
"prerender_multi_page_bundled",
"prerender_pages",
"web_resources_devserver",
)

Expand All @@ -220,7 +220,7 @@ load(
# /fonts/roboto.woff - The Robot font used in `my_component`.
# ... - Possibly other resources from `my_other_component` and transitive
# dependencies.
prerender_multi_page_bundled(
prerender_pages(
name = "prerendered_page",
# Script to invoke the default export of to generate the page.
src = "my_page_prerender.ts",
Expand All @@ -240,9 +240,9 @@ The page is built into a `web_resources()` rule which is a directory that
contains its HTML, JavaScript, CSS, and other resources from all the
transitively included components at their expected paths.

Multiple `prerender_multi_page_bundled()` directories can then be composed
together into a single `web_resources()` rule which contains a final directory
of everything merged together, representing an entire prerendered web site.
Multiple `prerender_pages()` directories can then be composed together into a
single `web_resources()` rule which contains a final directory of everything
merged together, representing an entire prerendered web site.

This final directory can be served with a simple devserver for local builds or
uploaded directly to a CDN for production deployments.
Expand All @@ -257,8 +257,8 @@ load(
)

# Combines all the prerendered resources into a single directory, composing a
# site from a bunch of `prerender_multi_page_bundled()` and `web_resources()`
# rules. Just upload this to a CDN for production builds!
# site from a bunch of `prerender_pages()` and `web_resources()` rules. Just
# upload this to a CDN for production builds!
web_resources(
name = "my_site",
deps = [
Expand Down Expand Up @@ -322,13 +322,13 @@ We can easily execute this at build time like so:

load(
"@npm//rules_prerender:index.bzl",
"prerender_multi_page_bundled",
"prerender_pages",
"web_resources_devserver",
)

# Renders a page for every `posts/*.md` file. Also performs all the bundling and
# merging of required JS, CSS, and other resources.
prerender_multi_page_bundled(
prerender_pages(
name = "prerendered_posts",
# Script to invoke the default export of to generate the page.
src = "posts_prerender.ts",
Expand Down
4 changes: 2 additions & 2 deletions examples/components/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ load("@npm//@bazel/typescript:index.bzl", "ts_library")
load(
"//:index.bzl",
"prerender_component",
"prerender_multi_page_bundled",
"prerender_pages",
"web_resources_devserver",
)
load("//tools:jasmine.bzl", "jasmine_node_test")

prerender_multi_page_bundled(
prerender_pages(
name = "page",
src = "page.ts",
bundle_js = False, # Optimization: No client-side JavaScript on this page.
Expand Down
10 changes: 5 additions & 5 deletions examples/custom_bundling/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Custom Bundling

An example which uses `prerender_multi_page()` instead of
`prerender_multi_page_bundled()` to skip the bundling step. It leaves bundling
JavaScript and CSS as a matter for the user, who can then leverage
`extract_single_resource()`, `inject_resources()`, and `web_resources()` to
assemble the bundled content together.
An example which uses `prerender_multi_page()` instead of `prerender_pages()` to
skip the bundling step. It leaves bundling JavaScript and CSS as a matter for
the user, who can then leverage `extract_single_resource()`,
`inject_resources()`, and `web_resources()` to assemble the bundled content
together.

It happens to use [Rollup](https://rollupjs.org/) to bundle JavaScript here, but
any bundler could reasonably be used.
Expand Down
4 changes: 2 additions & 2 deletions examples/data/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
load("@npm//@bazel/typescript:index.bzl", "ts_library")
load("//:index.bzl", "prerender_multi_page_bundled", "web_resources_devserver")
load("//:index.bzl", "prerender_pages", "web_resources_devserver")
load("//tools:jasmine.bzl", "jasmine_node_test")

prerender_multi_page_bundled(
prerender_pages(
name = "pages",
src = "pages.ts",
data = glob(["content/*.txt"]),
Expand Down
4 changes: 2 additions & 2 deletions examples/minimal/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
load("@npm//@bazel/typescript:index.bzl", "ts_library")
load("//:index.bzl", "prerender_multi_page_bundled", "web_resources_devserver")
load("//:index.bzl", "prerender_pages", "web_resources_devserver")
load("//tools:jasmine.bzl", "jasmine_node_test")

prerender_multi_page_bundled(
prerender_pages(
name = "page",
src = "page.ts",
bundle_js = False, # Optimization: No client-side JavaScript on this page.
Expand Down
4 changes: 2 additions & 2 deletions examples/multi_page/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//@bazel/typescript:index.bzl", "ts_library")
load(
"//:index.bzl",
"prerender_multi_page_bundled",
"prerender_pages",
"web_resources",
"web_resources_devserver",
)
load("//tools:jasmine.bzl", "jasmine_node_test")

prerender_multi_page_bundled(
prerender_pages(
name = "pages",
src = "pages.ts",
lib_deps = ["//packages/rules_prerender"],
Expand Down
8 changes: 4 additions & 4 deletions examples/multi_page/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Multi-Page

An example which generates multiple pages from a single NodeJS tool using
`prerender_multi_page_bundled()`. In this particular example, the pages are
fairly trivial and have constant paths, but the same strategy could be used to
generate pages from a more dynamic set of inputs, like a list of markdown files
that get converted into corresponding HTML files.
`prerender_pages()`. In this particular example, the pages are fairly trivial
and have constant paths, but the same strategy could be used to generate pages
from a more dynamic set of inputs, like a list of markdown files that get
converted into corresponding HTML files.
4 changes: 2 additions & 2 deletions examples/resources/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
load("@npm//@bazel/typescript:index.bzl", "ts_library")
load(
"//:index.bzl",
"prerender_multi_page_bundled",
"prerender_pages",
"web_resources",
"web_resources_devserver",
)
load("//tools:jasmine.bzl", "jasmine_node_test")

prerender_multi_page_bundled(
prerender_pages(
name = "page",
src = "page.ts",
bundle_js = False, # Optimization: No client-side JavaScript on this page.
Expand Down
8 changes: 4 additions & 4 deletions examples/resources/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Resources

An example which uses `web_resources()` rules to include external files in the
generated site. Technically, all examples which use
`prerender_multi_page_bundled()` include a `web_resources()` rule because that
is its output. However, this example actually includes custom files and verifies
that they are correctly propagated to the final site.
generated site. Technically, all examples which use `prerender_pages()` include
a `web_resources()` rule because that is its output. However, this example
actually includes custom files and verifies that they are correctly propagated
to the final site.
4 changes: 2 additions & 2 deletions examples/scripts/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
load("@npm//@bazel/typescript:index.bzl", "ts_library")
load("//:index.bzl", "prerender_multi_page_bundled", "web_resources_devserver")
load("//:index.bzl", "prerender_pages", "web_resources_devserver")
load("//tools:jasmine.bzl", "jasmine_node_test")

prerender_multi_page_bundled(
prerender_pages(
name = "page",
src = "page.ts",
lib_deps = ["//packages/rules_prerender"],
Expand Down
3 changes: 1 addition & 2 deletions examples/scripts/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Scripts

An example which bundles and loads JavaScript via
`prerender_multi_page_bundled()`.
An example which bundles and loads JavaScript via `prerender_pages()`.
4 changes: 2 additions & 2 deletions examples/site/about/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("//:index.bzl", "prerender_multi_page_bundled", "web_resources")
load("//:index.bzl", "prerender_pages", "web_resources")

prerender_multi_page_bundled(
prerender_pages(
name = "about",
src = "about.ts",
lib_deps = [
Expand Down
4 changes: 2 additions & 2 deletions examples/site/blog/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
load("@npm//@bazel/typescript:index.bzl", "ts_library")
load("//:index.bzl", "prerender_multi_page_bundled")
load("//:index.bzl", "prerender_pages")
load("//tools:jasmine.bzl", "jasmine_node_test")

prerender_multi_page_bundled(
prerender_pages(
name = "blog",
src = "blog.ts",
data = glob(["posts/*.md"]),
Expand Down
4 changes: 2 additions & 2 deletions examples/site/counter/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("//:index.bzl", "prerender_multi_page_bundled")
load("//:index.bzl", "prerender_pages")

prerender_multi_page_bundled(
prerender_pages(
name = "counter",
src = "counter.ts",
lib_deps = [
Expand Down
4 changes: 2 additions & 2 deletions examples/site/home/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
load("@npm//@bazel/typescript:index.bzl", "ts_library")
load("//:index.bzl", "prerender_multi_page_bundled", "web_resources_devserver")
load("//:index.bzl", "prerender_pages", "web_resources_devserver")
load("//tools:jasmine.bzl", "jasmine_node_test")

prerender_multi_page_bundled(
prerender_pages(
name = "home",
src = "home.ts",
lib_deps = [
Expand Down
4 changes: 2 additions & 2 deletions examples/styles/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
load("@npm//@bazel/typescript:index.bzl", "ts_library")
load("//:index.bzl", "prerender_multi_page_bundled", "web_resources_devserver")
load("//:index.bzl", "prerender_pages", "web_resources_devserver")
load("//tools:jasmine.bzl", "jasmine_node_test")

prerender_multi_page_bundled(
prerender_pages(
name = "page",
src = "page.ts",
styles = ["page.css"],
Expand Down
3 changes: 1 addition & 2 deletions examples/styles/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Styles

An example which bundles and loads CSS styles via
`prerender_multi_page_bundled()`.
An example which bundles and loads CSS styles via `prerender_pages()`.
4 changes: 2 additions & 2 deletions examples/testonly/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@npm//@bazel/typescript:index.bzl", "ts_library")
load(
"//:index.bzl",
"prerender_multi_page_bundled",
"prerender_pages",
"web_resources",
"web_resources_devserver",
)

prerender_multi_page_bundled(
prerender_pages(
name = "page",
src = "page.ts",
lib_deps = ["//packages/rules_prerender"],
Expand Down
4 changes: 2 additions & 2 deletions examples/tsconfig/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("//:index.bzl", "prerender_multi_page_bundled", "web_resources_devserver")
load("//:index.bzl", "prerender_pages", "web_resources_devserver")

prerender_multi_page_bundled(
prerender_pages(
name = "page",
src = "page.ts",
tsconfig = "tsconfig.json",
Expand Down
6 changes: 3 additions & 3 deletions index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ load(
_prerender_multi_page = "prerender_multi_page",
)
load(
"//packages/rules_prerender:prerender_multi_page_bundled.bzl",
_prerender_multi_page_bundled = "prerender_multi_page_bundled",
"//packages/rules_prerender:prerender_pages.bzl",
_prerender_pages = "prerender_pages",
)
load(
"//packages/rules_prerender:web_resources.bzl",
Expand All @@ -33,6 +33,6 @@ extract_single_resource = _extract_single_resource
inject_resources = _inject_resources
prerender_component = _prerender_component
prerender_multi_page = _prerender_multi_page
prerender_multi_page_bundled = _prerender_multi_page_bundled
prerender_pages = _prerender_pages
web_resources = _web_resources
web_resources_devserver = _web_resources_devserver
4 changes: 2 additions & 2 deletions packages/rules_prerender/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ bzl_library(
)

bzl_library(
name = "prerender_multi_page_bundled",
srcs = ["prerender_multi_page_bundled.bzl"],
name = "prerender_pages",
srcs = ["prerender_pages.bzl"],
visibility = ["//:__pkg__"],
deps = [
":multi_inject_resources",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Defines `prerender_multi_page_bundled()` functionality."""
"""Defines `prerender_pages()` functionality."""

load("@npm//@bazel/postcss:index.bzl", "postcss_binary")
load("@npm//@bazel/rollup:index.bzl", "rollup_bundle")
Expand All @@ -7,7 +7,7 @@ load(":postcss_import_plugin.bzl", IMPORT_PLUGIN_CONFIG = "PLUGIN_CONFIG")
load(":prerender_multi_page.bzl", "prerender_multi_page")
load(":web_resources.bzl", "web_resources")

def prerender_multi_page_bundled(
def prerender_pages(
name,
src,
tsconfig = None,
Expand Down
5 changes: 2 additions & 3 deletions packages/rules_prerender/rollup-default.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ export default {
// Give a better suggestion when no JavaScript is generated.
console.warn('Generated an empty JavaScript bundle, do you have'
+ ' any JavaScript? If not, consider setting'
+ ' `bundle_js = False` on your'
+ ' `prerender_multi_page_bundled()` to skip this step.\n\n'
+ warning.message);
+ ' `bundle_js = False` on your `prerender_pages()` to skip'
+ ' this step.\n\n' + warning.message);
return;
}

Expand Down

0 comments on commit c414b05

Please sign in to comment.