@fastly/compute-js-static-publish 3.5.0 → 4.0.0-alpha.0
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.
- package/README.md +440 -103
- package/build/assets/asset-manager.d.ts +7 -0
- package/build/assets/asset-manager.d.ts.map +1 -0
- package/build/assets/asset-manager.js +11 -0
- package/build/assets/content-assets.d.ts +29 -0
- package/build/assets/content-assets.d.ts.map +1 -0
- package/build/assets/content-assets.js +88 -0
- package/build/assets/module-assets.d.ts +23 -0
- package/build/assets/module-assets.d.ts.map +1 -0
- package/build/assets/module-assets.js +45 -0
- package/build/cli/build-static.d.ts.map +1 -0
- package/build/cli/build-static.js +524 -0
- package/build/cli/clean-object-store.d.ts +2 -0
- package/build/cli/clean-object-store.d.ts.map +1 -0
- package/build/cli/cli.d.ts.map +1 -0
- package/build/{cli.js → cli/cli.js} +0 -0
- package/build/cli/commands/build-static.d.ts +3 -0
- package/build/cli/commands/build-static.d.ts.map +1 -0
- package/build/cli/commands/build-static.js +501 -0
- package/build/cli/commands/clean-object-store.d.ts +3 -0
- package/build/cli/commands/clean-object-store.d.ts.map +1 -0
- package/build/cli/commands/clean-object-store.js +54 -0
- package/build/cli/commands/init-app.d.ts.map +1 -0
- package/build/cli/commands/init-app.js +559 -0
- package/build/cli/compression/brotli.d.ts +3 -0
- package/build/cli/compression/brotli.d.ts.map +1 -0
- package/build/cli/compression/brotli.js +15 -0
- package/build/cli/compression/gzip.d.ts +3 -0
- package/build/cli/compression/gzip.d.ts.map +1 -0
- package/build/cli/compression/gzip.js +15 -0
- package/build/cli/compression/index.d.ts +8 -0
- package/build/cli/compression/index.d.ts.map +1 -0
- package/build/cli/compression/index.js +12 -0
- package/build/cli/index.d.ts +3 -0
- package/build/cli/index.d.ts.map +1 -0
- package/build/cli/index.js +86 -0
- package/build/cli/init-app.d.ts +3 -0
- package/build/cli/init-app.d.ts.map +1 -0
- package/build/{init-app.js → cli/init-app.js} +16 -16
- package/build/cli/load-config.d.ts +3 -0
- package/build/cli/load-config.d.ts.map +1 -0
- package/build/cli/load-config.js +357 -0
- package/build/cli/presets/implementations/create-react-app.d.ts +11 -0
- package/build/cli/presets/implementations/create-react-app.d.ts.map +1 -0
- package/build/cli/presets/implementations/create-react-app.js +34 -0
- package/build/cli/presets/implementations/docusaurus.d.ts +7 -0
- package/build/cli/presets/implementations/docusaurus.d.ts.map +1 -0
- package/build/cli/presets/implementations/docusaurus.js +13 -0
- package/build/cli/presets/implementations/gatsby.d.ts +7 -0
- package/build/cli/presets/implementations/gatsby.d.ts.map +1 -0
- package/build/cli/presets/implementations/gatsby.js +13 -0
- package/build/cli/presets/implementations/next.d.ts +7 -0
- package/build/cli/presets/implementations/next.d.ts.map +1 -0
- package/build/cli/presets/implementations/next.js +13 -0
- package/build/cli/presets/implementations/sveltekit.d.ts +7 -0
- package/build/cli/presets/implementations/sveltekit.d.ts.map +1 -0
- package/build/cli/presets/implementations/sveltekit.js +13 -0
- package/build/cli/presets/implementations/vite.d.ts +7 -0
- package/build/cli/presets/implementations/vite.d.ts.map +1 -0
- package/build/cli/presets/implementations/vite.js +13 -0
- package/build/cli/presets/index.d.ts +3 -0
- package/build/cli/presets/index.d.ts.map +1 -0
- package/build/cli/presets/index.js +16 -0
- package/build/cli/presets/preset-base.d.ts +19 -0
- package/build/cli/presets/preset-base.d.ts.map +1 -0
- package/build/cli/util/data.d.ts +7 -0
- package/build/cli/util/data.d.ts.map +1 -0
- package/build/cli/util/data.js +58 -0
- package/build/cli/util/fastly-api.d.ts +10 -0
- package/build/cli/util/fastly-api.d.ts.map +1 -0
- package/build/cli/util/fastly-api.js +47 -0
- package/build/cli/util/files.d.ts +11 -0
- package/build/cli/util/files.d.ts.map +1 -0
- package/build/cli/util/files.js +33 -0
- package/build/cli/util/hash.d.ts +2 -0
- package/build/cli/util/hash.d.ts.map +1 -0
- package/build/cli/util/hash.js +8 -0
- package/build/cli/util/id.d.ts +3 -0
- package/build/cli/util/id.d.ts.map +1 -0
- package/build/cli/util/id.js +17 -0
- package/build/cli/util/object-store.d.ts +16 -0
- package/build/cli/util/object-store.d.ts.map +1 -0
- package/build/cli/util/object-store.js +108 -0
- package/build/cli/util/publish-id.d.ts +5 -0
- package/build/cli/util/publish-id.d.ts.map +1 -0
- package/build/cli/util/publish-id.js +26 -0
- package/build/constants/compression.d.ts +3 -0
- package/build/constants/compression.d.ts.map +1 -0
- package/build/constants/compression.js +4 -0
- package/build/index.d.ts +5 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +5 -1
- package/build/presets/implementations/create-react-app.js +1 -2
- package/build/presets/preset-base.d.ts +1 -1
- package/build/presets/preset-base.d.ts.map +1 -1
- package/build/server/assets/asset-manager.d.ts +7 -0
- package/build/server/assets/asset-manager.d.ts.map +1 -0
- package/build/server/assets/asset-manager.js +11 -0
- package/build/server/assets/content-assets.d.ts +33 -0
- package/build/server/assets/content-assets.d.ts.map +1 -0
- package/build/server/assets/content-assets.js +135 -0
- package/build/server/assets/module-assets.d.ts +23 -0
- package/build/server/assets/module-assets.d.ts.map +1 -0
- package/build/server/assets/module-assets.js +45 -0
- package/build/server/object-store/include-bytes-store-entry.d.ts +19 -0
- package/build/server/object-store/include-bytes-store-entry.d.ts.map +1 -0
- package/build/server/object-store/include-bytes-store-entry.js +87 -0
- package/build/server/object-store/inline-store-entry.d.ts +23 -0
- package/build/server/object-store/inline-store-entry.d.ts.map +1 -0
- package/build/server/object-store/inline-store-entry.js +95 -0
- package/build/server/publisher-server.d.ts +23 -0
- package/build/server/publisher-server.d.ts.map +1 -0
- package/build/server/publisher-server.js +224 -0
- package/build/server/serve-preconditions/if-modified-since.d.ts +4 -0
- package/build/server/serve-preconditions/if-modified-since.d.ts.map +1 -0
- package/build/server/serve-preconditions/if-modified-since.js +26 -0
- package/build/server/serve-preconditions/if-none-match.d.ts +3 -0
- package/build/server/serve-preconditions/if-none-match.d.ts.map +1 -0
- package/build/server/serve-preconditions/if-none-match.js +24 -0
- package/build/server/util/http.d.ts +2 -0
- package/build/server/util/http.d.ts.map +1 -0
- package/build/server/util/http.js +9 -0
- package/build/types/compute.d.ts +10 -0
- package/build/types/compute.d.ts.map +1 -0
- package/build/types/compute.js +1 -0
- package/build/types/config-normalized.d.ts +33 -0
- package/build/types/config-normalized.d.ts.map +1 -0
- package/build/types/config-normalized.js +1 -0
- package/build/types/config.d.ts +36 -0
- package/build/types/config.d.ts.map +1 -0
- package/build/types/config.js +1 -0
- package/build/types/content-assets.d.ts +37 -0
- package/build/types/content-assets.d.ts.map +1 -0
- package/build/types/content-assets.js +1 -0
- package/build/types/content-types.d.ts +11 -0
- package/build/types/content-types.d.ts.map +1 -0
- package/build/types/content-types.js +1 -0
- package/build/types/index.d.ts +7 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/index.js +1 -0
- package/build/types/module-assets.d.ts +15 -0
- package/build/types/module-assets.d.ts.map +1 -0
- package/build/types/module-assets.js +1 -0
- package/build/types/util.d.ts +7 -0
- package/build/types/util.d.ts.map +1 -0
- package/build/types/util.js +1 -0
- package/build/util/content-types.d.ts +5 -0
- package/build/util/content-types.d.ts.map +1 -0
- package/build/util/content-types.js +92 -0
- package/build/util/data.d.ts +7 -0
- package/build/util/data.d.ts.map +1 -0
- package/build/util/data.js +58 -0
- package/build/util/fastly-api.d.ts +10 -0
- package/build/util/fastly-api.d.ts.map +1 -0
- package/build/util/fastly-api.js +47 -0
- package/build/util/files.d.ts +10 -0
- package/build/util/files.d.ts.map +1 -0
- package/build/util/files.js +32 -0
- package/build/util/hash.d.ts +2 -0
- package/build/util/hash.d.ts.map +1 -0
- package/build/util/hash.js +8 -0
- package/build/util/id.d.ts +3 -0
- package/build/util/id.d.ts.map +1 -0
- package/build/util/id.js +17 -0
- package/build/util/index.d.ts +3 -0
- package/build/util/index.d.ts.map +1 -0
- package/build/util/index.js +2 -0
- package/build/util/metadata.d.ts +3 -0
- package/build/util/metadata.d.ts.map +1 -0
- package/build/util/metadata.js +12 -0
- package/build/util/object-store.d.ts +12 -0
- package/build/util/object-store.d.ts.map +1 -0
- package/build/util/object-store.js +80 -0
- package/package.json +11 -6
- package/resources/index.js +9 -114
- package/resources/statics-metadata.d.ts +10 -0
- package/resources/statics.d.ts +15 -7
- package/resources/webpack.config.js +4 -10
- package/build/assets.d.ts +0 -8
- package/build/assets.d.ts.map +0 -1
- package/build/assets.js +0 -24
- package/build/build-static.d.ts.map +0 -1
- package/build/build-static.js +0 -249
- package/build/cli.d.ts.map +0 -1
- package/build/init-app.d.ts.map +0 -1
- package/build/static-assets.d.ts +0 -11
- package/build/static-assets.d.ts.map +0 -1
- package/build/static-assets.js +0 -33
- package/build/types.d.ts +0 -50
- package/build/types.d.ts.map +0 -1
- package/resources/default-content-types.cjs +0 -105
- /package/build/{build-static.d.ts → cli/build-static.d.ts} +0 -0
- /package/build/{content-types.js → cli/clean-object-store.js} +0 -0
- /package/build/{cli.d.ts → cli/cli.d.ts} +0 -0
- /package/build/{init-app.d.ts → cli/commands/init-app.d.ts} +0 -0
- /package/build/{types.js → cli/presets/preset-base.js} +0 -0
package/README.md
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
|
+
PRO TIP - If you are viewing this README in GitHub, click the hamburger menu on the row right above this to see a Table
|
|
2
|
+
of Contents!
|
|
3
|
+
|
|
1
4
|
# Static Publisher for JavaScript on Compute@Edge
|
|
2
5
|
|
|
3
6
|
Using a static site generator to build your website? Do you simply need to serve some static files? With `compute-js-static-publish`, now you can deploy and serve everything from Fastly's blazing-fast [Compute@Edge](https://developer.fastly.com/learning/compute/).
|
|
4
7
|
|
|
5
|
-
##
|
|
8
|
+
## New! Version 4
|
|
9
|
+
|
|
10
|
+
Version 4 of this tool has some awesome new features:
|
|
11
|
+
- Support for optionally serving files from Fastly's [Object Store](https://www.fastly.com/blog/introducing-the-compute-edge-object-store-global-persistent-storage-for-compute-functions) instead of bundling them into the Wasm module. See [Object Store](#object-store) below for more information.
|
|
12
|
+
- Your scaffolded application no longer uses a bundler by default, making the use of Webpack optional
|
|
13
|
+
- Brotli and Gzip compression
|
|
14
|
+
- Support for returning `304 Not Modified` status based on `If-None-Match` and `If-Modified-Since` request headers
|
|
15
|
+
- `PublisherServer` class to map incoming requests to asset paths
|
|
16
|
+
- Ability to include files in the publishing that won't necessarily be served by `PublisherServer`. The content of these files are available to your application and may be useful for reading data written by third-party tools, etc.
|
|
17
|
+
- Makes content and metadata available to your application, giving your applications access to their content by their pre-package path/file
|
|
18
|
+
- Even load JavaScript files as code into your Compute@Edge JavaScript application
|
|
19
|
+
|
|
20
|
+
If you wish to update to this version, you may need to re-scaffold your application, or follow the migrations steps outlined in [MIGRATING.md](./MIGRATING.md).
|
|
6
21
|
|
|
7
|
-
|
|
8
|
-
|
|
22
|
+
## Prerequisites
|
|
23
|
+
|
|
24
|
+
Node 18 or newer is required during the build step, as we now rely on its `experimental-fetch` feature.
|
|
9
25
|
|
|
10
26
|
## How it works
|
|
11
27
|
|
|
@@ -16,10 +32,14 @@ Assuming the root of your output directory is `./public`,
|
|
|
16
32
|
### 1. Run `compute-js-static-publish`
|
|
17
33
|
|
|
18
34
|
```shell
|
|
19
|
-
npx @fastly/compute-js-static-publish@latest --
|
|
35
|
+
npx @fastly/compute-js-static-publish@latest --root-dir=./public
|
|
20
36
|
```
|
|
21
37
|
|
|
22
|
-
|
|
38
|
+
This will generate a Compute@Edge application at `./compute-js`. It will add a default `./src/index.js` file that instantiates the `PublisherServer` class and runs it to serve the static files from your project.
|
|
39
|
+
|
|
40
|
+
> This process creates a `./static-publish.rc.js` to hold your configuration. This, as well as the other files created in your new Compute@Edge program at `./compute-js`, can be committed to source control (except for the ones we specify in `.gitignore`!)
|
|
41
|
+
|
|
42
|
+
Now, each time you build this Compute@Edge project, `compute-js-static-publish` will re-scan your `./public` directory and regenerate `/src/statics-metadata.js` and `/src/statics.js`. These files hold references to your project's public files.
|
|
23
43
|
|
|
24
44
|
### 2. Test your application using [Fastly's local development server](https://developer.fastly.com/learning/compute/testing/#running-a-local-testing-server)
|
|
25
45
|
|
|
@@ -29,7 +49,9 @@ npm install
|
|
|
29
49
|
fastly compute serve
|
|
30
50
|
```
|
|
31
51
|
|
|
32
|
-
|
|
52
|
+
This will serve your application using the default `PublisherServer()`.
|
|
53
|
+
|
|
54
|
+
However, you can modify `/src/index.js` to add your own processing as you need. This file will not be overwritten after it is created.
|
|
33
55
|
|
|
34
56
|
### 3. When you're ready to go live, [deploy your Compute@Edge service](https://developer.fastly.com/reference/cli/compute/publish/)
|
|
35
57
|
|
|
@@ -37,9 +59,22 @@ The build process will generate a `/src/statics.js` and accompanying `/src/stati
|
|
|
37
59
|
fastly compute publish
|
|
38
60
|
```
|
|
39
61
|
|
|
40
|
-
|
|
62
|
+
## How does it work? Where are the files?
|
|
63
|
+
|
|
64
|
+
Once your application is scaffolded, `@fastly/compute-js-static-publish` integrates into your development process by
|
|
65
|
+
running as part of your build process.
|
|
66
|
+
|
|
67
|
+
The files you have configured to be included (`--root-dir`) are enumerated and prepared. Their contents are included into
|
|
68
|
+
your Wasm binary (or made available via Object Store, if so configured). This process is called "publishing".
|
|
41
69
|
|
|
42
|
-
|
|
70
|
+
Once the files are published, they are available to the other source files in the Compute@Edge application. For example,
|
|
71
|
+
the stock application simply runs the [PublisherServer](#publisherserver) class to serve up these files.
|
|
72
|
+
|
|
73
|
+
For more advanced uses, such as accessing the contents of these file in your own application, see the
|
|
74
|
+
[Using the packaged objects in your own application](#using-published-assets-in-your-own-application) section below.
|
|
75
|
+
|
|
76
|
+
Publishing is meant to run each time before building your Compute@Edge application into a Wasm file.
|
|
77
|
+
If the files in `--root-dir` have changed, then a new set of files will be published.
|
|
43
78
|
|
|
44
79
|
## CLI options
|
|
45
80
|
|
|
@@ -47,26 +82,47 @@ Most arguments are optional, and if provided, override the defaults described be
|
|
|
47
82
|
|
|
48
83
|
```shell
|
|
49
84
|
npx @fastly/compute-js-static-publish \
|
|
50
|
-
--
|
|
51
|
-
--
|
|
85
|
+
--root-dir=./build \
|
|
86
|
+
--root-dir=./build/public \
|
|
87
|
+
--static-dir=./build/public/static \
|
|
52
88
|
--output=./compute-js \
|
|
53
|
-
--spa=./build/
|
|
89
|
+
--spa=./build/spa.html
|
|
54
90
|
```
|
|
55
91
|
|
|
56
|
-
Any configuration options will be written to a `static-publish.rc.js` file
|
|
92
|
+
Any configuration options will be written to a `static-publish.rc.js` file, and used each time you build your Compute@Edge
|
|
93
|
+
application.
|
|
94
|
+
|
|
95
|
+
On subsequent builds of your Compute@Edge application, `compute-js-static-publish` will run with a special flag, `build-static`,
|
|
96
|
+
reading from stored configuration, then scanning the `--public-dir` directory to recreate `./src/statics.js`.
|
|
97
|
+
|
|
98
|
+
Any relative file and directory paths passed at the command line are handled as relative to the current directory.
|
|
99
|
+
|
|
100
|
+
### Publishing options:
|
|
101
|
+
|
|
102
|
+
| Option | Default | Description |
|
|
103
|
+
|------------------|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
104
|
+
| `preset` | (None) | Apply default options from a specified preset. See ["Frameworks and Static Site Generators"](#usage-with-frameworks-and-static-site-generators). |
|
|
105
|
+
| `output` | `./compute-js` | The directory in which to create the Compute@Edge application. |
|
|
106
|
+
| `root-dir` | (None) | **Required**. The root of the directory that contains the files to include in the publishing. All files you wish to include must reside under this root. |
|
|
107
|
+
|
|
108
|
+
### Server options:
|
|
109
|
+
|
|
110
|
+
Used to populate the `server` key under `static-publish.rc.js`.
|
|
57
111
|
|
|
58
|
-
| Option | Default | Description
|
|
59
|
-
|
|
60
|
-
| `
|
|
61
|
-
| `
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
| `
|
|
66
|
-
| `spa` | (None) | Serve this file when the request path does not match known paths – with a `200` status code. Useful for apps that use [client-side routing](https://create-react-app.dev/docs/deployment#serving-apps-with-client-side-routing). |
|
|
67
|
-
| `not-found-page` | `<public-dir>/404.html` | Serve this file when the request path does not match known paths – with a `404` status code. Useful for a custom 404 error page. |
|
|
112
|
+
| Option | Default | Description |
|
|
113
|
+
|------------------|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
114
|
+
| `public-dir` | <root-dir> | The directory that contains your website's public files. |
|
|
115
|
+
| `static-dir` | (None) | Any directories under `--public-dir` that contain the website's static assets that will be served with a very long TTL. You can specify as many such directories as you wish, by listing multiple items. |
|
|
116
|
+
| `auto-ext` | `.html,.htm` | Configuration for automatic file extensions. |
|
|
117
|
+
| `auto-index` | `index.html,index.htm` | Configuration for automatically serving an index file. |
|
|
118
|
+
| `spa` | (None) | Configuration for serving a fallback file for SPA applications. |
|
|
119
|
+
| `not-found-page` | `<public-dir>/404.html` | Configuration for serving a 404 not found file. |
|
|
68
120
|
|
|
69
|
-
|
|
121
|
+
See [PublisherServer](#publisherserver) for more information about these features.
|
|
122
|
+
|
|
123
|
+
For backwards compatibility, if you do not specify a `--root-dir` but you have provided a `--public-dir`, then that value is used for `--root-dir`.
|
|
124
|
+
|
|
125
|
+
Note that the files referenced by `--spa` and `--not-found-page` do not necessarily have to reside inside `--public-dir`.
|
|
70
126
|
|
|
71
127
|
### Fastly service options
|
|
72
128
|
|
|
@@ -79,98 +135,379 @@ These arguments are used to populate the `fastly.toml` and `package.json` files
|
|
|
79
135
|
| `author` | `author` from `package.json`, or `you@example.com` | The author of your Compute@Edge application. |
|
|
80
136
|
| `service-id` | (None) | The ID of an existing Fastly WASM service for your Compute@Edge application. |
|
|
81
137
|
|
|
82
|
-
|
|
83
138
|
## Usage with frameworks and static site generators
|
|
84
139
|
|
|
85
140
|
`compute-js-static-publish` supports preset defaults for a number of frameworks and static site generators:
|
|
86
141
|
|
|
87
|
-
| `--preset` | `--
|
|
88
|
-
|
|
89
|
-
| `cra` (or `create-react-app`) | `./build`
|
|
90
|
-
| `cra-eject` | `./build`
|
|
91
|
-
| `vite` | `./dist`
|
|
92
|
-
| `sveltekit` | `./dist`
|
|
93
|
-
| `next` | `./out`
|
|
94
|
-
| `gatsby` | `./public`
|
|
95
|
-
| `docusaurus` | `./build`
|
|
142
|
+
| `--preset` | `--root-dir` | `--static-dir` | Notes |
|
|
143
|
+
|-------------------------------|--------------|------------------|-------------------------------------------------------------------------------------------------------------------------------------|
|
|
144
|
+
| `cra` (or `create-react-app`) | `./build` | `./build/static` | For apps written using [Create React App](https://create-react-app.dev). Checks for a dependency on `react-scripts`. |
|
|
145
|
+
| `cra-eject` | `./build` | `./build/static` | For apps written using Create React App, but which have since been ejected via `npm run eject`. Does not check for `react-scripts`. |
|
|
146
|
+
| `vite` | `./dist` | (None) | For apps written using [Vite](https://vitejs.dev). |
|
|
147
|
+
| `sveltekit` | `./dist` | (None) | For apps written using [SvelteKit](https://kit.svelte.dev). |
|
|
148
|
+
| `next` | `./out` | (None) | For apps written using [Next.js](https://nextjs.org), using `npm run export`. *1 |
|
|
149
|
+
| `gatsby` | `./public` | (None) | For apps written using [Gatsby](https://www.gatsbyjs.com). |
|
|
150
|
+
| `docusaurus` | `./build` | (None) | For apps written using [Docusaurus](https://docusaurus.io) |
|
|
96
151
|
|
|
97
152
|
You may still override any of these options individually.
|
|
98
153
|
|
|
99
154
|
*1 - For Next.js, consider using `@fastly/next-compute-js`, a Next.js server implementation that allows you to run
|
|
100
155
|
your Next.js application on Compute@Edge.
|
|
101
156
|
|
|
102
|
-
##
|
|
157
|
+
## PublisherServer
|
|
158
|
+
|
|
159
|
+
Publisher Server is a simple yet powerful server that can be used out of the box to serve the files prepared by this tool.
|
|
160
|
+
|
|
161
|
+
This server handles the following automatically:
|
|
162
|
+
|
|
163
|
+
* Maps the path of your request to a path under `--public-dir` and serves the content of the asset
|
|
164
|
+
* Sources the content from the content packaged in the Wasm, or from the Object Store if so configured (see [Object Store](#object-store), below.)
|
|
165
|
+
* Applies long-lived cache headers to files served from `--static-dir` directories. Files under these directories will be cached by the browser for 1 year. (Use versioned or hashed filenames to avoid serving stale assets.)
|
|
166
|
+
* Performs Brotli and gzip compression as requested by the `Accept-Encoding` headers.
|
|
167
|
+
* Provides `Last-Modified` and `ETag` response headers, and uses them with `If-Modified-Since` and `If-None-Match` request headers to produce `304 Not Modified` responses.
|
|
168
|
+
* If an exact match is not found for the request path, applies automatic extensions (e.g., `.html`) and automatic index files (e.g., `index.html`).
|
|
169
|
+
* Can be configured to serve a fallback file for SPA apps. Useful for apps that use [client-side routing](https://create-react-app.dev/docs/deployment#serving-apps-with-client-side-routing).
|
|
170
|
+
* Can be configured to serve a 404 not found file.
|
|
171
|
+
* Returns `null` if nothing matches, so that you can add your own handling if necessary.
|
|
172
|
+
|
|
173
|
+
During initial scaffolding, the configuration based on the command-line parameters and preset are written to your `./static-publisher.rc.js` file under the `server` key.
|
|
174
|
+
|
|
175
|
+
### Configuring PublisherServer
|
|
176
|
+
|
|
177
|
+
You can further configure the server by making modifications to the `server` key under `./static-publisher.rc.js`.
|
|
178
|
+
|
|
179
|
+
| Key | Default | Description |
|
|
180
|
+
|--------------------|--------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
181
|
+
| `publicDirPrefix` | `''` | Prefix to apply to web requests. Effectively, a directory within `rootDir` that is used by the web server to determine the asset to respond with. |
|
|
182
|
+
| `staticItems` | `[]` | A test to apply to item names to decide whether to serve them as "static" files, in other words, with a long TTL. These are used for files that are not expected to change. They can be provided as a string or array of strings. |
|
|
183
|
+
| `compression` | `[ 'br', 'gzip' ]` | If the request contains an `Accept-Encoding` header, they are checked in the order listed in the header for the values listed here. The compression algorithm represented by the first match is applied. |
|
|
184
|
+
| `autoExt` | `[]` | When a file is not found, and it doesn't end in a slash, then try auto-ext: we try to serve a file with the same name post-fixed with the specified strings, tested in the order listed. These are tested before auto-index, if any. |
|
|
185
|
+
| `autoIndex` | `[]` | When a file is not found, then try auto-index: we treat it as a directory, then try to serve a file that has the specified strings, tested in the order listed. |
|
|
186
|
+
| `spaFile` | `null` | Asset key of a content item to serve with a status code of `200` when a GET request comes arrives for an unknown asset, and the Accept header includes text/html. |
|
|
187
|
+
| `notFoundPageFile` | `null` | Asset key of a content item to serve with a status code of `404` when a GET request comes arrives for an unknown asset, and the Accept header includes text/html. |
|
|
188
|
+
|
|
189
|
+
For `staticItems`:
|
|
190
|
+
* Items that contain asterisks are interpreted as glob patterns (for example, `/public/static/**/*.js`)
|
|
191
|
+
* Items that end with a trailing slash are interpreted as a directory name.
|
|
192
|
+
* Items that don't contain asterisks and that do not end in slash are checked for exact match.
|
|
193
|
+
|
|
194
|
+
For `compression`, the following values are allowed:
|
|
195
|
+
* `'br'` - Brotli
|
|
196
|
+
* `'gzip'` - Gzip
|
|
197
|
+
|
|
198
|
+
## Using the Object Store (BETA) <a name="object-store"></a>
|
|
199
|
+
|
|
200
|
+
Starting v4, it's now possible to upload assets to and serve them from the Fastly Object Store.
|
|
201
|
+
|
|
202
|
+
Fastly Object Store is currently part of a [beta release](https://docs.fastly.com/products/fastly-product-lifecycle#beta),
|
|
203
|
+
and to use it you will need to have the feature enabled for your account.
|
|
204
|
+
|
|
205
|
+
To enable the use of Object Store with `@fastly/compute-js-static-publish`, you will need to perform the following steps:
|
|
206
|
+
|
|
207
|
+
* Create a service on Fastly to host your Compute@Edge application. One way to do this would be to simply run `fastly
|
|
208
|
+
compute publish` your application.
|
|
209
|
+
|
|
210
|
+
* Create an Object Store under your Fastly account. At the moment you need to use the Fastly CLI. Once the Object Store
|
|
211
|
+
is created, it must be linked to your Fastly service using the Resources API.
|
|
212
|
+
|
|
213
|
+
```shell
|
|
214
|
+
# Create an object store
|
|
215
|
+
$ curl -i -X POST "https://api.fastly.com/resources/stores/object" -H "Fastly-Key: YOUR_FASTLY_TOKEN" -H "Content-Type: application/json" -H "Accept: application/json" -d '{"name":"example-store"}'
|
|
216
|
+
|
|
217
|
+
# Link the object store to a service
|
|
218
|
+
$ curl -i -X POST "https://api.fastly.com/service/YOUR_FASTLY_SERVICE_ID/version/YOUR_FASTLY_SERVICE_VERSION/resource" -H "Fastly-Key: YOUR_FASTLY_TOKEN" -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -d "name=example-store-service-a&resource_id=YOUR_OBJECT_STORE_ID"
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Object Store API: https://developer.fastly.com/reference/cli/object-store/create/
|
|
222
|
+
|
|
223
|
+
Resources API: https://developer.fastly.com/reference/api/services/resource/
|
|
224
|
+
|
|
225
|
+
* Once the object store is created and linked to your service, add the Object Store's name to your `static-publish.rc.js`
|
|
226
|
+
file under the `objectStore` key.
|
|
227
|
+
|
|
228
|
+
After you have done the above steps, go ahead and build your application as normal. If you use `fastly compute build --verbose`
|
|
229
|
+
(or run `npm run build` directly), you should see output in your logs saying that files are being sent to the Object Store.
|
|
230
|
+
|
|
231
|
+
The `statics-metadata.js` file should now show `"isInline":false` for content assets.
|
|
232
|
+
Your Wasm binary should also be smaller, as the content of the files are no longer inlined in the build artifact.
|
|
233
|
+
You can deploy this and run it from Fastly, and the referenced files will be served from Object Store.
|
|
234
|
+
|
|
235
|
+
You will also see entries in `fastly.toml` that represent the local object store.
|
|
236
|
+
These enable the site to also run correctly when served using the local development environment.
|
|
237
|
+
|
|
238
|
+
### Cleaning unused items from Object Store
|
|
239
|
+
|
|
240
|
+
The files that are uploaded to the Object Store are submitted using keys of the following format:
|
|
241
|
+
|
|
242
|
+
`<publish-id>:<asset-path>_<alg>_<hash>`
|
|
243
|
+
|
|
244
|
+
For example:
|
|
245
|
+
`12345abcde67890ABCDE00:/public/index.html_br_aeed29478691e67f6d5s36b4ded20c17e9eae437614617067a8751882368b965`
|
|
246
|
+
|
|
247
|
+
Using such an object key ensures that whenever the file contents are identical, the same key will be generated.
|
|
248
|
+
This enables to detect whether an unchanged file already exists in the Object Store, avoiding having to re-submit
|
|
249
|
+
files that have not changed. If the file contents have changed, then a new hash is generated. This ensures that
|
|
250
|
+
even during the brief amount of time between deploys, any request served by a prior version will still serve the same
|
|
251
|
+
corresponding previous version of the content.
|
|
252
|
+
|
|
253
|
+
However, this system never deletes files automatically. After many deployments, extraneous files may be left over.
|
|
254
|
+
|
|
255
|
+
`@fastly/compute-js-static-publish` includes a feature to delete these old versions of the files that are no longer being
|
|
256
|
+
used. To run it, type the following command:
|
|
257
|
+
|
|
258
|
+
`npx @fastly/compute-js-static-publish --clean-object-store`
|
|
259
|
+
|
|
260
|
+
It works by scanning `statics-metadata.js` for all currently-used object store keys. Then it enumerates all the existing
|
|
261
|
+
keys in the configured object store and that belong to this application (can do so by narrowing down all keys to the ones
|
|
262
|
+
that begin with the "publish id"). If any of the keys is not in the list of currently-used keys, then a request is made
|
|
263
|
+
to delete that object store entry.
|
|
264
|
+
|
|
265
|
+
And that's it! It should be possible to run this task to clean up once in a while.
|
|
266
|
+
|
|
267
|
+
## Advanced Usages
|
|
268
|
+
|
|
269
|
+
### The `static-publish.rc.js` config file <a name="static-publish-rc"></a>
|
|
270
|
+
|
|
271
|
+
* `rootDir` - All files under this root directory will be included by default in the publishing,
|
|
272
|
+
except for those that are excluded using some of the following features. Files outside this root cannot be
|
|
273
|
+
included in the publishing.
|
|
274
|
+
|
|
275
|
+
* `objectStore` - Set this value to the _name_ of an existing object store to enable uploading of content assets
|
|
276
|
+
to Fastly Object Store. See [Using the Object Store](#using-the-object-store) for more information.
|
|
277
|
+
|
|
278
|
+
* `excludeDirs` - Specifies names of files and directories within `rootDir` to exclude from the publishing. Each entry can
|
|
279
|
+
be a string or a JavaScript `RegExp` object. Every file and directory under `rootDir` is checked against each entry of
|
|
280
|
+
the array by testing its path relative to `rootDir`. The file or directory (included all children) and excluded if the
|
|
281
|
+
condition matches:
|
|
282
|
+
* If a string is specified, then an exact match is checked.
|
|
283
|
+
* If a `RegExp` is specified, then it is tested with the regular expression.
|
|
284
|
+
* If this setting is not set, then the default value is `['./node_modules']`.
|
|
285
|
+
* If you specifically set this to the empty array, then no files are excluded by this mechanism.
|
|
286
|
+
|
|
287
|
+
* `excludeDotfiles` - Unless disabled, will exclude all files and directories (and their children)
|
|
288
|
+
whose names begin with a `'.''`. This is `true` by default.
|
|
289
|
+
|
|
290
|
+
* `includeWellKnown` - Unless disabled, will include a file or directory called `.well-known`
|
|
291
|
+
even if `excludeDotfiles` would normally exclude it. This is `true` by default.
|
|
292
|
+
|
|
293
|
+
* `contentAssetInclusionTest` - Optionally specify a test function that can be run against each enumerated asset during
|
|
294
|
+
the publishing, to determine whether to include the asset as a content asset. For every file, this function is passed
|
|
295
|
+
the [asset key](#asset-keys), as well as its content type (MIME type string). You may return one of three values from
|
|
296
|
+
this function:
|
|
297
|
+
* Boolean `true` - Include the file as a content asset in this publishing. Upload the file to and serve it from the
|
|
298
|
+
Object Store if Object Store mode is enabled, or include the contents of the file in the Wasm binary if Object Store
|
|
299
|
+
mode is not enabled.
|
|
300
|
+
* String `"inline"` - Include the file as a content asset in this publishing. Include the contents of the file in the
|
|
301
|
+
Wasm binary, regardless of whether Object Store mode is enabled.
|
|
302
|
+
* Boolean `false` - Do not include this file as a content asset in this publishing.
|
|
303
|
+
|
|
304
|
+
If you do not provide a function, then every file will be included in this publishing as a content asset, and their
|
|
305
|
+
contents will be uploaded to and served from the Object Store if Object Store mode is enabled, or included in the Wasm
|
|
306
|
+
binary if Object Store mode is not enabled.
|
|
307
|
+
|
|
308
|
+
* `contentCompression` - During the publishing, the tool will pre-generate compressed versions of content assets in these
|
|
309
|
+
formats and make them available to the Publisher Server or your application. Default value is [ 'br' | 'gzip' ].
|
|
103
310
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
*
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
311
|
+
* `moduleAssetInclusionTest` - Optionally specify a test function that can be run against each enumerated asset during
|
|
312
|
+
the publishing, to determine whether to include the asset as a module asset. For every file, this function is passed
|
|
313
|
+
the [asset key](#asset-keys), as well as its content type (MIME type string). You may return one of three values from this function:
|
|
314
|
+
* `true` (boolean) - Include the file as a module asset in this publishing.
|
|
315
|
+
* `"static-import"` (string) - Include the file as a module asset in this publishing, and statically import it. This causes
|
|
316
|
+
any top-level code in these modules to run at application initialization time.
|
|
317
|
+
* `false` (boolean) - Do not include this file as a module asset in this publishing.
|
|
318
|
+
|
|
319
|
+
If you do not provide a function, then no module assets will be included in this publishing.
|
|
320
|
+
|
|
321
|
+
* `contentTypes` - Provide custom content types and/or override them.
|
|
322
|
+
|
|
323
|
+
This tool comes with a set of default content types defined for many common file extensions. This list can be used to
|
|
324
|
+
add to and/or override items in the default list.
|
|
325
|
+
|
|
326
|
+
Content type definitions are checked in the provided order, and if none of them match, the default content types are
|
|
327
|
+
tested afterwards.
|
|
328
|
+
|
|
329
|
+
Provide these as an array of content type definition objects, each with the following keys and values:
|
|
330
|
+
* `test` - a RegExp or function to perform on the asset key. If the test succeeds, then the content asset is considered
|
|
331
|
+
to be of this content type definition.
|
|
332
|
+
* `contentType` - The content type header to apply when serving an asset of this content type definition.
|
|
333
|
+
* `text` - If `true`, this content type definition is considered to contain textual data. This makes `.text()` and `.json()`
|
|
334
|
+
available for calling on store entries. If not specified, this is treated as `false`.
|
|
335
|
+
|
|
336
|
+
> Note that content types are tested at publishing time, not at runtime.
|
|
337
|
+
|
|
338
|
+
* `server` - Configuration of `PublisherServer()`. See the [Configuring PublisherServer](#configuring-publisherserver) section
|
|
339
|
+
above.
|
|
340
|
+
|
|
341
|
+
### Running custom code alongside Publisher Server
|
|
342
|
+
|
|
343
|
+
The generated `./src/index.js` program instantiates the server and simply asks it to respond to a request.
|
|
344
|
+
|
|
345
|
+
You are free to add code to this file.
|
|
346
|
+
|
|
347
|
+
For example, if the server is unable to formulate a response to the request, then it returns `null`. You may add your
|
|
348
|
+
own code to handle these cases, such as to provide custom responses.
|
|
349
|
+
|
|
350
|
+
```js
|
|
351
|
+
import { getServer } from './statics.js';
|
|
352
|
+
const server = getServer();
|
|
353
|
+
|
|
354
|
+
addEventListener("fetch", (event) => event.respondWith(handleRequest(event)));
|
|
355
|
+
async function handleRequest(event) {
|
|
356
|
+
|
|
357
|
+
const response = await server.serveRequest(event.request);
|
|
358
|
+
if (response != null) {
|
|
359
|
+
return response;
|
|
360
|
+
}
|
|
152
361
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
362
|
+
// Do custom things here!
|
|
363
|
+
|
|
364
|
+
return new Response('Not found', { status: 404 });
|
|
365
|
+
}
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### Using published assets in your own application
|
|
369
|
+
|
|
370
|
+
Publishing, as described earlier, is the process of preparing files for inclusion into your application.
|
|
371
|
+
This process also makes metadata available about each of the files that are included, such as its content type, the last
|
|
372
|
+
modified date, the file hash, and so on.
|
|
373
|
+
|
|
374
|
+
The `PublisherServer` class that is used by the default scaffolded application is one simple application of this content
|
|
375
|
+
and metadata. By importing `./statics.js` into your Compute@Edge application, you can just as easily access this
|
|
376
|
+
information about the assets that were included during publishing.
|
|
377
|
+
|
|
378
|
+
> IMPORTANT: Use a static `import` statement, rather than using `await import()` to load `./statics.js`, in order to
|
|
379
|
+
ensure that its top-level code runs during the initialization phase of your Compute@Edge application.
|
|
380
|
+
|
|
381
|
+
#### Assets
|
|
382
|
+
|
|
383
|
+
There are two categories of assets: Content Assets and Module Assets.
|
|
384
|
+
|
|
385
|
+
* A Content Asset is a type of asset where your application or a user of your application is interested in the text or
|
|
386
|
+
binary contents of an asset.
|
|
387
|
+
|
|
388
|
+
The data of each content asset can exist in one of two stores:
|
|
389
|
+
* Inline Store - this is a data store that exists within the Wasm binary.
|
|
390
|
+
* Fastly Object Store - Fastly's distributed edge data store. Data can be placed here without impacting the size of
|
|
391
|
+
your Wasm binary.
|
|
392
|
+
|
|
393
|
+
Your application can stream the contents of these assets to a visitor, or read from the stream itself and access its
|
|
394
|
+
contents.
|
|
395
|
+
|
|
396
|
+
* A Module Asset is a type of asset where your application wants to load the asset as a module, and use it as part of its
|
|
397
|
+
running code. Their contents are actually built at publishing time and their built representation is included in the Wasm
|
|
398
|
+
binary. They can be imported statically at will, and your application is able to execute the code exported by these modules.
|
|
399
|
+
|
|
400
|
+
##### Asset Keys
|
|
401
|
+
|
|
402
|
+
When working with content assets or module assets from your application, they are referenced by their asset key, which
|
|
403
|
+
is the relative path of the file from `rootDir`, including the leading slash.
|
|
404
|
+
|
|
405
|
+
#### Content Assets
|
|
406
|
+
|
|
407
|
+
You can obtain the content assets included in publishing by importing the `contentAssets` object exported from
|
|
408
|
+
`./statics.js`.
|
|
409
|
+
|
|
410
|
+
```js
|
|
411
|
+
import { contentAssets } from './statics';
|
|
412
|
+
|
|
413
|
+
// Obtain a content asset named '/public/index.html'
|
|
414
|
+
const asset = contentAssets.getAsset('/public/index.html');
|
|
415
|
+
|
|
416
|
+
// true if object's data is 'inlined' into Wasm binary
|
|
417
|
+
// false if object's data exists in Fastly Object Store
|
|
418
|
+
const isInline = asset.isInline;
|
|
419
|
+
|
|
420
|
+
// Get the "store entry"
|
|
421
|
+
const storeEntry = await asset.getStoreEntry();
|
|
422
|
+
|
|
423
|
+
storeEntry.contentEncoding; // null, 'br', 'gzip'
|
|
424
|
+
storeEntry.hash; // SHA256 of the contents of the file
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
Regardless of which store these objects come from, they implement the `Body` interface as defined by `@fastly/js-compute`.
|
|
428
|
+
As such, you are able to work with them in the same way to obtain their contents:
|
|
429
|
+
|
|
430
|
+
```js
|
|
431
|
+
storeEntry.body; // ReadableStream<Uint8Array>
|
|
432
|
+
storeEntry.bodyUsed; // true if consumed or distrubed
|
|
433
|
+
|
|
434
|
+
// Get the data as ArrayBuffer, parsed JSON, or string
|
|
435
|
+
// The latter two are only available if the data is a text type
|
|
436
|
+
const arrayBuffer = await storeEntry.arrayBuffer();
|
|
437
|
+
const json = await storeEntry.json();
|
|
438
|
+
const text = await storeEntry.text();
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
Or, if you don't care about the contents but just want to stream it to the visitor, you can pass the `.body` field directly
|
|
442
|
+
to the Response constructor:
|
|
443
|
+
|
|
444
|
+
```js
|
|
445
|
+
const response = new Response(storeEntry.body, { status: 200 });
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
> IMPORTANT: Once a store entry is consumed, its body cannot be read from again. If you need to access the contents of the
|
|
449
|
+
same asset more than once, you may obtain another store entry, as in the following example:
|
|
450
|
+
```js
|
|
451
|
+
import { contentAssets } from './statics';
|
|
452
|
+
const asset = contentAssets.getAsset('/public/index.html');
|
|
453
|
+
const entry1 = await asset.getStoreEntry(); // Get a new store entry
|
|
454
|
+
const json1a = await entry1.json();
|
|
455
|
+
const json1b = await entry1.json(); // Can't do this, the body has already been consumed!
|
|
456
|
+
|
|
457
|
+
const entry2 = await asset.getStoreEntry(); // Get a new store entry for same asset
|
|
458
|
+
const json2a = await entry2.json(); // This will work.
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
#### Module Assets
|
|
462
|
+
|
|
463
|
+
Module assets are useful when an asset includes executable JavaScript code that you may want to execute at runtime.
|
|
464
|
+
|
|
465
|
+
You can obtain the module assets included in publishing by importing the `moduleAssets` object exported from
|
|
466
|
+
`./statics.js`. Keep in mind that by default, no modules are included in `moduleAssets`. If you wish to include module
|
|
467
|
+
assets, you must configure your publishing to include them. See [`moduleAssetInclusionTest` in the `static-publish.rc.js`
|
|
468
|
+
config file](#static-publish-rc) for more details.
|
|
469
|
+
|
|
470
|
+
`/module/hello.js`
|
|
471
|
+
```js
|
|
472
|
+
export function hello() {
|
|
473
|
+
console.log('Hello, World!');
|
|
474
|
+
}
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
```js
|
|
478
|
+
import { moduleAssets } from './statics';
|
|
479
|
+
|
|
480
|
+
// Obtain a module asset named '/module/hello.js'
|
|
481
|
+
const asset = contentAssets.getAsset('/module/hello.js');
|
|
482
|
+
|
|
483
|
+
// Load the module
|
|
484
|
+
const helloModule = await asset.getModule();
|
|
485
|
+
|
|
486
|
+
helloModule.hello(); // Will print "Hello, World!"
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
#### Metadata
|
|
490
|
+
|
|
491
|
+
In some use cases, you may have a use case where you need to know about the files that were included during publishing,
|
|
492
|
+
but not in the context of Compute@Edge. (e.g., a tool that runs in Node.js that performs some maintenance task on assets).
|
|
493
|
+
|
|
494
|
+
You cannot import `./statics.js` from a Node.js application, as it holds dependencies on Compute@Edge.
|
|
495
|
+
|
|
496
|
+
Instead, you can import `./statics-metadata.js`, a companion file that is generated in the same directory. This file
|
|
497
|
+
exposes plain JavaScript objects that contain the metadata about your content assets that were included in the final
|
|
498
|
+
publishing event.
|
|
499
|
+
|
|
500
|
+
See the definition of `ContentAssetMetadataMapEntry` in the [`types/content-assets` file](./src/types/content-assets.ts) for more details.
|
|
501
|
+
|
|
502
|
+
### Using Webpack
|
|
503
|
+
|
|
504
|
+
As of v4, Webpack is no longer required, and by default is no longer part of the default scaffolded application.
|
|
505
|
+
If you wish to use some features of Webpack, you can elect to include Webpack in your generated application by specifying
|
|
506
|
+
`--webpack` at the command line.
|
|
507
|
+
|
|
508
|
+
## Migrating
|
|
509
|
+
|
|
510
|
+
See [MIGRATING.md](./MIGRATING.md).
|
|
174
511
|
|
|
175
512
|
## Issues
|
|
176
513
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare abstract class AssetManager<TAsset> {
|
|
2
|
+
protected readonly assets: Record<string, TAsset>;
|
|
3
|
+
protected constructor();
|
|
4
|
+
setAsset(assetKey: string, asset: TAsset): void;
|
|
5
|
+
getAsset(assetKey: string): TAsset | null;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=asset-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-manager.d.ts","sourceRoot":"","sources":["../../src/assets/asset-manager.ts"],"names":[],"mappings":"AAAA,8BAAsB,YAAY,CAAC,MAAM;IAEvC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAElD,SAAS;IAIT,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAIxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;CAI1C"}
|