Skip to content

Commit 05ec4b9

Browse files
authored
Merge pull request #37 from fastly/kats/v7
Version 7
2 parents 233ef0c + 4728a22 commit 05ec4b9

File tree

92 files changed

+6481
-4248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+6481
-4248
lines changed

CHANGELOG.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,49 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [unreleased]
99

10+
> [!NOTE]
11+
> Breaking release. Every project will need a re-scaffold.
12+
13+
### Added
14+
15+
- Named Collections
16+
- Support for named collections of assets that are managed together and can be individually previewed.
17+
- Expiration trio: --expires-in, --expires-at, --expires-never.
18+
- Collection selector utilities that can be run at the edge code to activate a collection.
19+
- Default collection never expires.
20+
21+
- git-style subcommands
22+
- Actions separated into subcommands, such as `clean`, `publish-content`, and `collections`.
23+
- Dry-run mode (--dry-run) for commands that mutates KV or disk.
24+
25+
- KV Store
26+
- Bytes of assets are stored in the Fastly KV Store.
27+
- Items in the KV Store are keyed by the hash of the file, keeping storage efficient and deduplicated, even across collections.
28+
- Metadata (file sizes, encodings, compression) for static assets is stored in KV Store Item metadata.
29+
- Large-object chunking: files > 20 MB are split into segments behind the scenes and reassembled at read time.
30+
- Upload process has been optimized - files are uploaded in parallel, and are only compressed and uploaded when necessary.
31+
- Automatic retry with exponential back-off when the Fastly KV API rate-limits a burst of uploads.
32+
- Fully supported in the local development environment during development.
33+
- `--local` flag for all management commands. Passing this flag makes the command operate on the local KV Store instead of the Fastly KV Store.
34+
35+
### Changed
36+
37+
- Separate config files:
38+
- `static-publisher.rc.js` now owns behavior that is common to the scaffolded Compute app
39+
- publish-time settings are in `publish-content.config.js`.
40+
41+
- Script names in the scaffold are now grouped by environment: `dev:publish`, `dev:start`, `fastly:publish`, `fastly:deploy`.
42+
43+
- Asset inclusion test renamed to `kvStoreAssetInclusionTest` and now expects a boolean return value.
44+
45+
### Removed / Deprecated
46+
47+
- This tool drops `wasm-inline`, and no longer inlines bytes of assets into the Wasm binary.
48+
49+
- Static files metadata is no longer stored in the Wasm binary,
50+
51+
- This tool drops `moduleAssets`.
52+
1053
## [6.3.0] - 2025-03-19
1154

1255
### Added

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 Fastly, Inc.
3+
Copyright (c) 2025 Fastly, Inc.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

MIGRATING.md

Lines changed: 3 additions & 253 deletions
Original file line numberDiff line numberDiff line change
@@ -5,256 +5,6 @@ are generated during scaffolding. For this reason, it is recommended that you re
55

66
This is straightforward if you're using `compute-js-static-publisher` out-of-the-box. Otherwise, read on.
77

8-
## KV Store
9-
10-
Starting with `v5.0.0`, this tool refers to the KV Store using its finalized product name, "KV Store". References in
11-
code and in configuration that used the previous "Object Store" name have been changed to the new name. If you have
12-
been using the feature, you can take the following steps:
13-
14-
* In your `static-publish.rc.js` file:
15-
* Rename the `objectStore` key to `kvStoreName`. For example, if your KV Store is named `'my-store'`, then change:
16-
```
17-
objectStore: 'my-store'
18-
```
19-
to
20-
```
21-
kvStoreName: 'my-store'
22-
```
23-
24-
* In your `fastly.toml` file, find all lines that pertain to object store entries.
25-
* Such lines may look like this and there may be many:
26-
```toml
27-
[[local_server.object_store.my-store]]
28-
key = "4QEM5nIpyLiNF3wwsbnda5:/404.html_aeed29478691e636b4ded20c17e9eae437614617067a8751882368b965a21bcb"
29-
path = "output/404.html"
30-
```
31-
* Change the `object_store` of these lines to `kv_stores`. For example:
32-
```toml
33-
[[local_server.kv_stores.my-store]]
34-
key = "4QEM5nIpyLiNF3wwsbnda5:/404.html_aeed29478691e636b4ded20c17e9eae437614617067a8751882368b965a21bcb"
35-
path = "output/404.html"
36-
```
37-
38-
## Webpack
39-
40-
Starting with `v4.0.0` of this tool, webpack is no longer required and is disabled by default for new applications. This can simplify development and result in shorter build times.
41-
42-
You may still wish to use webpack if you need some of the features it provides, e.g., the ability to use loaders, asset modules, module replacement, dynamic imports, etc.
43-
44-
To migrate away from using webpack, make the following changes in your `./compute-js` directory:
45-
46-
* First, check your `webpack.config.js` file to make sure you aren't actually depending on any custom webpack features. When you're ready, continue to the next step.
47-
* Delete `webpack.config.js`.
48-
* Modify `static-publish.rc.js`:
49-
* Change the line `module.exports = {` to `const config = {`
50-
* At the end of the file, add `export default config;`
51-
* In your `package.json` file:
52-
* At the top level, add a `"type"` key if one doesn't already exist, with the value `"module"`.
53-
* Under `devDependencies`, remove the `webpack` and `webpack-cli` entries.
54-
* Under `scripts`, modify the `prebuild` script by removing the `&& webpack` at the end
55-
of it.
56-
* Under `scripts`, modify the `build` script by replacing the parameter `./bin/index.js`
57-
with `./src/index.js`.
58-
* In the end, the two scripts should look like this (along with any other scripts you may have):
59-
```json
60-
{
61-
"prebuild": "npx @fastly/compute-js-static-publish --build-static",
62-
"build": "js-compute-runtime ./src/index.js ./bin/main.wasm"
63-
}
64-
```
65-
66-
If you aren't moving away from webpack just yet, check that your `webpack.config.js` is up-to-date. Refer
67-
to the [default `webpack.config.js` in this package](./resources/webpack.config.js) and add your changes,
68-
or modify your configuration file using the following steps:
69-
70-
* To make the resulting bundle easier to debug, it is recommended to set the `devtool` value to `false`.
71-
72-
* The JavaScript SDK automatically adds the named condition `fastly` when resolving dependency packages.
73-
To match the behavior when bundling with webpack, set `resolve.conditionsNames` to the following:
74-
```
75-
resolve: {
76-
conditionNames: [
77-
'fastly',
78-
'...',
79-
],
80-
],
81-
```
82-
83-
* Starting `v3.0.0`, we depend on `v1.0.0` of the `js-compute` library, which provides namespaced exports for Fastly
84-
features. To use them, you'll need to make the following changes to `webpack.config.js`:
85-
86-
* Set the `target` value to `false`.
87-
88-
* The `output` section should look like this:
89-
```
90-
output: {
91-
filename: "index.js",
92-
path: path.resolve(__dirname, "bin"),
93-
chunkFormat: 'commonjs',
94-
library: {
95-
type: 'commonjs',
96-
},
97-
},
98-
```
99-
100-
* Add a new `externals` array to the bottom if it doesn't exist already. Add the following entry:
101-
102-
```javascript
103-
module.exports = {
104-
/* ... other config ... */
105-
externals: [
106-
/^fastly:.*$/,
107-
],
108-
}
109-
```
110-
111-
* Starting `v3.0.0`, we no longer use webpack static assets to include the contents of static files, and instead [use the
112-
`includeBytes` function](https://js-compute-reference-docs.edgecompute.app/docs/fastly:experimental/includeBytes)
113-
to enable more performant loading, as well as a more size-efficient Wasm binary. As a result, the following code can
114-
safely be removed from the `module.rules` array.
115-
116-
```javascript
117-
{
118-
// asset/source exports the source code of the asset.
119-
resourceQuery: /staticText/,
120-
type: "asset/source",
121-
},
122-
{
123-
// asset/inline exports the raw bytes of the asset.
124-
// We base64 encode them here
125-
resourceQuery: /staticBinary/,
126-
type: "asset/inline",
127-
generator: {
128-
/**
129-
* @param {Buffer} content
130-
* @returns {string}
131-
*/
132-
dataUrl: content => {
133-
return content.toString('base64');
134-
},
135-
}
136-
},
137-
```
138-
139-
If you need webpack for a new project you are scaffolding with this site, specify the `--webpack` command-line option
140-
when you scaffold your application, e.g.:
141-
142-
```
143-
npx @fastly/compute-js-static-publish@latest --webpack --root-dir=./public
144-
```
145-
146-
## Removal of Expressly
147-
148-
Previous versions of `@fastly/compute-js-static-publish` used [Expressly](https://expressly.edgecompute.app) to serve
149-
assets. `v4` does away with this dependency and implements its own server in the `PublisherServer`
150-
class.
151-
152-
When using `v4`, you can remove the dependency on Expressly by deleting the `@fastly/expressly` entry from
153-
`dependencies` or `devDependencies`, in your `package.json` file.
154-
155-
If your application depended on Expressly for things like middleware, you will need to make further
156-
changes.
157-
158-
### The entry point `src/index.js`
159-
160-
As of `v4`, the `src/index.js` entry point no longer uses Expressly, and looks like this:
161-
162-
```js
163-
/// <reference types="@fastly/js-compute" />
164-
import { getServer } from './statics.js';
165-
const staticContentServer = getServer();
166-
167-
// eslint-disable-next-line no-restricted-globals
168-
addEventListener("fetch", (event) => event.respondWith(handleRequest(event)));
169-
async function handleRequest(event) {
170-
171-
const response = await staticContentServer.serveRequest(event.request);
172-
if (response != null) {
173-
return response;
174-
}
175-
176-
// Do custom things here!
177-
// Handle API requests, serve non-static responses, etc.
178-
179-
return new Response('Not found', { status: 404 });
180-
}
181-
```
182-
183-
If you've previously made changes to `src/index.js`, you will need to make the equivalent changes in this new format.
184-
185-
## `static-publish.rc.js`
186-
187-
This configuration file has changed in v4, and you may find that some features have stopped working after
188-
upgrading from v3.
189-
190-
* In v3, the configuration object was typed `Config`. In v4, it is now typed with a more descriptive name, `StaticPublisherConfig`.
191-
192-
```js
193-
/** @type {import('@fastly/compute-js-static-publish').StaticPublisherConfig} */
194-
const config = {
195-
rootDir: './public',
196-
// ... and so on
197-
};
198-
```
199-
200-
* A new key, `server`, was added to group configurations that pertain to Publisher Server.
201-
202-
To migrate this file, you'll need to make the following changes:
203-
204-
* `publicDir` - rename this to `rootDir`. All files under this root directory will be included by default in the publishing,
205-
except for those that are excluded using some of the following features.
206-
* `excludeDirs`, `includeDirs`, `excludeTest`, `moduleTest` - In v3, these were used in combination to determine whether
207-
each file would be included in the publishing, and whether files would be included as modules. The interaction between
208-
these four tests was not clearly defined, often having one option exclude files, only to have other options add them
209-
back. In addition, in v3 it was not possible to have a module asset that was not also already a content asset.
210-
In v4, these are more clearly defined. These four options should be rewritten in terms of
211-
`excludeDirs`, `excludeDotFiles`, `includeWellKnown`, `contentAssetInclusionTest`, and `moduleAssetInclusionTest`.
212-
* `staticDirs` - in v4, this was renamed to `staticItems` and moved under the new `server` key.
213-
* `spa` - in v4, this was renamed to `spaFile` and moved under the new `server` key.
214-
* `notFoundPage` - in v4, this was renamed to `notFoundPageFile` and moved under the new `server` key.
215-
* `autoExt` - in v4, this was moved under the new `server` key.
216-
* `autoIndex` - in v4, this was moved under the new `server` key.
217-
* `contentTypes` - This is unchanged.
218-
219-
See [static-publish.rc.js config file](./README.md#static-publish-rc) for a detailed explanation of each of these new values.
220-
221-
* `.gitignore`
222-
223-
Depending on the version of `compute-js-static-publisher` used to scaffold your application, your `.gitignore` file
224-
may have been generated with different entries. Add any of the following entries that may be missing from your
225-
`.gitignore` file:
226-
227-
```gitignore
228-
/src/statics.js
229-
/src/statics.d.ts
230-
/src/statics-metadata.js
231-
/src/statics-metadata.d.ts
232-
/src/static-content
233-
```
234-
235-
* Build scripts
236-
* Various versions of `@fastly/compute-js-static-publish` have specified different build scripts. We recommend the following setup, regardless of the version of `@fastly/compute-js-static-publish` or Fastly CLI.
237-
238-
* The build script listed in `fastly.toml` of your `compute-js` directory should look like this:
239-
```toml
240-
[scripts]
241-
build = "npm run build"
242-
```
243-
244-
* If you're using webpack, then the `scripts` section of `package.json` of your `compute-js` directory should contain
245-
the following items (along with any other scripts):
246-
```json
247-
{
248-
"prebuild": "npx @fastly/compute-js-static-publish --build-static && webpack",
249-
"build": "js-compute-runtime ./bin/index.js ./bin/main.wasm"
250-
}
251-
```
252-
253-
* If you're not using webpack, then the `scripts` section of `package.json` of your `compute-js` directory should
254-
contain the following items (along with any other scripts):
255-
```json
256-
{
257-
"prebuild": "npx @fastly/compute-js-static-publish --build-static",
258-
"build": "js-compute-runtime ./src/index.js ./bin/main.wasm"
259-
}
260-
```
8+
> [!NOTE]
9+
> This document is under construction.
10+
>

0 commit comments

Comments
 (0)