From c414b05ab7826b1be370a6eaa1c52b4db8e17f1e Mon Sep 17 00:00:00 2001 From: Doug Parker Date: Wed, 7 Apr 2021 19:46:47 -0700 Subject: [PATCH] Renames `prerender_multi_page_bundled()` -> `prerender_pages()`. 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()`. --- BUILD.bazel | 2 +- README.md | 18 +++++++++--------- examples/components/BUILD.bazel | 4 ++-- examples/custom_bundling/README.md | 10 +++++----- examples/data/BUILD.bazel | 4 ++-- examples/minimal/BUILD.bazel | 4 ++-- examples/multi_page/BUILD.bazel | 4 ++-- examples/multi_page/README.md | 8 ++++---- examples/resources/BUILD.bazel | 4 ++-- examples/resources/README.md | 8 ++++---- examples/scripts/BUILD.bazel | 4 ++-- examples/scripts/README.md | 3 +-- examples/site/about/BUILD.bazel | 4 ++-- examples/site/blog/BUILD.bazel | 4 ++-- examples/site/counter/BUILD.bazel | 4 ++-- examples/site/home/BUILD.bazel | 4 ++-- examples/styles/BUILD.bazel | 4 ++-- examples/styles/README.md | 3 +-- examples/testonly/BUILD.bazel | 4 ++-- examples/tsconfig/BUILD.bazel | 4 ++-- index.bzl | 6 +++--- packages/rules_prerender/BUILD.bazel | 4 ++-- ...ti_page_bundled.bzl => prerender_pages.bzl} | 4 ++-- .../rules_prerender/rollup-default.config.js | 5 ++--- 24 files changed, 60 insertions(+), 63 deletions(-) rename packages/rules_prerender/{prerender_multi_page_bundled.bzl => prerender_pages.bzl} (98%) diff --git a/BUILD.bazel b/BUILD.bazel index e5fbc7d3..6fcba9a0 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -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", ], diff --git a/README.md b/README.md index d172b102..82ec8960 100644 --- a/README.md +++ b/README.md @@ -206,7 +206,7 @@ export default function* render(): Generator { load( "@npm//rules_prerender:index.bzl", - "prerender_multi_page_bundled", + "prerender_pages", "web_resources_devserver", ) @@ -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", @@ -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. @@ -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 = [ @@ -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", diff --git a/examples/components/BUILD.bazel b/examples/components/BUILD.bazel index 49384db6..91d8d48b 100644 --- a/examples/components/BUILD.bazel +++ b/examples/components/BUILD.bazel @@ -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. diff --git a/examples/custom_bundling/README.md b/examples/custom_bundling/README.md index a2bd4fd2..2b7734ee 100644 --- a/examples/custom_bundling/README.md +++ b/examples/custom_bundling/README.md @@ -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. diff --git a/examples/data/BUILD.bazel b/examples/data/BUILD.bazel index 5dd5c689..e58562f6 100644 --- a/examples/data/BUILD.bazel +++ b/examples/data/BUILD.bazel @@ -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"]), diff --git a/examples/minimal/BUILD.bazel b/examples/minimal/BUILD.bazel index 84d43e26..bb13f3ed 100644 --- a/examples/minimal/BUILD.bazel +++ b/examples/minimal/BUILD.bazel @@ -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. diff --git a/examples/multi_page/BUILD.bazel b/examples/multi_page/BUILD.bazel index fdbb10b8..b5b94f95 100644 --- a/examples/multi_page/BUILD.bazel +++ b/examples/multi_page/BUILD.bazel @@ -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"], diff --git a/examples/multi_page/README.md b/examples/multi_page/README.md index edb2800d..c5de7442 100644 --- a/examples/multi_page/README.md +++ b/examples/multi_page/README.md @@ -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. diff --git a/examples/resources/BUILD.bazel b/examples/resources/BUILD.bazel index 56045b80..62572099 100644 --- a/examples/resources/BUILD.bazel +++ b/examples/resources/BUILD.bazel @@ -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. diff --git a/examples/resources/README.md b/examples/resources/README.md index ea326e80..788e134c 100644 --- a/examples/resources/README.md +++ b/examples/resources/README.md @@ -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. diff --git a/examples/scripts/BUILD.bazel b/examples/scripts/BUILD.bazel index 5099910e..cf9d4e49 100644 --- a/examples/scripts/BUILD.bazel +++ b/examples/scripts/BUILD.bazel @@ -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"], diff --git a/examples/scripts/README.md b/examples/scripts/README.md index d71f7505..83f72ee6 100644 --- a/examples/scripts/README.md +++ b/examples/scripts/README.md @@ -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()`. diff --git a/examples/site/about/BUILD.bazel b/examples/site/about/BUILD.bazel index d1eba29e..8db331c0 100644 --- a/examples/site/about/BUILD.bazel +++ b/examples/site/about/BUILD.bazel @@ -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 = [ diff --git a/examples/site/blog/BUILD.bazel b/examples/site/blog/BUILD.bazel index 2b228d81..9771cb92 100644 --- a/examples/site/blog/BUILD.bazel +++ b/examples/site/blog/BUILD.bazel @@ -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"]), diff --git a/examples/site/counter/BUILD.bazel b/examples/site/counter/BUILD.bazel index e1252d7c..c3eed978 100644 --- a/examples/site/counter/BUILD.bazel +++ b/examples/site/counter/BUILD.bazel @@ -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 = [ diff --git a/examples/site/home/BUILD.bazel b/examples/site/home/BUILD.bazel index ac7823d0..1fcc3c00 100644 --- a/examples/site/home/BUILD.bazel +++ b/examples/site/home/BUILD.bazel @@ -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 = [ diff --git a/examples/styles/BUILD.bazel b/examples/styles/BUILD.bazel index bcde3794..0b902535 100644 --- a/examples/styles/BUILD.bazel +++ b/examples/styles/BUILD.bazel @@ -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"], diff --git a/examples/styles/README.md b/examples/styles/README.md index c2b4bcf5..2f01925b 100644 --- a/examples/styles/README.md +++ b/examples/styles/README.md @@ -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()`. diff --git a/examples/testonly/BUILD.bazel b/examples/testonly/BUILD.bazel index 31a169f8..0d5c72ad 100644 --- a/examples/testonly/BUILD.bazel +++ b/examples/testonly/BUILD.bazel @@ -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"], diff --git a/examples/tsconfig/BUILD.bazel b/examples/tsconfig/BUILD.bazel index f3156370..75973ae2 100644 --- a/examples/tsconfig/BUILD.bazel +++ b/examples/tsconfig/BUILD.bazel @@ -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", diff --git a/index.bzl b/index.bzl index 20ca72f4..7fd51014 100644 --- a/index.bzl +++ b/index.bzl @@ -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", @@ -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 diff --git a/packages/rules_prerender/BUILD.bazel b/packages/rules_prerender/BUILD.bazel index 456ead01..34cd1767 100644 --- a/packages/rules_prerender/BUILD.bazel +++ b/packages/rules_prerender/BUILD.bazel @@ -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", diff --git a/packages/rules_prerender/prerender_multi_page_bundled.bzl b/packages/rules_prerender/prerender_pages.bzl similarity index 98% rename from packages/rules_prerender/prerender_multi_page_bundled.bzl rename to packages/rules_prerender/prerender_pages.bzl index a0901909..56670ef9 100644 --- a/packages/rules_prerender/prerender_multi_page_bundled.bzl +++ b/packages/rules_prerender/prerender_pages.bzl @@ -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") @@ -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, diff --git a/packages/rules_prerender/rollup-default.config.js b/packages/rules_prerender/rollup-default.config.js index c26930ed..7a5367d3 100644 --- a/packages/rules_prerender/rollup-default.config.js +++ b/packages/rules_prerender/rollup-default.config.js @@ -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; }