@fastly/compute-js-static-publish 8.1.0-beta.8 → 8.1.0-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +10 -2
  2. package/DOCUMENTATION.md +89 -71
  3. package/MIGRATING.md +45 -15
  4. package/README.md +6 -5
  5. package/README.short.md +6 -5
  6. package/build/cli/cli/commands/manage/clean.js +1 -1
  7. package/build/cli/cli/commands/manage/collections/delete.js +1 -1
  8. package/build/cli/cli/commands/manage/collections/index.js +1 -1
  9. package/build/cli/cli/commands/manage/collections/list.js +1 -1
  10. package/build/cli/cli/commands/manage/collections/promote.js +1 -1
  11. package/build/cli/cli/commands/manage/collections/update-expiration.js +1 -1
  12. package/build/cli/cli/commands/manage/index.js +2 -2
  13. package/build/cli/cli/commands/manage/publish-content.js +1 -1
  14. package/build/cli/cli/commands/manage/status.js +1 -1
  15. package/build/cli/cli/commands/manage/template/index.js +1 -1
  16. package/build/cli/cli/commands/manage/template/init.d.ts.map +1 -1
  17. package/build/cli/cli/commands/manage/template/init.js +11 -4
  18. package/build/cli/cli/commands/scaffold/app-template.js +1 -1
  19. package/build/cli/cli/commands/scaffold/generate-app.d.ts +1 -1
  20. package/build/cli/cli/commands/scaffold/generate-app.d.ts.map +1 -1
  21. package/build/cli/cli/commands/scaffold/generate-app.js +1 -1
  22. package/build/cli/cli/commands/scaffold/index.js +5 -5
  23. package/build/cli/cli/hono/build.d.ts +21 -14
  24. package/build/cli/cli/hono/build.d.ts.map +1 -1
  25. package/build/cli/cli/hono/build.js +119 -76
  26. package/build/cli/cli/managed/app.js +4 -4
  27. package/build/cli/cli/managed/command-helpers.js +6 -6
  28. package/build/cli/cli/managed/project-file.js +6 -6
  29. package/build/cli/cli/managed/template-init.js +3 -3
  30. package/build/cli/cli/storage/kv-store-local-provider.d.ts +2 -2
  31. package/build/cli/cli/storage/kv-store-local-provider.d.ts.map +1 -1
  32. package/build/cli/cli/storage/kv-store-local-provider.js +2 -14
  33. package/build/cli/cli/storage/kv-store-provider.d.ts +2 -2
  34. package/build/cli/cli/storage/kv-store-provider.d.ts.map +1 -1
  35. package/build/cli/cli/storage/kv-store-provider.js +2 -1
  36. package/build/cli/cli/storage/s3-storage-provider.d.ts +2 -2
  37. package/build/cli/cli/storage/s3-storage-provider.d.ts.map +1 -1
  38. package/build/cli/cli/storage/s3-storage-provider.js +4 -3
  39. package/build/cli/cli/storage/storage-provider.d.ts +3 -1
  40. package/build/cli/cli/storage/storage-provider.d.ts.map +1 -1
  41. package/build/cli/cli/storage/storage-provider.js +16 -0
  42. package/build/cli/cli/util/kv-store.d.ts +1 -1
  43. package/build/cli/cli/util/kv-store.d.ts.map +1 -1
  44. package/build/cli/models/config/static-publish-rc.d.ts +4 -3
  45. package/build/cli/models/config/static-publish-rc.d.ts.map +1 -1
  46. package/build/cli/models/config/template-settings.d.ts.map +1 -1
  47. package/build/cli/models/config/template-settings.js +34 -9
  48. package/build/server/hono/compose.d.ts +51 -0
  49. package/build/server/hono/compose.d.ts.map +1 -0
  50. package/build/server/hono/{extensions.js → compose.js} +25 -17
  51. package/build/server/hono/index.d.ts +1 -1
  52. package/build/server/hono/index.d.ts.map +1 -1
  53. package/build/server/hono/index.js +1 -1
  54. package/build/server/models/config/static-publish-rc.d.ts +4 -3
  55. package/build/server/models/config/static-publish-rc.d.ts.map +1 -1
  56. package/build/server/server/index.d.ts +1 -1
  57. package/build/server/server/index.d.ts.map +1 -1
  58. package/build/server/server/publisher-server/index.d.ts.map +1 -1
  59. package/build/server/server/publisher-server/index.js +6 -1
  60. package/build/server/server/storage/kv-store-provider.d.ts.map +1 -1
  61. package/build/server/server/storage/kv-store-provider.js +1 -0
  62. package/build/server/server/storage/s3-storage-provider.d.ts +2 -2
  63. package/build/server/server/storage/s3-storage-provider.d.ts.map +1 -1
  64. package/build/server/server/storage/s3-storage-provider.js +5 -2
  65. package/build/server/server/storage/storage-provider.d.ts +12 -1
  66. package/build/server/server/storage/storage-provider.d.ts.map +1 -1
  67. package/package.json +2 -2
  68. package/resources/template-init/hono/_example.ts +14 -13
  69. package/resources/templates/hono/package-lock.json +40 -40
  70. package/resources/templates/hono/package.json +2 -2
  71. package/resources/templates/hono/scripts/template_postinstall.js +5 -5
  72. package/resources/templates/hono/scripts/template_prebuild.js +6 -6
  73. package/resources/templates/hono/scripts/template_watch.js +5 -4
  74. package/resources/templates/hono/src/hono-compose.generated.d.ts +5 -0
  75. package/resources/templates/hono/src/index.ts +14 -14
  76. package/resources/templates/plain/package-lock.json +40 -40
  77. package/resources/templates/plain/package.json +2 -2
  78. package/build/server/hono/extensions.d.ts +0 -50
  79. package/build/server/hono/extensions.d.ts.map +0 -1
  80. package/resources/templates/hono/src/hono-extensions.generated.d.ts +0 -5
package/CHANGELOG.md CHANGED
@@ -12,8 +12,8 @@ This file does not list v7 releases after 7.0.8, or v6 releases after 6.3.0. For
12
12
  ### Added
13
13
 
14
14
  - `scaffold --template hono` (and `managed.template: 'hono'` in a managed project): a TypeScript Hono app. `src/index.ts` uses `selectCollection()`, `serveStatic()`, and `serveFallback()` of `@fastly/compute-js-static-publish/hono`, and `fire()` of `@fastly/hono-fastly-compute`. The app has `tsconfig.json`, and `typescript` as a dev dependency; the build does not check types (run `npx tsc`). In a managed project, a change of `managed.template` generates the app again with the new template, and changes the fingerprint.
15
- - Hono extensions for the `hono` template: modules in `hono-extensions/` default-export `defineExtension()` (from `@fastly/compute-js-static-publish/hono`), with a function for each phase that they use: `middleware`, `beforeFilesRoutes` (before the published files), and `afterFilesRoutes` (for the requests that no published file matches). Each phase function gets the app, the options of the module, and the helpers of the app (`serveStatic()`, `staticResponse()`, `serveFallback()`, `fallbackResponse()`, `isCollectionAvailable()`, and `publisherServer`). `c.env` in a module has the types of its bindings. The build bundles them into the app; the packages that the app provides stay imports. Options come from `templateOptions.hono.extensions` and bindings from `templateOptions.hono.bindings`, and `build.hono.extensionsDir` sets another folder. `template init` makes or updates the folder (with a `.gitignore` for `node_modules/`), and `template init --check` fails with the new error code `template-init-needed` if it is out of date. `dev -- --watch` and `npm run dev:watch` also watch the folder. `status --json` has `template`, with the packages that the template provides.
16
- - Examples of Hono extensions in `examples/hono/` (in the repository, not in the npm package): `grip` (realtime streams and Server-Sent Events with Fastly Fanout) and `oauth` (a login with GitHub or Google).
15
+ - Composing plugin modules in the `hono` template: plugins in `hono-compose/` default-export `definePlugin()` (from `@fastly/compute-js-static-publish/hono`), with a function for each phase that they use: `middleware`, `routes` (before the published files), and `afterFilesRoutes` (for the requests that no published file matches). Each phase function gets the app, the options of the plugin, and the helpers of the app (`serveStatic()`, `staticResponse()`, `serveFallback()`, `fallbackResponse()`, `isCollectionAvailable()`, and `publisherServer`). `c.env` in a plugin has the types of its bindings. The build bundles them into the app; the packages that the app provides stay imports. Options come from `templateOptions.hono.compose.plugins` and bindings from `templateOptions.hono.bindings`, and `build.hono.composeDir` sets another folder. A file named `index` in the folder is reserved. `template init` makes or updates the folder (with a `.gitignore` for `node_modules/`), and `template init --check` fails with the new error code `template-init-needed` if it is out of date. `dev -- --watch` and `npm run dev:watch` also watch the folder. `status --json` has `template`, with the packages that the template provides.
16
+ - Examples of plugins in `examples/hono/` (in the repository, not in the npm package): `grip` (realtime streams and Server-Sent Events with Fastly Fanout) and `oauth` (a login with GitHub or Google).
17
17
  - Hono support: `@fastly/compute-js-static-publish/hono`. `fromStaticPublishRc(rc)` (or `fromPublisherServer(server)`) returns `serveStatic()` (middleware that serves the published files with `serveRequest()`, and calls the next handler if no file matches; the option `onMissing` replaces `collectionSelection.onMissing` for one route), `staticResponse(c)` (the same response for use in a handler, or `null`; never the SPA file or the 404 page), `serveFallback()` (for `app.notFound()`: the SPA file or the 404 page), `fallbackResponse(c)` (the same response for use in a handler, or `null`), `isCollectionAvailable(c)` (whether the selected collection, or another one, is published and not expired), `selectCollection()` (collection selection for a Hono app; it sets `c.var.staticPublisher`, and `serveStatic()` and `serveFallback()` use the selected collection), and `publisherServer`. The type `StaticPublisherVariables` is for the variables of the app. The options `status` and `headers` change the response of a file. `hono` v4 is an optional peer dependency. This replaces `@fastly/hono-compute-js-static-publish`, which supports only v6 and v7; `MIGRATING.md` has the steps.
18
18
  - `--project-dir`: run a command for the app in another directory, for example from the root of the repo in CI. All relative paths are then relative to that directory.
19
19
  - `--version`: print the version of this package. It works in any directory.
@@ -52,6 +52,7 @@ This file does not list v7 releases after 7.0.8, or v6 releases after 6.3.0. For
52
52
  - `PublisherServer`: the options `status` and `headers` of `serveRequest()` and `serveFallback()` change the status and the headers of the response of a file, for one call. For a status other than `2xx`, the server does not evaluate the preconditions of the request.
53
53
  - `PublisherServer`: `serveRequestStreaming()`, `serveFallbackStreaming()`, and `serveCachedStreaming()` return `{ response, fillPromise }`. On a Fastly service with `@fastly/js-compute` 4.2 or later (not in `fastly compute serve`), a response cache fill for a body with a known length streams the body to the visitor and into the cache at the same time. Pass `fillPromise` to `event.waitUntil()`. A body that does not have its declared length is not cached, and the next fill reads the whole body first. The `plain` template and the Hono helpers use them.
54
54
  - `PublisherServer`: the function of `serveCached()` can return `{ response, length }`. With `length: null`, the response is not cached.
55
+ - `StorageProvider.getEntry()` takes an optional third parameter, `options` (type `GetEntryOptions`). Its `ttl` sets how long, in seconds, a provider that caches what it reads keeps the entry.
55
56
 
56
57
  ### Changed
57
58
 
@@ -70,6 +71,12 @@ This file does not list v7 releases after 7.0.8, or v6 releases after 6.3.0. For
70
71
  - `collections promote` from a collection that does not exist stops with the message "Collection '…' does not exist." (exit `2`). Before, it stopped with an uncaught error.
71
72
  - `collections delete` of a collection that does not exist says "Nothing to delete." It still succeeds, as before.
72
73
  - `staticPublisherWorkingDir` in `static-publish.rc.js` can be a path outside the directory of the file, for example `../static-publisher`. It must start with `./` or `../`, and it must not be the directory of `static-publish.rc.js` or a directory above it (for example `./`, `..`, or `../..`). Before, the value had to start with `./`. A value that breaks the rule stops the command before it writes anything.
74
+ - S3 mode: the server keeps the files that it reads from storage in the Fastly cache for 1 year. It was 1 hour. With a response cache `maxAge` of 1 hour or more, a response-cache miss then usually also read the file from storage. The key of a file has the hash of its content, so a cached copy does not get out of date. The cached files have the new surrogate key `<publishId>-files`. A publish does not purge it. The settings and the index are still kept for 1 hour.
75
+ - S3-compatible storage is no longer a beta feature. The docs, the help, and the messages of the CLI do not show "Beta" for it now.
76
+
77
+ ### Updated
78
+
79
+ - Scaffolded apps and the apps of managed projects use `@fastly/js-compute` `^4.4.0` and `@fastly/cli` `^17.0.0`. Before, they used `^4.0.0` and `^16.0.0`.
73
80
 
74
81
  ### Deprecated
75
82
 
@@ -79,6 +86,7 @@ This file does not list v7 releases after 7.0.8, or v6 releases after 6.3.0. For
79
86
 
80
87
  - `PublisherServer`: a request for the 404 page with an `If-None-Match` that matched its `ETag` (or an `If-Modified-Since` after its time) got a `304` with no body. Now the server evaluates the preconditions only for a `2xx` response, as RFC 9110 says, so the response is always the `404` with the page.
81
88
  - `scaffold` now escapes the values that it writes into `fastly.toml`. Before, a `"` or a `\` in `--name`, `--description`, or `--author`, or a KV Store name with a character such as `.`, gave a `fastly.toml` that was not valid.
89
+ - `collections promote` and `collections update-expiration` (KV Store): the command sometimes stopped with `400 Bad request: must include valid content-length header` when it wrote the index of the collection. The command sent the index as a stream, with no `Content-Length`. Now it reads the index into memory and sends it with a `Content-Length`. In S3 mode, the commands now also send the index and the settings with a known length.
82
90
 
83
91
  ## [8.0.2] - 2026-11-16
84
92
 
package/DOCUMENTATION.md CHANGED
@@ -3,7 +3,7 @@
3
3
  > NOTE: `@fastly/compute-js-static-publish` is provided as a Fastly Labs product. Visit the [Fastly Labs](https://www.fastlylabs.com/) site for terms of use.
4
4
 
5
5
  > [!NOTE]
6
- > v8 adds Beta support for S3-compatible storage, such as Fastly [Object Storage](https://www.fastly.com/products/storage). For more details, see the [S3-compatible storage](#-using-s3-compatible-storage-beta) section.
6
+ > v8 adds support for S3-compatible storage, such as Fastly [Object Storage](https://www.fastly.com/products/storage). For more details, see the [S3-compatible storage](#-using-s3-compatible-storage) section.
7
7
 
8
8
  > [!NOTE]
9
9
  > These docs are for v7 or newer, a major rewrite that adds powerful new features such as named collections.
@@ -15,9 +15,10 @@
15
15
  ## 📖 Table of Contents
16
16
 
17
17
  - [✨ Key Features](#-key-features)
18
+ - [🆕 New in 8.1](#-new-in-81)
18
19
  - [🏁 Quick Start](#-quick-start)
19
20
  - [📦 Fastly KV Store](#-using-the-fastly-kv-store)
20
- - [🎁 S3 Compatible Storage](#-using-s3-compatible-storage-beta) (Beta)
21
+ - [🎁 S3 Compatible Storage](#-using-s3-compatible-storage)
21
22
  - [⚙️ Configuring `static-publish.rc.js`](#️-configuring-static-publishrcjs)
22
23
  - [🧾 Config for Publishing and Server: `publish-content.config.js`](#-config-for-publishing-and-server-publish-contentconfigjs)
23
24
  - [📦 Collections (Publish, Preview, Promote)](#-collections-publish-preview-promote)
@@ -34,18 +35,34 @@ Serve static websites and web apps at the edge &mdash; no backends and no CDN in
34
35
 
35
36
  `@fastly/compute-js-static-publish` helps you deploy and serve static files using [Fastly Compute](https://developer.fastly.com/learning/compute/) for fast, cacheable, and content-addressed delivery. The library can be configured to store your data in either of the following:
36
37
  * Fastly [Key Value Store](https://www.fastly.com/products/kv-store)
37
- * S3-compatible storage, such as Fastly [Object Storage](https://www.fastly.com/products/storage) (Beta)
38
+ * S3-compatible storage, such as Fastly [Object Storage](https://www.fastly.com/products/storage)
38
39
 
39
40
  ## ✨ Key Features
40
41
 
41
42
  - 📦 Easy to scaffold and deploy
42
- - 🚀 Content stored using hashed keys, in Fastly KV Store or S3-compatible storage (Beta) including Fastly Object Storage
43
+ - 🚀 Content stored using hashed keys, in Fastly KV Store or S3-compatible storage, including Fastly Object Storage
43
44
  - 🔁 Publish new content without needing to deploy new Wasm binaries
44
45
  - 🗂 Organize releases into named collections which can be previewed (e.g. `live`, `staging`, `preview-123`)
45
46
  - 🧼 Cleanup tools to remove expired or orphaned files
46
47
  - ⚙️ Configurable per-collection server configurations (e.g. fallback files)
47
48
  - 🔒 Supports Brotli/gzip compression, conditional GET, and long cache TTLs
48
49
 
50
+ ## 🆕 New in 8.1
51
+
52
+ - **Managed projects:** keep only `static-publish.project.js` in your repo. The CLI generates the app, and `dev`, `deploy`, `status`, `upgrade`, and `eject` work with it. ([Managed and ejected apps](#managed-and-ejected-apps))
53
+ - **Previews:** serve another collection for a request, selected by host, path, query, cookie, or header. ([Previews](#-previews-collection-selection))
54
+ - **Hidden files:** publish files that the server does not serve for a request, for your own code to read. Deploy your app with 8.1 before you publish hidden files: an app built with 8.0 does not serve a collection that has hidden files. ([Hidden files](#hidden-files))
55
+ - **Hono:** the `hono` template (`--template=hono`), with your own middleware and routes as plugin modules in `hono-compose/`, and examples for GRIP streaming and OAuth login. For your own Hono app, `@fastly/compute-js-static-publish/hono` replaces `@fastly/hono-compute-js-static-publish`. ([Using Hono](#-using-hono))
56
+ - **CI:** `--json` output, exit codes, error codes, `--project-dir`, and `--non-interactive`. ([Using the CLI in CI](#-using-the-cli-in-ci))
57
+ - **Streaming response cache:** on a cache miss, the file goes to the visitor and into the cache at the same time, so the visitor does not wait for the whole file, and the request uses less memory. Apps from the `plain` and `hono` templates do this; in your own code, use `serveRequestStreaming()` and pass `fillPromise` to `event.waitUntil()`. It needs `@fastly/js-compute` 4.2 or later on a Fastly service. ([Streaming the response into the cache](#streaming-the-response-into-the-cache))
58
+
59
+ Before you upgrade, read [CHANGELOG.md](CHANGELOG.md). These changes can break something:
60
+
61
+ - The name of a new collection must be a DNS label: lowercase `a-z`, `0-9`, and `-`, from 1 to 63 characters, with no `-` at the start or the end. A collection that exists continues to work with another name, with a warning.
62
+ - A usage or config error exits with `2`. Before, every error exited with `1`.
63
+ - `collectionSelector.fromCookie()`: the activate and reset paths redirect with `308`. Before, they used `302`.
64
+ - `PublisherServer`: the fields `serverTiming`, `settingsCached`, and `assetEntryMapCache` are read-only (deprecated). An assignment to them throws a `TypeError` (and is a TypeScript error).
65
+
49
66
  ---
50
67
 
51
68
  ## 🏁 Quick Start
@@ -111,7 +128,7 @@ This command uploads your static files to the KV Store and applies the server co
111
128
  FASTLY_API_TOKEN=$(npx fastly auth token) npm run fastly:publish
112
129
  ```
113
130
 
114
- ### 🎁 Using S3 Compatible Storage (Beta)
131
+ ### 🎁 Using S3 Compatible Storage
115
132
 
116
133
  #### 1. Scaffold a Compute App
117
134
 
@@ -246,7 +263,7 @@ my-site/
246
263
 
247
264
  The project file has the settings that an ejected app has in its two files:
248
265
 
249
- - The top level has the fields of `static-publish.rc.js` (`storageMode`, `kvStore` or `s3`, `publishId`, `defaultCollectionName`, `staticPublisherWorkingDir`, `collectionSelection`), and the settings of the template (`build` and `templateOptions`, see [Hono extensions](#hono-extensions)).
266
+ - The top level has the fields of `static-publish.rc.js` (`storageMode`, `kvStore` or `s3`, `publishId`, `defaultCollectionName`, `staticPublisherWorkingDir`, `collectionSelection`), and the settings of the template (`build` and `templateOptions`, see [Composing plugin modules](#composing-plugin-modules)).
250
267
  - `publishContent` has the fields of `publish-content.config.js`. `publish-content --config <file>` replaces it for one run.
251
268
  - `managed` has the settings of the generated app (`name`, `description`, `authors`, `serviceId`, `staticPublishVersion`, the version of this package that the project uses, and `fastlyToml`, see below).
252
269
 
@@ -401,7 +418,7 @@ const rc = {
401
418
  export default rc;
402
419
  ```
403
420
 
404
- ### Using S3-compatible storage (BETA)
421
+ ### Using S3-compatible storage
405
422
 
406
423
  #### Fields:
407
424
 
@@ -890,7 +907,7 @@ If you do need to rebuild and redeploy the Compute app, simply run:
890
907
  npm run fastly:deploy
891
908
  ```
892
909
 
893
- ### Using S3-compatible storage (BETA)
910
+ ### Using S3-compatible storage
894
911
 
895
912
  #### Local development
896
913
 
@@ -1145,6 +1162,7 @@ publisherServer.setResponseCache({ maxAge: 3600, maxBodySize: 4 * 1024 * 1024 })
1145
1162
  - If several requests miss the same response at the same time, one request produces it, and the others wait for it.
1146
1163
  - Only `200` and `404` responses are cached. Conditional requests (`304`) and `HEAD` requests are answered from the cached response.
1147
1164
  - Each cached response has the surrogate key `<publishId>-<collectionName>`. After you publish, `publish-content` purges this key (see [`--fastly-service-id`](#publish-content)), so the next request gets the new content. `collections promote` and `collections delete` purge the key of the collection that they change.
1165
+ - In S3 mode, the server also keeps the settings, the index, and the files that it reads from storage in the Fastly cache. The settings and the index are kept for 1 hour, with the surrogate key of the collection. The files are kept for 1 year, with the surrogate key `<publishId>-files`, because the key of a file has the hash of its content. Thus after a publish, a file that did not change is read from the cache, not from storage. A publish does not purge `<publishId>-files`. To remove the cached copies of all files, purge it yourself.
1148
1166
 
1149
1167
  `serveRequest()` uses the response cache automatically. If you call `getMatchingAsset()` and `serveAsset()` directly, wrap them in `serveCached()`. When a response is not cached yet, `serveCached()` calls your function to produce it, with a `GET` request that has no conditional headers:
1150
1168
 
@@ -1177,7 +1195,7 @@ async function handleRequest(event) {
1177
1195
 
1178
1196
  With `event.waitUntil()`, the fill continues after your handler returns, also if the visitor disconnects. Without it, the fill stops when your handler returns, and nothing is cached. `fillPromise` never rejects.
1179
1197
 
1180
- The scaffolded app of the `plain` template and the [Hono](#-using-hono) helpers use these methods.
1198
+ The scaffolded app of the `plain` template and the [Hono](#-using-hono) helpers use these methods. Apps scaffolded before 8.1.0 call `serveRequest()`, so their fill does not stream. To stream, change `src/index.js` of such an app as the example above shows.
1181
1199
 
1182
1200
  The fill streams only on a Fastly service with `@fastly/js-compute` 4.2 or later. With an earlier version, in `fastly compute serve`, or for a body with a length that is not known, the fill reads the whole body first, as `serveCached()` does, and `fillPromise` is already resolved.
1183
1201
 
@@ -1204,9 +1222,9 @@ npx @fastly/compute-js-static-publish@beta --template hono --root-dir=./public -
1204
1222
 
1205
1223
  The app is TypeScript: `src/index.ts`, with code like the example below, and `tsconfig.json`. Add your own routes in `src/index.ts`. The build (`js-compute-runtime ./src/index.ts`) removes the types, but does not check them. To check the types, run `npx tsc` in the app. The app has `typescript` as a dev dependency.
1206
1224
 
1207
- ### Hono extensions
1225
+ ### Composing plugin modules
1208
1226
 
1209
- To add your own middleware and routes to the `hono` template, put modules in the extensions folder, `hono-extensions/`. In a managed project, this is the only way to add code, because the CLI generates the app. In an ejected app, you can also edit `src/index.ts`.
1227
+ To add your own middleware and routes to the `hono` template, put plugin modules in the folder `hono-compose/`. The app composes them with the published files. In a managed project, this is the only way to add code, because the CLI generates the app. In an ejected app, you can also edit `src/index.ts`.
1210
1228
 
1211
1229
  `scaffold --template hono` makes the folder next to the project file (managed) or next to `compute-js/` (ejected). To make it later, or to update it, run:
1212
1230
 
@@ -1215,42 +1233,42 @@ npx @fastly/compute-js-static-publish@beta template init
1215
1233
  ```
1216
1234
 
1217
1235
  ```
1218
- hono-extensions/
1236
+ hono-compose/
1219
1237
  ├── package.json # Your dependencies, and the peer dependencies on the packages that the app provides
1220
1238
  ├── tsconfig.json # For your editor
1221
1239
  ├── .gitignore # Ignores node_modules/
1222
- ├── 10-auth.ts # A module
1223
- ├── api.ts # A module
1224
- ├── _example.ts # An example, not a module (the name starts with _)
1225
- └── lib/ # Your helpers (not modules)
1240
+ ├── 10-auth.ts # A plugin
1241
+ ├── api.ts # A plugin
1242
+ ├── _example.ts # An example, not a plugin (the name starts with _)
1243
+ └── lib/ # Your helpers (not plugins)
1226
1244
  ```
1227
1245
 
1228
- - **Modules** are the files directly in the folder, with the extension `.ts`, `.mts`, `.js`, or `.mjs`. Files that start with `_` or `.`, and `.d.ts` files, are not modules. The build does not look in subfolders, so use them, for example `lib/`, for your helpers.
1229
- - **The name** of a module is the file name without the number prefix and the extension: `10-auth.ts` is `auth`. Two modules with the same name are an error.
1230
- - **The phases:** a module adds its handlers to the app in one or more phases. In each phase, the app takes the modules in the order of the file names (add a number prefix to set the order). The phases are on two axes:
1246
+ - **Plugins** are the files directly in the folder, with the extension `.ts`, `.mts`, `.js`, or `.mjs`. Files that start with `_` or `.`, and `.d.ts` files, are not plugins. The build does not look in subfolders, so use them, for example `lib/`, for your helpers.
1247
+ - **The name** of a plugin is the file name without the number prefix and the extension: `10-auth.ts` is `auth`. Two plugins with the same name are an error. `index` is a reserved name: a file `index.ts` (or `.js`, `.mjs`, `.mts`) stops the build.
1248
+ - **The phases:** a plugin adds its handlers to the app in one or more phases. In each phase, the app takes the plugins in the order of the file names (add a number prefix to set the order). The phases are on two axes:
1231
1249
 
1232
1250
  ```
1233
1251
  selectCollection()
1234
1252
  middleware processing: wraps all of the routing below
1235
- beforeFilesRoutes routing: the first route that answers wins
1253
+ routes routing: the first route that answers wins
1236
1254
  → published files (serveStatic())
1237
1255
  → afterFilesRoutes
1238
1256
  → serveFallback()
1239
1257
  ```
1240
1258
 
1241
- - **Processing:** `middleware` wraps each request, for example a login check, a header on each response, or the time of a request. In a middleware, the code before `await next()` runs before the routes. The code after it runs after the response is made, also when a published file answered, and in the reverse order of the modules. All modules add their middleware before any module adds its routes, so a middleware such as a login check also applies to the routes of the other modules.
1259
+ - **Processing:** `middleware` wraps each request, for example a login check, a header on each response, or the time of a request. In a middleware, the code before `await next()` runs before the routes. The code after it runs after the response is made, also when a published file answered, and in the reverse order of the plugins. All plugins add their middleware before any plugin adds its routes, so a middleware such as a login check also applies to the routes of the other plugins.
1242
1260
  - **Routing:** the routes that can answer a request, in this order. The first one that answers wins.
1243
- - `beforeFilesRoutes`: before the published files. A route here wins over a file at the same path, for example an API.
1261
+ - `routes`: before the published files. A route here wins over a file at the same path, for example an API.
1244
1262
  - The published files (`serveStatic()`).
1245
1263
  - `afterFilesRoutes`: only for the requests that no published file matches, before the SPA file or the 404 page. A file at the same path wins, for example for a redirect from an old URL, which stops when a file is published at that URL again. The published files are served only for `GET` and `HEAD`, so these routes also get all other methods.
1246
1264
 
1247
1265
  A middleware that measures the time of each request, with the code before and after `await next()`:
1248
1266
 
1249
1267
  ```ts
1250
- // hono-extensions/05-timing.ts
1251
- import { defineExtension } from '@fastly/compute-js-static-publish/hono';
1268
+ // hono-compose/05-timing.ts
1269
+ import { definePlugin } from '@fastly/compute-js-static-publish/hono';
1252
1270
 
1253
- export default defineExtension((app) => {
1271
+ export default definePlugin((app) => {
1254
1272
  app.use('*', async (c, next) => {
1255
1273
  const start = performance.now();
1256
1274
  await next();
@@ -1261,13 +1279,13 @@ hono-extensions/
1261
1279
 
1262
1280
  The time ends when the response is made. The body of a large file can still be on its way to the visitor then.
1263
1281
 
1264
- A module default-exports `defineExtension()`. Give it a function for each phase that the module uses. Each function gets the Hono app, the options of the module, and the helpers of the app (see below), and adds handlers with `app.use()`, `app.get()`, `app.post()`, and the other methods of Hono. With only a function in place of the object, the function is the `middleware` phase:
1282
+ A plugin default-exports `definePlugin()`. Give it a function for each phase that the plugin uses. Each function gets the Hono app, the options of the plugin, and the helpers of the app (see below), and adds handlers with `app.use()`, `app.get()`, `app.post()`, and the other methods of Hono. With only a function in place of the object, the function is the `middleware` phase:
1265
1283
 
1266
1284
  ```ts
1267
- // hono-extensions/10-header.ts
1268
- import { defineExtension } from '@fastly/compute-js-static-publish/hono';
1285
+ // hono-compose/10-header.ts
1286
+ import { definePlugin } from '@fastly/compute-js-static-publish/hono';
1269
1287
 
1270
- export default defineExtension((app, options?: { value?: string }) => {
1288
+ export default definePlugin((app, options?: { value?: string }) => {
1271
1289
  app.use('*', async (c, next) => {
1272
1290
  await next();
1273
1291
  c.header('x-site', options?.value ?? 'default');
@@ -1276,17 +1294,17 @@ export default defineExtension((app, options?: { value?: string }) => {
1276
1294
  ```
1277
1295
 
1278
1296
  ```ts
1279
- // hono-extensions/api.ts
1280
- import { defineExtension } from '@fastly/compute-js-static-publish/hono';
1297
+ // hono-compose/api.ts
1298
+ import { definePlugin } from '@fastly/compute-js-static-publish/hono';
1281
1299
 
1282
- export default defineExtension({ bindings: { config: 'ConfigStore:site_config' } }, {
1300
+ export default definePlugin({ bindings: { config: 'ConfigStore:site_config' } }, {
1283
1301
  middleware: (app) => {
1284
1302
  app.use('/api/*', async (c, next) => {
1285
1303
  await next();
1286
1304
  c.header('cache-control', 'no-store');
1287
1305
  });
1288
1306
  },
1289
- beforeFilesRoutes: (app) => {
1307
+ routes: (app) => {
1290
1308
  app.get('/api/greeting', async (c) => c.json({ greeting: await c.env.config?.get('greeting') }));
1291
1309
  },
1292
1310
  afterFilesRoutes: (app) => {
@@ -1295,28 +1313,28 @@ export default defineExtension({ bindings: { config: 'ConfigStore:site_config' }
1295
1313
  });
1296
1314
  ```
1297
1315
 
1298
- **Options** come from `templateOptions.hono.extensions` in the project file (or in `static-publish.rc.js`), with the name of the module as the key. Each phase of a module gets the same options. The build shows a warning for options of a module that does not exist:
1316
+ **Options** come from `templateOptions.hono.compose.plugins` in the project file (or in `static-publish.rc.js`), with the name of the plugin as the key. Each phase of a plugin gets the same options. The build shows a warning for options of a plugin that does not exist:
1299
1317
 
1300
1318
  ```js
1301
1319
  templateOptions: {
1302
1320
  hono: {
1303
1321
  bindings: { config: 'ConfigStore:site_config' },
1304
- extensions: { header: { value: 'my-site' } },
1322
+ compose: { plugins: { header: { value: 'my-site' } } },
1305
1323
  },
1306
1324
  },
1307
1325
  ```
1308
1326
 
1309
- **The files step:** between `beforeFilesRoutes` and `afterFilesRoutes`, the app has a fixed step that serves the published files with `serveStatic()`. It is not a phase, and a module cannot remove it. A module can serve files in another way before it: a request that the module answers does not get to this step, and a request that the module passes on with `next()` does.
1327
+ **The files step:** between `routes` and `afterFilesRoutes`, the app has a fixed step that serves the published files with `serveStatic()`. It is not a phase, and a plugin cannot remove it. A plugin can serve files in another way before it: a request that the plugin answers does not get to this step, and a request that the plugin passes on with `next()` does.
1310
1328
 
1311
- **Helpers:** the third argument of each phase function has the `serveStatic()`, `staticResponse()`, `serveFallback()`, `fallbackResponse()`, `isCollectionAvailable()`, and `publisherServer` that the app uses (see [Using Hono](#-using-hono)). They are made once when the app starts, with the same `collectionSelection`, so a module can serve published files in its own place in the order, with its own rules.
1329
+ **Helpers:** the third argument of each phase function has the `serveStatic()`, `staticResponse()`, `serveFallback()`, `fallbackResponse()`, `isCollectionAvailable()`, and `publisherServer` that the app uses (see [Using Hono](#-using-hono)). They are made once when the app starts, with the same `collectionSelection`, so a plugin can serve published files in its own place in the order, with its own rules.
1312
1330
 
1313
- For example, a module that runs before a login check, and serves `/theme/*` on a preview: from the selected collection, or from the default collection if the preview is missing, and with a plain `404` (not the 404 page of the collection, which would show the preview without a login). Without a preview, the module does nothing, and the app serves the request as usual. In Hono, a handler cannot skip the handlers that come after it in the same `app.use()`, so the module decides first whether it takes part. Two ways to write it, which do the same:
1331
+ For example, a plugin that runs before a login check, and serves `/theme/*` on a preview: from the selected collection, or from the default collection if the preview is missing, and with a plain `404` (not the 404 page of the collection, which would show the preview without a login). Without a preview, the plugin does nothing, and the app serves the request as usual. In Hono, a handler cannot skip the handlers that come after it in the same `app.use()`, so the plugin decides first whether it takes part. Two ways to write it, which do the same:
1314
1332
 
1315
1333
  ```ts
1316
- // hono-extensions/10-theme.ts: one handler with staticResponse()
1317
- import { defineExtension } from '@fastly/compute-js-static-publish/hono';
1334
+ // hono-compose/10-theme.ts: one handler with staticResponse()
1335
+ import { definePlugin } from '@fastly/compute-js-static-publish/hono';
1318
1336
 
1319
- export default defineExtension((app, options, { staticResponse }) => {
1337
+ export default definePlugin((app, options, { staticResponse }) => {
1320
1338
  app.use('/theme/*', async (c, next) => {
1321
1339
  if (c.var.staticPublisher.collectionName == null) {
1322
1340
  return next(); // not a preview: the app serves it as usual
@@ -1327,11 +1345,11 @@ export default defineExtension((app, options, { staticResponse }) => {
1327
1345
  ```
1328
1346
 
1329
1347
  ```ts
1330
- // hono-extensions/10-theme.ts: serveStatic() with except() of hono/combine
1331
- import { defineExtension } from '@fastly/compute-js-static-publish/hono';
1348
+ // hono-compose/10-theme.ts: serveStatic() with except() of hono/combine
1349
+ import { definePlugin } from '@fastly/compute-js-static-publish/hono';
1332
1350
  import { except } from 'hono/combine';
1333
1351
 
1334
- export default defineExtension((app, options, { serveStatic }) => {
1352
+ export default definePlugin((app, options, { serveStatic }) => {
1335
1353
  const notPreview = (c) => c.var.staticPublisher.collectionName == null;
1336
1354
  app.use('/theme/*', except(notPreview,
1337
1355
  serveStatic({ onMissing: 'default' }),
@@ -1344,13 +1362,13 @@ export default defineExtension((app, options, { serveStatic }) => {
1344
1362
 
1345
1363
  With `onMissing: 'default'`, a missing preview gets a normal response of the default collection, with its headers. When the preview is published, the next request gets the file of the preview: `PublisherServer` checks the selected collection before it reads the response cache. These examples are for a `host`, `query`, `cookie`, or `header` source. With a `path` source, the request path has the prefix (for example `/_preview/pr-1/theme/site.css`), so the route `/theme/*` does not match it: add the handler on `*`, and check `c.var.staticPublisher.pathname`, the path without the prefix. `serveStatic()` and `staticResponse()` look up that path.
1346
1364
 
1347
- For example, a module that runs after a login check, and shows the page `/preview-not-found/` of the default collection, with a `404`, when the selected preview is not available. Because it is a module, it can come after the login check, so that a visitor who is not logged in cannot learn which previews exist:
1365
+ For example, a plugin that runs after a login check, and shows the page `/preview-not-found/` of the default collection, with a `404`, when the selected preview is not available. Because it is a plugin, it can come after the login check, so that a visitor who is not logged in cannot learn which previews exist:
1348
1366
 
1349
1367
  ```ts
1350
- // hono-extensions/30-preview-not-found.ts
1351
- import { defineExtension } from '@fastly/compute-js-static-publish/hono';
1368
+ // hono-compose/30-preview-not-found.ts
1369
+ import { definePlugin } from '@fastly/compute-js-static-publish/hono';
1352
1370
 
1353
- export default defineExtension((app, options, { isCollectionAvailable, staticResponse }) => {
1371
+ export default definePlugin((app, options, { isCollectionAvailable, staticResponse }) => {
1354
1372
  app.use('*', async (c, next) => {
1355
1373
  if (await isCollectionAvailable(c)) {
1356
1374
  return next();
@@ -1361,31 +1379,31 @@ export default defineExtension((app, options, { isCollectionAvailable, staticRes
1361
1379
  });
1362
1380
  ```
1363
1381
 
1364
- **`publisherServer` in a module:** the app has one `PublisherServer` for all requests. Use the other helpers where you can: they use the selected collection, and the path without the prefix of a `path` source. In a handler, a module can call these methods of `publisherServer`:
1382
+ **`publisherServer` in a plugin:** the app has one `PublisherServer` for all requests. Use the other helpers where you can: they use the selected collection, and the path without the prefix of a `path` source. In a handler, a plugin can call these methods of `publisherServer`:
1365
1383
 
1366
1384
  - `isCollectionAvailable()`, `serveRequest()`, `serveFallback()`, and `resolveCollection()`.
1367
1385
  - The methods that read the collection of the request: `getServerConfig()`, `getStaticItems()`, `getAssetEntryMap()`, `getMatchingAsset()`, and `testExtendedCache()`. They use the collection of the last `serveRequest()` or `serveFallback()` in the request (also through `serveStatic()` and the other helpers), or of `beginRequest()`, which uses the active collection, not the selected one. If neither ran in the request, call `publisherServer.beginRequest(c.req.raw)` first.
1368
1386
 
1369
1387
  Do not call the `set…()` methods (`setActiveCollectionName()`, `setCollectionSelection()`, `setResponseCache()`, and the others) in a handler: they change the server for all requests. In the phase function, which runs one time when the app starts, they change the configuration of the whole app. Do not call the lower-level methods (`serveAsset()`, `serveCached()`, `serveCachedStreaming()`, `loadAssetVariant()`, `handlePreconditions()`, and `findAcceptEncodingsGroups()`). Use `staticResponse()` and `fallbackResponse()` in their place.
1370
1388
 
1371
- **Bindings** put Fastly resources on `c.env`, as `buildFire()` of `@fastly/hono-fastly-compute` does. A module declares the bindings that it uses in the first argument of `defineExtension()`, and `c.env` in its handlers has their types, for example `ConfigStore | undefined` for `'ConfigStore:site_config'` (`undefined` if the resource does not exist or is not linked to the service). `templateOptions.hono.bindings` adds bindings for the app. The same name with the same resource in two places is allowed. The same name with two different resources stops the build, and the message names both places. `c.var` is not typed in a module, so that a module can set its own variables.
1389
+ **Bindings** put Fastly resources on `c.env`, as `buildFire()` of `@fastly/hono-fastly-compute` does. A plugin declares the bindings that it uses in the first argument of `definePlugin()`, and `c.env` in its handlers has their types, for example `ConfigStore | undefined` for `'ConfigStore:site_config'` (`undefined` if the resource does not exist or is not linked to the service). `templateOptions.hono.bindings` adds bindings for the app. The same name with the same resource in two places is allowed. The same name with two different resources stops the build, and the message names both places. `c.var` is not typed in a plugin, so that a plugin can set its own variables.
1372
1390
 
1373
- **Errors** in a module stop the build, and the message names the file: a default export that is not `defineExtension()`, an object with no phase, a key that is not a phase, or a phase that is not a function.
1391
+ **Errors** in a plugin stop the build, and the message names the file: a default export that is not `definePlugin()`, an object with no phase, a key that is not a phase, or a phase that is not a function.
1374
1392
 
1375
- **The build** bundles the modules into `src/hono-extensions.generated.js` of the app (the `prebuild` [template hook](#-template-hooks)). The packages that the app provides stay imports, so that the app has one copy of each: the dependencies of the app (for example `hono` and `@fastly/hono-fastly-compute`), this package, and `fastly:*`. Thus, do not add them to the `dependencies` of the folder. `template init` writes them as peer dependencies in `hono-extensions/package.json`, with the versions that the app has. `npm install` in `hono-extensions/` installs them too, because npm 7 and later install peer dependencies. These copies are only for your editor and the type checker. The build always uses the copies of the app. Install other packages in the folder, and the build bundles them.
1393
+ **The build** bundles the plugins into `src/hono-compose.generated.js` of the app (the `prebuild` [template hook](#-template-hooks)). The packages that the app provides stay imports, so that the app has one copy of each: the dependencies of the app (for example `hono` and `@fastly/hono-fastly-compute`), this package, and `fastly:*`. Thus, do not add them to the `dependencies` of the folder. `template init` writes them as peer dependencies in `hono-compose/package.json`, with the versions that the app has. `npm install` in `hono-compose/` installs them too, because npm 7 and later install peer dependencies. These copies are only for your editor and the type checker. The build always uses the copies of the app. Install other packages in the folder, and the build bundles them.
1376
1394
 
1377
- - `build.hono.extensionsDir` sets another folder, relative to the project file (or to `static-publish.rc.js`). The default is `./hono-extensions`.
1378
- - Without the folder, or without modules, the app has no extensions. `dev` and `deploy` of a managed project then show how to make the folder.
1379
- - In a managed project, the files of the folder (without `node_modules/`) are part of the fingerprint, so a change to a module makes `deploy` deploy again.
1380
- - Keep the code of the extensions in the folder. A module can import a file from outside the folder, and the build bundles it, but a change to that file does not change the fingerprint, and the watcher does not see it.
1395
+ - `build.hono.composeDir` sets another folder, relative to the project file (or to `static-publish.rc.js`). The default is `./hono-compose`.
1396
+ - Without the folder, or without plugins, the app has no plugins. `dev` and `deploy` of a managed project then show how to make the folder.
1397
+ - In a managed project, the files of the folder (without `node_modules/`) are part of the fingerprint, so a change to a plugin makes `deploy` deploy again.
1398
+ - Keep the code of the plugins in the folder. A plugin can import a file from outside the folder, and the build bundles it, but a change to that file does not change the fingerprint, and the watcher does not see it.
1381
1399
 
1382
- **`template init`** makes the folder with `package.json`, `tsconfig.json`, `.gitignore` (for `node_modules/`), and the example. In a folder that exists, it updates only the peer dependencies, and adds the starter files that are missing. It never changes your modules. `--reset` writes the starter files again (it asks first, or needs `--force` with `--non-interactive`). `--check` changes nothing, and fails with `template-init-needed` if the folder is out of date, for example after an upgrade of this package; use it in CI.
1400
+ **`template init`** makes the folder with `package.json`, `tsconfig.json`, `.gitignore` (for `node_modules/`), and the example. In a folder that exists, it updates only the peer dependencies, and adds the starter files that are missing. It never changes your plugins. `--reset` writes the starter files again (it asks first, or needs `--force` with `--non-interactive`). `--check` changes nothing, and fails with `template-init-needed` if the folder is out of date, for example after an upgrade of this package; use it in CI.
1383
1401
 
1384
- **Watch:** `dev -- --watch` (managed) and `npm run dev:watch` (ejected) also watch the extensions folder, also if it does not exist yet. A change in the folder bundles the modules again, and then the Fastly CLI builds and restarts the app. If a module has an error, the watcher shows it and the app keeps the last modules that built.
1402
+ **Watch:** `dev -- --watch` (managed) and `npm run dev:watch` (ejected) also watch the folder of the plugins, also if it does not exist yet. A change in the folder bundles the plugins again, and then the Fastly CLI builds and restarts the app. If a plugin has an error, the watcher shows it and the app keeps the last plugins that built.
1385
1403
 
1386
- **Examples** in [`examples/hono/`](https://github.com/fastly/compute-js-static-publish/tree/beta/8.1/examples/hono) show complete extensions. They are not part of the npm package, and you cannot scaffold an app with them: for a new project, copy the `hono-extensions/` folder of an example into your project, and set it up as the README of the example shows. The README also shows how to add an example to a project that exists.
1404
+ **Examples** in [`examples/hono/`](https://github.com/fastly/compute-js-static-publish/tree/beta/8.1/examples/hono) show complete plugins. They are not part of the npm package, and you cannot scaffold an app with them: for a new project, copy the `hono-compose/` folder of an example into your project, and set it up as the README of the example shows. The README also shows how to add an example to a project that exists.
1387
1405
 
1388
- - [`grip`](https://github.com/fastly/compute-js-static-publish/tree/beta/8.1/examples/hono/grip): realtime streams and Server-Sent Events with Fastly Fanout, and a publish endpoint with a shared key. One module with two phases: the `middleware` phase hands off only `/events/*` to Fanout, and the `beforeFilesRoutes` phase has the endpoints.
1406
+ - [`grip`](https://github.com/fastly/compute-js-static-publish/tree/beta/8.1/examples/hono/grip): realtime streams and Server-Sent Events with Fastly Fanout, and a publish endpoint with a shared key. One plugin with two phases: the `middleware` phase hands off only `/events/*` to Fanout, and the `routes` phase has the endpoints.
1389
1407
  - [`oauth`](https://github.com/fastly/compute-js-static-publish/tree/beta/8.1/examples/hono/oauth): a login with GitHub or Google in front of some paths of the site (`protect`), with a signed session cookie.
1390
1408
 
1391
1409
  Each example takes its secrets from a Secret Store. For `dev`, `managed.fastlyToml` adds a local Secret Store that reads environment variables.
@@ -1659,7 +1677,7 @@ Each object has `schemaVersion` (now `1`). A new field keeps the version. A fiel
1659
1677
  }
1660
1678
  ```
1661
1679
 
1662
- `template.provides` lists the packages that the app of the template provides to the folder of the template (for example `hono-extensions/`), with their versions.
1680
+ `template.provides` lists the packages that the app of the template provides to the folder of the template (for example `hono-compose/`), with their versions.
1663
1681
 
1664
1682
  In an ejected app, `status --json` gives `{ "schemaVersion": 1, "mode": "ejected", "serviceId": "SERVICE_ID" }`.
1665
1683
 
@@ -1693,7 +1711,7 @@ In an ejected app, `status --json` gives `{ "schemaVersion": 1, "mode": "ejected
1693
1711
  | `version-mismatch` | `2` | `managed.staticPublishVersion` is not the version of the CLI that runs |
1694
1712
  | `first-deploy-manual` | `2` | The first deploy of a managed project with S3 storage, with `--non-interactive` |
1695
1713
  | `version-not-published` | `2` | `eject` needs a version of this package that is on npm |
1696
- | `template-init-needed` | `2` | `template init --check`: the folder of the template (for example `hono-extensions/`) is out of date. Run `template init` |
1714
+ | `template-init-needed` | `2` | `template init --check`: the folder of the template (for example `hono-compose/`) is out of date. Run `template init` |
1697
1715
  | `deploy-failed` | `1` | The build or the deploy of the app failed |
1698
1716
  | `failed` | `1` | The operation failed, for example storage cannot be reached |
1699
1717
 
@@ -1713,7 +1731,7 @@ npx @fastly/compute-js-static-publish@beta \
1713
1731
  --root-dir=./public \
1714
1732
  --kv-store-name=<site-content>
1715
1733
 
1716
- # Using S3 storage (BETA)
1734
+ # Using S3 storage
1717
1735
  npx @fastly/compute-js-static-publish@beta \
1718
1736
  --root-dir=./public \
1719
1737
  --storage-mode=s3 \
@@ -1829,7 +1847,7 @@ npx @fastly/compute-js-static-publish@beta publish-content \
1829
1847
  [--verbose]
1830
1848
  ```
1831
1849
 
1832
- Publishes static files from your local root directory into a named collection, in the storage that `static-publish.rc.js` specifies: the Fastly KV Store, S3-compatible storage (BETA), or a local dev directory (`--local`, KV Store mode only).
1850
+ Publishes static files from your local root directory into a named collection, in the storage that `static-publish.rc.js` specifies: the Fastly KV Store, S3-compatible storage, or a local dev directory (`--local`, KV Store mode only).
1833
1851
 
1834
1852
  Before it scans your files, the command lists the files that are already in storage. Files that already exist with the same hash are not compressed or uploaded again. With the KV Store, a file larger than 20 MiB is stored in chunks, and the command uploads a chunk again if the chunk in storage does not have the correct size. Then the command uploads the remaining files in batches.
1835
1853
 
@@ -1842,7 +1860,7 @@ After this process is complete, the PublisherServer object in the Compute applic
1842
1860
  - `--root-dir`: Source directory to read files from (overrides value in `publish-content.config.js`)
1843
1861
  - `--overwrite-existing`: Always upload all files, even if they are already in storage. `--kv-overwrite` is an alias.
1844
1862
  - `--brotli-quality`: Brotli quality for the `br` variants, an integer from 0 to 11. Overrides `brotliQuality` in `publish-content.config.js`. This is useful in CI, where the config file is generated at each run.
1845
- - `--fastly-service-id`: The Fastly Service ID to purge after publishing. The command purges the surrogate key `<publishId>-<collectionName>`, so that the service stops serving cached copies of the collection's settings, index, files, and responses (see [response cache](#️-caching-responses-with-the-core-cache)). If not set, the tool will check:
1863
+ - `--fastly-service-id`: The Fastly Service ID to purge after publishing. The command purges the surrogate key `<publishId>-<collectionName>`, so that the service stops serving cached copies of the collection's settings, index, and responses (see [response cache](#️-caching-responses-with-the-core-cache)). If not set, the tool will check:
1846
1864
  - **`FASTLY_SERVICE_ID` environment variable**
1847
1865
  - `service_id` in `fastly.toml`
1848
1866
 
@@ -1864,7 +1882,7 @@ After this process is complete, the PublisherServer object in the Compute applic
1864
1882
 
1865
1883
  - `--fastly-api-token`: API token to use when publishing. If not set, the tool uses the **`FASTLY_API_TOKEN` environment variable**.
1866
1884
 
1867
- **S3 Storage Options (BETA):**
1885
+ **S3 Storage Options:**
1868
1886
 
1869
1887
  - `--s3-access-key-id`, `--s3-secret-access-key`: Access key ID and secret access key for S3-compatible storage. If not set, the tool will check the `S3_ACCESS_KEY_ID` and `S3_SECRET_ACCESS_KEY` environment variables.
1870
1888
  - `--s3-upload-concurrency`: Number of objects to upload at the same time, from 1 to 256 (default: 64). Each upload keeps its file in memory, so a site with many large files can need a lower value.
@@ -1891,7 +1909,7 @@ This can include expired collection indexes and orphaned content assets.
1891
1909
 
1892
1910
  - `--fastly-api-token`: API token to use when publishing. If not set, the tool uses the **`FASTLY_API_TOKEN` environment variable**.
1893
1911
 
1894
- **S3 Storage Options (BETA):**
1912
+ **S3 Storage Options:**
1895
1913
 
1896
1914
  - `--s3-access-key-id`, `--s3-secret-access-key`: Access key ID and secret access key for S3-compatible storage. If not set, the tool will check the `S3_ACCESS_KEY_ID` and `S3_SECRET_ACCESS_KEY` environment variables.
1897
1915
 
@@ -1910,7 +1928,7 @@ Lists all collections currently published in storage.
1910
1928
 
1911
1929
  - `--fastly-api-token`: API token to use when publishing. If not set, the tool uses the **`FASTLY_API_TOKEN` environment variable**.
1912
1930
 
1913
- **S3 Storage Options (BETA):**
1931
+ **S3 Storage Options:**
1914
1932
 
1915
1933
  - `--s3-access-key-id`, `--s3-secret-access-key`: Access key ID and secret access key for S3-compatible storage. If not set, the tool will check the `S3_ACCESS_KEY_ID` and `S3_SECRET_ACCESS_KEY` environment variables.
1916
1934
 
@@ -1950,7 +1968,7 @@ If a Service ID is found, the command then purges the surrogate key `<publishId>
1950
1968
  - `--fastly-service-id`: The Fastly Service ID to purge after promoting. If not set, the tool checks the `FASTLY_SERVICE_ID` environment variable, then `service_id` in `fastly.toml`. If none is found, the command skips the purge. The purge also needs an API token (see `--fastly-api-token`), also in S3 mode. With `--local`, there is no purge. If the purge fails, the command shows a warning and completes, because the collection is already promoted.
1951
1969
  - `--purge-environment`: The environments to purge: `production` (the default), `staging`, or both, as a comma-separated list. You can also repeat the option.
1952
1970
 
1953
- **S3 Storage Options (BETA):**
1971
+ **S3 Storage Options:**
1954
1972
 
1955
1973
  - `--s3-access-key-id`, `--s3-secret-access-key`: Access key ID and secret access key for S3-compatible storage. If not set, the tool will check the `S3_ACCESS_KEY_ID` and `S3_SECRET_ACCESS_KEY` environment variables.
1956
1974
 
@@ -1980,7 +1998,7 @@ Sets or updates the expiration time of an existing collection.
1980
1998
 
1981
1999
  - `--fastly-api-token`: API token to use when publishing. If not set, the tool uses the **`FASTLY_API_TOKEN` environment variable**.
1982
2000
 
1983
- **S3 Storage Options (BETA):**
2001
+ **S3 Storage Options:**
1984
2002
 
1985
2003
  - `--s3-access-key-id`, `--s3-secret-access-key`: Access key ID and secret access key for S3-compatible storage. If not set, the tool will check the `S3_ACCESS_KEY_ID` and `S3_SECRET_ACCESS_KEY` environment variables.
1986
2004
 
@@ -2011,7 +2029,7 @@ If a Service ID is found, the command then purges the surrogate key `<publishId>
2011
2029
 
2012
2030
  - `--fastly-api-token`: API token to use when publishing. If not set, the tool uses the **`FASTLY_API_TOKEN` environment variable**.
2013
2031
 
2014
- **S3 Storage Options (BETA):**
2032
+ **S3 Storage Options:**
2015
2033
 
2016
2034
  - `--s3-access-key-id`, `--s3-secret-access-key`: Access key ID and secret access key for S3-compatible storage. If not set, the tool will check the `S3_ACCESS_KEY_ID` and `S3_SECRET_ACCESS_KEY` environment variables.
2017
2035
 
package/MIGRATING.md CHANGED
@@ -17,7 +17,7 @@ changing the version of this package. See "Managed and ejected apps" in `README.
17
17
 
18
18
  > [!IMPORTANT]
19
19
  > Managed mode generates the app from a template: `plain` (the default) or `hono`. If you changed `src/index.js` (or
20
- > other files of the app), move your changes into options of the project file, or into Hono extensions (see
20
+ > other files of the app), move your changes into options of the project file, or into plugin modules (see
21
21
  > [An app with changes to `src/index.js`](#an-app-with-changes-to-srcindexjs)), or keep your app ejected.
22
22
 
23
23
  These steps move a project with this layout. Change the paths to match your project:
@@ -103,24 +103,24 @@ my-site/
103
103
  ### An app with changes to `src/index.js`
104
104
 
105
105
  Managed mode generates `src/index.js` again for each build, so your changes to it would be lost. With the `hono`
106
- template, you can keep your code in Hono extensions: modules in the folder `hono-extensions/`, beside the project file.
107
- The build bundles them into the app. Code that ran before `serveRequest()`, for example a redirect of an old host name,
108
- a login check, or a proxy to another service, goes into a `middleware` or `beforeFilesRoutes` phase. Code that ran when no
109
- file matched, for example a special page for a path, goes into an `afterFilesRoutes` phase. Each module gets its own options,
110
- and declares the Fastly resources that it uses (bindings).
106
+ template, you can keep your code in plugin modules: files in the folder `hono-compose/`, beside the
107
+ project file. The build bundles them into the app. Code that ran before `serveRequest()`, for example a redirect of an old
108
+ host name, a login check, or a proxy to another service, goes into a `middleware` or `routes` phase. Code that ran when no
109
+ file matched, for example a special page for a path, goes into an `afterFilesRoutes` phase. Each plugin gets its own
110
+ options, and declares the Fastly resources that it uses (bindings).
111
111
 
112
112
  1. In step 2, add `template: "hono"` to `managed`.
113
113
  2. In `my-site/`, make the folder, and install its packages:
114
114
 
115
115
  ```sh
116
116
  npx compute-js-static-publish template init
117
- cd hono-extensions
117
+ cd hono-compose
118
118
  npm install
119
119
  ```
120
120
 
121
- 3. Move each part of your code into a module. See "Hono extensions" in `README.md` for the phases, the options, and
122
- the bindings, and `examples/hono/` in the repository for two complete examples.
123
- 4. Continue with step 3 above. `dev` and `deploy` build the app with your modules.
121
+ 3. Move each part of your code into a plugin. See "Composing plugin modules" in `README.md` for the phases, the options,
122
+ and the bindings, and `examples/hono/` in the repository for two complete examples.
123
+ 4. Continue with step 3 above. `dev` and `deploy` build the app with your plugins.
124
124
 
125
125
  ## Move from `@fastly/hono-compute-js-static-publish` (8.1)
126
126
 
@@ -160,6 +160,39 @@ Differences of `serveStatic()`:
160
160
  - It serves only `GET` and `HEAD`. For other methods, it calls the next handler.
161
161
  - For previews, use `selectCollection()` with `collectionSelection` in `static-publish.rc.js` (see [Using Hono](./README.md#-using-hono)).
162
162
 
163
+ ## Update the plugins from an earlier beta of 8.1
164
+
165
+ In the betas of 8.1 before 8.1.0-beta.9, plugin modules had other names ("Hono extensions"). Your plugins
166
+ work the same way; only the names change. Each old name stops the build, and the message gives the new name.
167
+
168
+ | Before | Now |
169
+ | --- | --- |
170
+ | The folder `hono-extensions/` | `hono-compose/` |
171
+ | `defineExtension()` (from `@fastly/compute-js-static-publish/hono`) | `definePlugin()` (the same import) |
172
+ | The phase `beforeFiles` or `beforeFilesRoutes` | `routes` |
173
+ | The phase `afterFiles` | `afterFilesRoutes` |
174
+ | The types `ExtensionEnv`, `ExtensionBindings`, `ExtensionPhaseFunction`, `ExtensionHelpers`, `ExtensionEntry` | `PluginEnv`, `PluginBindings`, `PluginPhaseFunction`, `PluginHelpers`, `PluginEntry` |
175
+ | `templateOptions.hono.extensions` | `templateOptions.hono.compose.plugins` |
176
+ | `build.hono.extensionsDir` | `build.hono.composeDir` |
177
+
178
+ 1. Rename the folder: `git mv hono-extensions hono-compose` (in the directory of the project file, or next to
179
+ `compute-js/`).
180
+ 2. In each plugin, change `defineExtension` to `definePlugin`, and the phase names and the types as the table shows.
181
+ 3. In the project file (or in `static-publish.rc.js`), change the keys as the table shows.
182
+ 4. In an ejected app, also update the files of the app, because nothing generates them again:
183
+ - `scripts/template_prebuild.js`, `scripts/template_postinstall.js`, and `scripts/template_watch.js`: the functions
184
+ of `@fastly/compute-js-static-publish/hono/build` are now `bundlePlugins()`, `writePluginsStub()`, and
185
+ `watchPlugins()`, and the constant is `PLUGINS_MANIFEST`;
186
+ - `src/index.ts`: import `plugins` from `./hono-compose.generated.js`, run the phase `routes` in place of
187
+ `beforeFilesRoutes`, read the options from `honoOptions?.compose?.plugins`, and use `p.plugin.phases` in place of
188
+ `e.module.phases`;
189
+ - `src/hono-extensions.generated.d.ts` becomes `src/hono-compose.generated.d.ts` (with `plugins: PluginEntry[]`),
190
+ and `.gitignore` ignores `/src/hono-compose.generated.js`.
191
+
192
+ To see the new files, scaffold a new app with `--template hono` and compare.
193
+
194
+ A managed project gets the new files of the app at the next `dev` or `deploy`.
195
+
163
196
  ## Upgrade from v7 to v8
164
197
 
165
198
  v8 can use the files that v7 published. The storage key layout did not change. v8 also accepts the v7 format of
@@ -261,7 +294,7 @@ To stop using `publicDirPrefix`:
261
294
  publish it again. The keys of the files are the hashes of the content, so the CLI does not upload the same files
262
295
  again.
263
296
 
264
- ### Move from the KV Store to S3-compatible storage (BETA)
297
+ ### Move from the KV Store to S3-compatible storage
265
298
 
266
299
  You do not have to move to S3-compatible storage. The KV Store continues to be the default storage mode.
267
300
 
@@ -274,7 +307,7 @@ Thus, to move, you publish your content again into the bucket:
274
307
  2. Copy your changes from your current app into the new app, for example the changes to `src/index.js` and to
275
308
  `publish-content.config.js`. Keep the same `publishId` and `defaultCollectionName`.
276
309
 
277
- 3. Set up the S3 credentials for publishing and for the server. See "Using S3 Compatible Storage (Beta)" in
310
+ 3. Set up the S3 credentials for publishing and for the server. See "Using S3 Compatible Storage" in
278
311
  `README.md`.
279
312
 
280
313
  4. Publish each collection that you need again, from its source files. The collections that are in the KV Store
@@ -284,6 +317,3 @@ Thus, to move, you publish your content again into the bucket:
284
317
 
285
318
  6. When you do not need the KV Store content, delete it. Before you do this, make sure that no service version
286
319
  that is active or staged uses that KV Store.
287
-
288
- > [!NOTE]
289
- > S3-compatible storage is in beta. The configuration and these steps can change before this feature is stable.