@astrojs/cloudflare 6.2.4 → 6.4.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/dist/index.js +22 -7
- package/package.json +9 -3
- package/.turbo/turbo-build.log +0 -4
- package/CHANGELOG.md +0 -421
- package/src/index.ts +0 -227
- package/src/runtime.ts +0 -28
- package/src/server.advanced.ts +0 -53
- package/src/server.directory.ts +0 -58
- package/src/util.ts +0 -19
- package/test/basics.test.js +0 -32
- package/test/directory.test.js +0 -22
- package/test/fixtures/basics/astro.config.mjs +0 -10
- package/test/fixtures/basics/node_modules/.bin/astro +0 -17
- package/test/fixtures/basics/package.json +0 -9
- package/test/fixtures/basics/src/pages/index.astro +0 -9
- package/test/fixtures/no-output/astro.config.mjs +0 -6
- package/test/fixtures/no-output/node_modules/.bin/astro +0 -17
- package/test/fixtures/no-output/package.json +0 -9
- package/test/fixtures/prerender/astro.config.mjs +0 -7
- package/test/fixtures/prerender/node_modules/.bin/astro +0 -17
- package/test/fixtures/prerender/package.json +0 -9
- package/test/fixtures/prerender/src/pages/index.astro +0 -8
- package/test/fixtures/prerender/src/pages/one.astro +0 -11
- package/test/no-output.test.js +0 -24
- package/test/prerender.test.js +0 -19
- package/test/test-utils.js +0 -62
- package/test/wrangler.toml +0 -4
- package/tsconfig.json +0 -10
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRedirectsFromAstroRoutes } from "@astrojs/underscore-redirects";
|
|
1
2
|
import esbuild from "esbuild";
|
|
2
3
|
import * as fs from "fs";
|
|
3
4
|
import * as os from "os";
|
|
@@ -31,7 +32,8 @@ function createIntegration(args) {
|
|
|
31
32
|
build: {
|
|
32
33
|
client: new URL(`.${config.base}`, config.outDir),
|
|
33
34
|
server: new URL(`.${SERVER_BUILD_FOLDER}`, config.outDir),
|
|
34
|
-
serverEntry: "_worker.mjs"
|
|
35
|
+
serverEntry: "_worker.mjs",
|
|
36
|
+
redirects: false
|
|
35
37
|
}
|
|
36
38
|
});
|
|
37
39
|
},
|
|
@@ -41,7 +43,7 @@ function createIntegration(args) {
|
|
|
41
43
|
_buildConfig = config.build;
|
|
42
44
|
if (config.output === "static") {
|
|
43
45
|
throw new Error(`
|
|
44
|
-
[@astrojs/cloudflare] \`output: "server"\` is required to use this adapter. Otherwise, this adapter is not necessary to deploy a static site to Cloudflare.
|
|
46
|
+
[@astrojs/cloudflare] \`output: "server"\` or \`output: "hybrid"\` is required to use this adapter. Otherwise, this adapter is not necessary to deploy a static site to Cloudflare.
|
|
45
47
|
|
|
46
48
|
`);
|
|
47
49
|
}
|
|
@@ -52,8 +54,8 @@ function createIntegration(args) {
|
|
|
52
54
|
},
|
|
53
55
|
"astro:build:setup": ({ vite, target }) => {
|
|
54
56
|
if (target === "server") {
|
|
55
|
-
vite.resolve
|
|
56
|
-
vite.resolve.alias
|
|
57
|
+
vite.resolve ||= {};
|
|
58
|
+
vite.resolve.alias ||= {};
|
|
57
59
|
const aliases = [{ find: "react-dom/server", replacement: "react-dom/server.browser" }];
|
|
58
60
|
if (Array.isArray(vite.resolve.alias)) {
|
|
59
61
|
vite.resolve.alias = [...vite.resolve.alias, ...aliases];
|
|
@@ -62,11 +64,11 @@ function createIntegration(args) {
|
|
|
62
64
|
vite.resolve.alias[alias.find] = alias.replacement;
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
|
-
vite.ssr
|
|
66
|
-
vite.ssr.target =
|
|
67
|
+
vite.ssr ||= {};
|
|
68
|
+
vite.ssr.target = "webworker";
|
|
67
69
|
}
|
|
68
70
|
},
|
|
69
|
-
"astro:build:done": async ({ pages }) => {
|
|
71
|
+
"astro:build:done": async ({ pages, routes, dir }) => {
|
|
70
72
|
var _a, _b;
|
|
71
73
|
const entryPath = fileURLToPath(new URL(_buildConfig.serverEntry, _buildConfig.server));
|
|
72
74
|
const entryUrl = new URL(_buildConfig.serverEntry, _config.outDir);
|
|
@@ -75,6 +77,7 @@ function createIntegration(args) {
|
|
|
75
77
|
await esbuild.build({
|
|
76
78
|
target: "es2020",
|
|
77
79
|
platform: "browser",
|
|
80
|
+
conditions: ["workerd", "worker", "browser"],
|
|
78
81
|
entryPoints: [entryPath],
|
|
79
82
|
outfile: buildPath,
|
|
80
83
|
allowOverwrite: true,
|
|
@@ -133,6 +136,18 @@ function createIntegration(args) {
|
|
|
133
136
|
staticPathList.push(...redirects);
|
|
134
137
|
}
|
|
135
138
|
}
|
|
139
|
+
const redirectRoutes = routes.filter((r) => r.type === "redirect");
|
|
140
|
+
const trueRedirects = createRedirectsFromAstroRoutes({
|
|
141
|
+
config: _config,
|
|
142
|
+
routes: redirectRoutes,
|
|
143
|
+
dir
|
|
144
|
+
});
|
|
145
|
+
if (!trueRedirects.empty()) {
|
|
146
|
+
await fs.promises.appendFile(
|
|
147
|
+
new URL("./_redirects", _config.outDir),
|
|
148
|
+
trueRedirects.print()
|
|
149
|
+
);
|
|
150
|
+
}
|
|
136
151
|
await fs.promises.writeFile(
|
|
137
152
|
new URL("./_routes.json", _config.outDir),
|
|
138
153
|
JSON.stringify(
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/cloudflare",
|
|
3
3
|
"description": "Deploy your site to Cloudflare Workers/Pages",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.4.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -27,19 +27,25 @@
|
|
|
27
27
|
"./server.directory.js": "./dist/server.directory.js",
|
|
28
28
|
"./package.json": "./package.json"
|
|
29
29
|
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"runtime.d.ts"
|
|
33
|
+
],
|
|
30
34
|
"dependencies": {
|
|
35
|
+
"@astrojs/underscore-redirects": "^0.1.0",
|
|
31
36
|
"esbuild": "^0.17.12",
|
|
32
37
|
"tiny-glob": "^0.2.9"
|
|
33
38
|
},
|
|
34
39
|
"peerDependencies": {
|
|
35
|
-
"astro": "^2.
|
|
40
|
+
"astro": "^2.6.0"
|
|
36
41
|
},
|
|
37
42
|
"devDependencies": {
|
|
38
43
|
"chai": "^4.3.6",
|
|
39
44
|
"cheerio": "^1.0.0-rc.11",
|
|
40
45
|
"mocha": "^9.2.2",
|
|
46
|
+
"slash": "^4.0.0",
|
|
41
47
|
"wrangler": "^2.0.23",
|
|
42
|
-
"astro": "2.
|
|
48
|
+
"astro": "2.6.0",
|
|
43
49
|
"astro-scripts": "0.0.14"
|
|
44
50
|
},
|
|
45
51
|
"scripts": {
|
package/.turbo/turbo-build.log
DELETED
package/CHANGELOG.md
DELETED
|
@@ -1,421 +0,0 @@
|
|
|
1
|
-
# @astrojs/cloudflare
|
|
2
|
-
|
|
3
|
-
## 6.2.4
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- [#6925](https://github.com/withastro/astro/pull/6925) [`d11d18595`](https://github.com/withastro/astro/commit/d11d1859518f9fdc94390aab9be29f8667bb27cb) Thanks [@Yan-Thomas](https://github.com/Yan-Thomas)! - Fix missing code language in Cloudflare README
|
|
8
|
-
|
|
9
|
-
- Updated dependencies [[`a98df9374`](https://github.com/withastro/astro/commit/a98df9374dec65c678fa47319cb1481b1af123e2), [`50975f2ea`](https://github.com/withastro/astro/commit/50975f2ea3a59f9e023cc631a9372c0c7986eec9), [`ebae1eaf8`](https://github.com/withastro/astro/commit/ebae1eaf87f49399036033c673b513338f7d9c42), [`dc062f669`](https://github.com/withastro/astro/commit/dc062f6695ce577dc569781fc0678c903012c336)]:
|
|
10
|
-
- astro@2.3.3
|
|
11
|
-
|
|
12
|
-
## 6.2.3
|
|
13
|
-
|
|
14
|
-
### Patch Changes
|
|
15
|
-
|
|
16
|
-
- [#6222](https://github.com/withastro/astro/pull/6222) [`081b2402c`](https://github.com/withastro/astro/commit/081b2402cfb48b5eb8dbd02664d8af2f7c798edf) Thanks [@AirBorne04](https://github.com/AirBorne04)! - add option to compile unminified code
|
|
17
|
-
|
|
18
|
-
- Updated dependencies [[`b89042553`](https://github.com/withastro/astro/commit/b89042553ec45d5f6bc71747e0f3470ba969e679)]:
|
|
19
|
-
- astro@2.3.2
|
|
20
|
-
|
|
21
|
-
## 6.2.2
|
|
22
|
-
|
|
23
|
-
### Patch Changes
|
|
24
|
-
|
|
25
|
-
- [#6550](https://github.com/withastro/astro/pull/6550) [`2c829fdf6`](https://github.com/withastro/astro/commit/2c829fdf65bcb91485837c9cfb5a3b453c6fccc7) Thanks [@RichiCoder1](https://github.com/RichiCoder1)! - fix `config.base` trimming logic for cloudflare integration `_routes.json` generation
|
|
26
|
-
|
|
27
|
-
- Updated dependencies [[`04dddd783`](https://github.com/withastro/astro/commit/04dddd783da3235aa9ed523d2856adf86b792b5f), [`ea9b3dd72`](https://github.com/withastro/astro/commit/ea9b3dd72b98b3f5a542ca24a275f673faa6c7c5), [`bf024cb34`](https://github.com/withastro/astro/commit/bf024cb3429c5929d98378108230bc946a376b17), [`22955b895`](https://github.com/withastro/astro/commit/22955b895ce4343e282355db64b3a5c1415f3944), [`f413446a8`](https://github.com/withastro/astro/commit/f413446a859e497395b3612e44d1540cc6b9dad7), [`90e5f87d0`](https://github.com/withastro/astro/commit/90e5f87d03215a833bb6ac91f9548670a25ce659), [`388190102`](https://github.com/withastro/astro/commit/3881901028cbb586f5a4de1b4953e2d6730458ab), [`035c0c4df`](https://github.com/withastro/astro/commit/035c0c4df2a623bcc2f2a1cb9e490df35fa29adc), [`f112c12b1`](https://github.com/withastro/astro/commit/f112c12b15dfbb278d66699f54809674dd1bded0), [`689884251`](https://github.com/withastro/astro/commit/68988425119255382f94c983796574050006f003), [`fa132e35c`](https://github.com/withastro/astro/commit/fa132e35c23f2cfe368fd0a7239584a2bc5c4f12), [`f5fddafc2`](https://github.com/withastro/astro/commit/f5fddafc248bb1ef57b7349bfecc25539ae2b5ea), [`283734525`](https://github.com/withastro/astro/commit/28373452503bc6ca88221ffd39a5590e015e4d71), [`66858f1f2`](https://github.com/withastro/astro/commit/66858f1f238a0edf6ded2b0f693bc738785d5aa3), [`6c465e958`](https://github.com/withastro/astro/commit/6c465e958e088ff55e5b895e67c64c0dfd4277a6)]:
|
|
28
|
-
- astro@2.1.4
|
|
29
|
-
|
|
30
|
-
## 6.2.1
|
|
31
|
-
|
|
32
|
-
### Patch Changes
|
|
33
|
-
|
|
34
|
-
- [#6531](https://github.com/withastro/astro/pull/6531) [`4ddf34893`](https://github.com/withastro/astro/commit/4ddf3489384ed53f25df190a3478da44bd38600e) Thanks [@matthewp](https://github.com/matthewp)! - Remove false-positive warnings from Cloudflare's build.
|
|
35
|
-
|
|
36
|
-
Cloudflare includes warnings when it bundles the already-built output from astro.build. Those warnings are mostly due to `"sideEffects": false` packages that are included in the Vite built output because they are marked as external. Rollup will remove unused imports from these packages but will not remove the actual import, causing the false-positive warning.
|
|
37
|
-
|
|
38
|
-
- [#6473](https://github.com/withastro/astro/pull/6473) [`1c3e8f6c3`](https://github.com/withastro/astro/commit/1c3e8f6c3b839087aa51de2e2fb665cd907f2847) Thanks [@RichiCoder1](https://github.com/RichiCoder1)! - fix automatic routes generation not respecting config.base
|
|
39
|
-
|
|
40
|
-
- [#6494](https://github.com/withastro/astro/pull/6494) [`a13e9d7e3`](https://github.com/withastro/astro/commit/a13e9d7e33baccf51e7d4815f99b481ad174bc57) Thanks [@Yan-Thomas](https://github.com/Yan-Thomas)! - Consistency improvements to several package descriptions
|
|
41
|
-
|
|
42
|
-
- Updated dependencies [[`acf78c5e2`](https://github.com/withastro/astro/commit/acf78c5e271ec3d4f589782078e2a2044cc1c391), [`04e624d06`](https://github.com/withastro/astro/commit/04e624d062c6ce385f6293afba26f3942c2290c6), [`cc90d7219`](https://github.com/withastro/astro/commit/cc90d72197e1139195e9545105b9a1d339f38e1b), [`a9a6ae298`](https://github.com/withastro/astro/commit/a9a6ae29812339ea00f3b9afd3de09bd9d3733a9), [`6a7cf0712`](https://github.com/withastro/astro/commit/6a7cf0712da23e2c095f4bc4f2512e618bceb38e), [`bfd67ea74`](https://github.com/withastro/astro/commit/bfd67ea749dbc6ffa7c9a671fcc48bea6c04a075), [`f6eddffa0`](https://github.com/withastro/astro/commit/f6eddffa0414d54767e9f9e1ee5a936b8a20146b), [`c63874090`](https://github.com/withastro/astro/commit/c6387409062f1d7c2afc93319748ad57086837c5), [`d637d1ea5`](https://github.com/withastro/astro/commit/d637d1ea5b347b9c724adc895c9006c696ac8fc8), [`637f9bc72`](https://github.com/withastro/astro/commit/637f9bc728ea7d56fc82a862d761385f0dcd9528), [`77a046e88`](https://github.com/withastro/astro/commit/77a046e886c370b737208574b6934f5a1cf2b177)]:
|
|
43
|
-
- astro@2.1.3
|
|
44
|
-
|
|
45
|
-
## 6.2.0
|
|
46
|
-
|
|
47
|
-
### Minor Changes
|
|
48
|
-
|
|
49
|
-
- [#6213](https://github.com/withastro/astro/pull/6213) [`afbbc4d5b`](https://github.com/withastro/astro/commit/afbbc4d5bfafc1779bac00b41c2a1cb1c90f2808) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Updated compilation settings to disable downlevelling for Node 14
|
|
50
|
-
|
|
51
|
-
### Patch Changes
|
|
52
|
-
|
|
53
|
-
- Updated dependencies [[`fec583909`](https://github.com/withastro/astro/commit/fec583909ab62829dc0c1600e2387979365f2b94), [`b087b83fe`](https://github.com/withastro/astro/commit/b087b83fe266c431fe34a07d5c2293cc4ab011c6), [`694918a56`](https://github.com/withastro/astro/commit/694918a56b01104831296be0c25456135a63c784), [`a20610609`](https://github.com/withastro/astro/commit/a20610609863ae3b48afe96819b8f11ae4f414d5), [`a4a74ab70`](https://github.com/withastro/astro/commit/a4a74ab70cd2aa0d812a1f6b202c4e240a8913bf), [`75921b3cd`](https://github.com/withastro/astro/commit/75921b3cd916d439f6392c487c21532fde35ed13), [`afbbc4d5b`](https://github.com/withastro/astro/commit/afbbc4d5bfafc1779bac00b41c2a1cb1c90f2808)]:
|
|
54
|
-
- astro@2.1.0
|
|
55
|
-
|
|
56
|
-
## 6.1.3
|
|
57
|
-
|
|
58
|
-
### Patch Changes
|
|
59
|
-
|
|
60
|
-
- [#6208](https://github.com/withastro/astro/pull/6208) [`79f49acbe`](https://github.com/withastro/astro/commit/79f49acbe13673bfc27e794bcfae518f38c4a4fe) Thanks [@mfrachet](https://github.com/mfrachet)! - Fix path file that was generated outside the functions folder
|
|
61
|
-
|
|
62
|
-
- Updated dependencies [[`79783fc01`](https://github.com/withastro/astro/commit/79783fc0181153a8e379d3f023422510a7467ead), [`baa2dbb3b`](https://github.com/withastro/astro/commit/baa2dbb3b5678b2bd56fb80df99d386f32e274b7), [`8b7cb64da`](https://github.com/withastro/astro/commit/8b7cb64dadfca93c65d62df54754633d398cb2ed)]:
|
|
63
|
-
- astro@2.0.11
|
|
64
|
-
|
|
65
|
-
## 6.1.2
|
|
66
|
-
|
|
67
|
-
### Patch Changes
|
|
68
|
-
|
|
69
|
-
- [#6075](https://github.com/withastro/astro/pull/6075) [`45b41d98f`](https://github.com/withastro/astro/commit/45b41d98f50dc9f76a5004a8b3346f393f1a6cb6) Thanks [@NachoVazquez](https://github.com/NachoVazquez)! - Uses config root path as location for Cloudflare Pages Functions
|
|
70
|
-
|
|
71
|
-
- Updated dependencies [[`f6fc662c3`](https://github.com/withastro/astro/commit/f6fc662c3c59d164584c6287a930fcd1c9086ee6), [`592386b75`](https://github.com/withastro/astro/commit/592386b75541f3b7f7d95c631f86024b7e2d314d), [`1b591a143`](https://github.com/withastro/astro/commit/1b591a1431b44eacd239ed8f76809916cabca1db), [`bf8d7366a`](https://github.com/withastro/astro/commit/bf8d7366acb57e1b21181cc40fff55a821d8119e), [`ec38a8921`](https://github.com/withastro/astro/commit/ec38a8921f02a275949abcababe1b8afdf8184a2), [`f20a85b64`](https://github.com/withastro/astro/commit/f20a85b642994f240d8c94260fc55ffa1fd14294), [`9f22ac3d0`](https://github.com/withastro/astro/commit/9f22ac3d097ef2cb3b2bbe5343b8a8a49d83425d), [`cee70f5c6`](https://github.com/withastro/astro/commit/cee70f5c6ac9b0d2edc1f8a6f8f5043605576026), [`ac7fb04d6`](https://github.com/withastro/astro/commit/ac7fb04d6b162f28a337918138d5737e2c0fffad), [`d1f5611fe`](https://github.com/withastro/astro/commit/d1f5611febfd020cca4078c71bafe599015edd16), [`2189170be`](https://github.com/withastro/astro/commit/2189170be523f74f244e84ccab22c655219773ce), [`32abe49bd`](https://github.com/withastro/astro/commit/32abe49bd073417b480b1b990f432a837c12eb6f)]:
|
|
72
|
-
- astro@2.0.7
|
|
73
|
-
|
|
74
|
-
## 6.1.1
|
|
75
|
-
|
|
76
|
-
### Patch Changes
|
|
77
|
-
|
|
78
|
-
- [#6046](https://github.com/withastro/astro/pull/6046) [`df3201165`](https://github.com/withastro/astro/commit/df320116528e00ab082396531b4deffbb0707b78) Thanks [@matthewp](https://github.com/matthewp)! - Cloudflare fix for building to directory mode
|
|
79
|
-
|
|
80
|
-
- Updated dependencies [[`41e97158b`](https://github.com/withastro/astro/commit/41e97158ba90d23d346b6e3ff6c7c14b5ecbe903), [`e779c6242`](https://github.com/withastro/astro/commit/e779c6242418d1d4102e683ca5b851b764c89688)]:
|
|
81
|
-
- astro@2.0.4
|
|
82
|
-
|
|
83
|
-
## 6.1.0
|
|
84
|
-
|
|
85
|
-
### Minor Changes
|
|
86
|
-
|
|
87
|
-
- [#5914](https://github.com/withastro/astro/pull/5914) [`088f5194c`](https://github.com/withastro/astro/commit/088f5194c55a6ec15b2eaf2cfb97f9ef45a24a33) Thanks [@AngusMorton](https://github.com/AngusMorton)! - Re-enable streaming in Cloudflare Pages.
|
|
88
|
-
|
|
89
|
-
### Patch Changes
|
|
90
|
-
|
|
91
|
-
- [#5993](https://github.com/withastro/astro/pull/5993) [`9855db676`](https://github.com/withastro/astro/commit/9855db676e61ad616c64382adeaa8c74de05f7e1) Thanks [@matthewp](https://github.com/matthewp)! - Support for prerendering in the Cloudflare integration
|
|
92
|
-
|
|
93
|
-
This fixes prerendering in the Cloudflare adapter. Now any prerendered routes are added to the `_routes.json` config so that the worker script is skipped for those routes.
|
|
94
|
-
|
|
95
|
-
- Updated dependencies [[`b53e0717b`](https://github.com/withastro/astro/commit/b53e0717b7f6b042baaeec7f87999e99c76c031c), [`60b32d585`](https://github.com/withastro/astro/commit/60b32d58565d87e87573eb268408293fc28ec657), [`883e0cc29`](https://github.com/withastro/astro/commit/883e0cc29968d51ed6c7515be035a40b28bafdad), [`dabce6b8c`](https://github.com/withastro/astro/commit/dabce6b8c684f851c3535f8acead06cbef6dce2a), [`aedf23f85`](https://github.com/withastro/astro/commit/aedf23f8582e32a6b94b81ddba9b323831f2b22a)]:
|
|
96
|
-
- astro@2.0.2
|
|
97
|
-
|
|
98
|
-
## 6.0.0
|
|
99
|
-
|
|
100
|
-
### Major Changes
|
|
101
|
-
|
|
102
|
-
- [#5707](https://github.com/withastro/astro/pull/5707) [`5eba34fcc`](https://github.com/withastro/astro/commit/5eba34fcc663def20bdf6e0daad02a6a5472776b) Thanks [@bluwy](https://github.com/bluwy)! - Remove `astro:build:start` backwards compatibility code
|
|
103
|
-
|
|
104
|
-
- [#5806](https://github.com/withastro/astro/pull/5806) [`7572f7402`](https://github.com/withastro/astro/commit/7572f7402238da37de748be58d678fedaf863b53) Thanks [@matthewp](https://github.com/matthewp)! - Make astro a `peerDependency` of integrations
|
|
105
|
-
|
|
106
|
-
This marks `astro` as a `peerDependency` of several packages that are already getting `major` version bumps. This is so we can more properly track the dependency between them and what version of Astro they are being used with.
|
|
107
|
-
|
|
108
|
-
### Patch Changes
|
|
109
|
-
|
|
110
|
-
- Updated dependencies [[`93e633922`](https://github.com/withastro/astro/commit/93e633922c2e449df3bb2357b3683af1d3c0e07b), [`16dc36a87`](https://github.com/withastro/astro/commit/16dc36a870df47a4151a8ed2d91d0bd1bb812458), [`01f3f463b`](https://github.com/withastro/astro/commit/01f3f463bf2918b310d130a9fabbf3ee21d14029), [`e2019be6f`](https://github.com/withastro/astro/commit/e2019be6ffa46fa33d92cfd346f9ecbe51bb7144), [`05caf445d`](https://github.com/withastro/astro/commit/05caf445d4d2728f1010aeb2179a9e756c2fd17d), [`49ab4f231`](https://github.com/withastro/astro/commit/49ab4f231c23b34891c3ee86f4b92bf8d6d267a3), [`a342a486c`](https://github.com/withastro/astro/commit/a342a486c2831461e24e6c2f1ca8a9d3e15477b6), [`8fb28648f`](https://github.com/withastro/astro/commit/8fb28648f66629741cb976bfe34ccd9d8f55661e), [`1f92d64ea`](https://github.com/withastro/astro/commit/1f92d64ea35c03fec43aff64eaf704dc5a9eb30a), [`c2180746b`](https://github.com/withastro/astro/commit/c2180746b4f6d9ef1b6f86924f21f52cc6ab4e63), [`ae8a012a7`](https://github.com/withastro/astro/commit/ae8a012a7b6884a03c50494332ee37b4505c2c3b), [`cf2de5422`](https://github.com/withastro/astro/commit/cf2de5422c26bfdea4c75f76e57b57299ded3e3a), [`ce5c5dbd4`](https://github.com/withastro/astro/commit/ce5c5dbd46afbe738b03600758bf5c35113de522), [`ec09bb664`](https://github.com/withastro/astro/commit/ec09bb6642064dbd7d2f3369afb090363ae18de2), [`665a2c222`](https://github.com/withastro/astro/commit/665a2c2225e42881f5a9550599e8f3fc1deea0b4), [`259a539d7`](https://github.com/withastro/astro/commit/259a539d7d70c783330c797794b15716921629cf), [`f7aa1ec25`](https://github.com/withastro/astro/commit/f7aa1ec25d1584f7abd421903fbef66b1c050e2a), [`4987d6f44`](https://github.com/withastro/astro/commit/4987d6f44cfd0d81d88f21f5c380503403dc1e6a), [`304823811`](https://github.com/withastro/astro/commit/304823811eddd8e72aa1d8e2d39b40ab5cda3565), [`302e0ef8f`](https://github.com/withastro/astro/commit/302e0ef8f5d5232e3348afe680e599f3e537b5c5), [`55cea0a9d`](https://github.com/withastro/astro/commit/55cea0a9d8c8df91a46590fc04a9ac28089b3432), [`dd56c1941`](https://github.com/withastro/astro/commit/dd56c19411b126439b8bc42d681b6fa8c06e8c61), [`9963c6e4d`](https://github.com/withastro/astro/commit/9963c6e4d50c392c3d1ac4492237020f15ccb1de), [`be901dc98`](https://github.com/withastro/astro/commit/be901dc98c4a7f6b5536540aa8f7ba5108e939a0), [`f6cf92b48`](https://github.com/withastro/astro/commit/f6cf92b48317a19a3840ad781b77d6d3cae143bb), [`e818cc046`](https://github.com/withastro/astro/commit/e818cc0466a942919ea3c41585e231c8c80cb3d0), [`8c100a6fe`](https://github.com/withastro/astro/commit/8c100a6fe6cc652c3799d1622e12c2c969f30510), [`116d8835c`](https://github.com/withastro/astro/commit/116d8835ca9e78f8b5e477ee5a3d737b69f80706), [`840412128`](https://github.com/withastro/astro/commit/840412128b00a04515156e92c314a929d6b94f6d), [`1f49cddf9`](https://github.com/withastro/astro/commit/1f49cddf9e9ffc651efc171b2cbde9fbe9e8709d), [`7325df412`](https://github.com/withastro/astro/commit/7325df412107fc0e65cd45c1b568fb686708f723), [`16c7d0bfd`](https://github.com/withastro/astro/commit/16c7d0bfd49d2b9bfae45385f506bcd642f9444a), [`a9c292026`](https://github.com/withastro/astro/commit/a9c2920264e36cc5dc05f4adc1912187979edb0d), [`2a5786419`](https://github.com/withastro/astro/commit/2a5786419599b8674473c699300172b9aacbae2e), [`4a1cabfe6`](https://github.com/withastro/astro/commit/4a1cabfe6b9ef8a6fbbcc0727a0dc6fa300cedaa), [`a8d3e7924`](https://github.com/withastro/astro/commit/a8d3e79246605d252dcddad159e358e2d79bd624), [`fa8c131f8`](https://github.com/withastro/astro/commit/fa8c131f88ef67d14c62f1c00c97ed74d43a80ac), [`64b8082e7`](https://github.com/withastro/astro/commit/64b8082e776b832f1433ed288e6f7888adb626d0), [`c4b0cb8bf`](https://github.com/withastro/astro/commit/c4b0cb8bf2b41887d9106440bb2e70d421a5f481), [`23dc9ea96`](https://github.com/withastro/astro/commit/23dc9ea96a10343852d965efd41fe6665294f1fb), [`63a6ceb38`](https://github.com/withastro/astro/commit/63a6ceb38d88331451dca64d0034c7c58e3d26f1), [`a3a7fc929`](https://github.com/withastro/astro/commit/a3a7fc9298e6d88abb4b7bee1e58f05fa9558cf1), [`52209ca2a`](https://github.com/withastro/astro/commit/52209ca2ad72a30854947dcb3a90ab4db0ac0a6f), [`5fd9208d4`](https://github.com/withastro/astro/commit/5fd9208d447f5ab8909a2188b6c2491a0debd49d), [`5eba34fcc`](https://github.com/withastro/astro/commit/5eba34fcc663def20bdf6e0daad02a6a5472776b), [`899214298`](https://github.com/withastro/astro/commit/899214298cee5f0c975c7245e623c649e1842d73), [`3a00ecb3e`](https://github.com/withastro/astro/commit/3a00ecb3eb4bc44be758c064f2bde6e247e8a593), [`5eba34fcc`](https://github.com/withastro/astro/commit/5eba34fcc663def20bdf6e0daad02a6a5472776b), [`2303f9514`](https://github.com/withastro/astro/commit/2303f95142aa740c99213a098f82b99dd37d74a0), [`1ca81c16b`](https://github.com/withastro/astro/commit/1ca81c16b8b66236e092e6eb6ec3f73f5668421c), [`b66d7195c`](https://github.com/withastro/astro/commit/b66d7195c17a55ea0931bc3744888bd4f5f01ce6)]:
|
|
111
|
-
- astro@2.0.0
|
|
112
|
-
|
|
113
|
-
## 6.0.0-beta.1
|
|
114
|
-
|
|
115
|
-
<details>
|
|
116
|
-
<summary>See changes in 6.0.0-beta.1</summary>
|
|
117
|
-
|
|
118
|
-
### Major Changes
|
|
119
|
-
|
|
120
|
-
- [#5806](https://github.com/withastro/astro/pull/5806) [`7572f7402`](https://github.com/withastro/astro/commit/7572f7402238da37de748be58d678fedaf863b53) Thanks [@matthewp](https://github.com/matthewp)! - Make astro a `peerDependency` of integrations
|
|
121
|
-
|
|
122
|
-
This marks `astro` as a `peerDependency` of several packages that are already getting `major` version bumps. This is so we can more properly track the dependency between them and what version of Astro they are being used with.
|
|
123
|
-
|
|
124
|
-
### Patch Changes
|
|
125
|
-
|
|
126
|
-
- Updated dependencies [[`01f3f463b`](https://github.com/withastro/astro/commit/01f3f463bf2918b310d130a9fabbf3ee21d14029), [`1f92d64ea`](https://github.com/withastro/astro/commit/1f92d64ea35c03fec43aff64eaf704dc5a9eb30a), [`c2180746b`](https://github.com/withastro/astro/commit/c2180746b4f6d9ef1b6f86924f21f52cc6ab4e63), [`ae8a012a7`](https://github.com/withastro/astro/commit/ae8a012a7b6884a03c50494332ee37b4505c2c3b), [`cf2de5422`](https://github.com/withastro/astro/commit/cf2de5422c26bfdea4c75f76e57b57299ded3e3a), [`ec09bb664`](https://github.com/withastro/astro/commit/ec09bb6642064dbd7d2f3369afb090363ae18de2), [`665a2c222`](https://github.com/withastro/astro/commit/665a2c2225e42881f5a9550599e8f3fc1deea0b4), [`f7aa1ec25`](https://github.com/withastro/astro/commit/f7aa1ec25d1584f7abd421903fbef66b1c050e2a), [`302e0ef8f`](https://github.com/withastro/astro/commit/302e0ef8f5d5232e3348afe680e599f3e537b5c5), [`840412128`](https://github.com/withastro/astro/commit/840412128b00a04515156e92c314a929d6b94f6d), [`1f49cddf9`](https://github.com/withastro/astro/commit/1f49cddf9e9ffc651efc171b2cbde9fbe9e8709d), [`4a1cabfe6`](https://github.com/withastro/astro/commit/4a1cabfe6b9ef8a6fbbcc0727a0dc6fa300cedaa), [`c4b0cb8bf`](https://github.com/withastro/astro/commit/c4b0cb8bf2b41887d9106440bb2e70d421a5f481), [`23dc9ea96`](https://github.com/withastro/astro/commit/23dc9ea96a10343852d965efd41fe6665294f1fb), [`63a6ceb38`](https://github.com/withastro/astro/commit/63a6ceb38d88331451dca64d0034c7c58e3d26f1), [`52209ca2a`](https://github.com/withastro/astro/commit/52209ca2ad72a30854947dcb3a90ab4db0ac0a6f), [`2303f9514`](https://github.com/withastro/astro/commit/2303f95142aa740c99213a098f82b99dd37d74a0)]:
|
|
127
|
-
- astro@2.0.0-beta.2
|
|
128
|
-
|
|
129
|
-
</details>
|
|
130
|
-
|
|
131
|
-
## 6.0.0-beta.0
|
|
132
|
-
|
|
133
|
-
<details>
|
|
134
|
-
<summary>See changes in 6.0.0-beta.0</summary>
|
|
135
|
-
|
|
136
|
-
### Major Changes
|
|
137
|
-
|
|
138
|
-
- [#5707](https://github.com/withastro/astro/pull/5707) [`5eba34fcc`](https://github.com/withastro/astro/commit/5eba34fcc663def20bdf6e0daad02a6a5472776b) Thanks [@bluwy](https://github.com/bluwy)! - Remove `astro:build:start` backwards compatibility code
|
|
139
|
-
|
|
140
|
-
### Patch Changes
|
|
141
|
-
|
|
142
|
-
- Updated dependencies [[`e2019be6f`](https://github.com/withastro/astro/commit/e2019be6ffa46fa33d92cfd346f9ecbe51bb7144), [`8fb28648f`](https://github.com/withastro/astro/commit/8fb28648f66629741cb976bfe34ccd9d8f55661e), [`dd56c1941`](https://github.com/withastro/astro/commit/dd56c19411b126439b8bc42d681b6fa8c06e8c61), [`f6cf92b48`](https://github.com/withastro/astro/commit/f6cf92b48317a19a3840ad781b77d6d3cae143bb), [`16c7d0bfd`](https://github.com/withastro/astro/commit/16c7d0bfd49d2b9bfae45385f506bcd642f9444a), [`a9c292026`](https://github.com/withastro/astro/commit/a9c2920264e36cc5dc05f4adc1912187979edb0d), [`5eba34fcc`](https://github.com/withastro/astro/commit/5eba34fcc663def20bdf6e0daad02a6a5472776b), [`5eba34fcc`](https://github.com/withastro/astro/commit/5eba34fcc663def20bdf6e0daad02a6a5472776b)]:
|
|
143
|
-
- astro@2.0.0-beta.0
|
|
144
|
-
|
|
145
|
-
</details>
|
|
146
|
-
|
|
147
|
-
## 5.0.0
|
|
148
|
-
|
|
149
|
-
### Patch Changes
|
|
150
|
-
|
|
151
|
-
- Updated dependencies [[`d85ec7484`](https://github.com/withastro/astro/commit/d85ec7484ce14a4c7d3f480da8f38fcb9aff388f), [`d2960984c`](https://github.com/withastro/astro/commit/d2960984c59af7b60a3ea472c6c58fb00534a8e6), [`31ec84797`](https://github.com/withastro/astro/commit/31ec8479721a1cd65538ec041458c5ffe8f50ee9), [`5ec0f6ed5`](https://github.com/withastro/astro/commit/5ec0f6ed55b0a14a9663a90a03428345baf126bd), [`dced4a8a2`](https://github.com/withastro/astro/commit/dced4a8a2657887ec569860d9862d20f695dc23a), [`6b156dd3b`](https://github.com/withastro/astro/commit/6b156dd3b467884839a571c53114aadf26fa4b0b)]:
|
|
152
|
-
- astro@1.7.0
|
|
153
|
-
|
|
154
|
-
## 4.1.1
|
|
155
|
-
|
|
156
|
-
### Patch Changes
|
|
157
|
-
|
|
158
|
-
- [#5534](https://github.com/withastro/astro/pull/5534) [`fabd9124b`](https://github.com/withastro/astro/commit/fabd9124bd3e654e885054f30e9c0d01eabf0470) Thanks [@bluwy](https://github.com/bluwy)! - Update esbuild dependency
|
|
159
|
-
|
|
160
|
-
- Updated dependencies [[`9082a850e`](https://github.com/withastro/astro/commit/9082a850eef4ab0187fc3bfdd5a377f0c7040070), [`4f7f20616`](https://github.com/withastro/astro/commit/4f7f20616ed2b63f94ebf43bc5fdc1be55062a94), [`05915fec0`](https://github.com/withastro/astro/commit/05915fec01a51f27ab5051644f01e6112ecf06bc), [`1aeabe417`](https://github.com/withastro/astro/commit/1aeabe417077505bc0cdb8d2e47366ddbc616072), [`795f00f73`](https://github.com/withastro/astro/commit/795f00f73c549727e05d5b7bf0e39cce87add4e7), [`2c836b9d1`](https://github.com/withastro/astro/commit/2c836b9d1283a0707128d172e92ee2bba767486c), [`8f3f67c96`](https://github.com/withastro/astro/commit/8f3f67c96aee63be64de77f374293761ff73f6ce)]:
|
|
161
|
-
- astro@1.6.14
|
|
162
|
-
|
|
163
|
-
## 4.1.0
|
|
164
|
-
|
|
165
|
-
### Minor Changes
|
|
166
|
-
|
|
167
|
-
- [#5347](https://github.com/withastro/astro/pull/5347) [`743000cc7`](https://github.com/withastro/astro/commit/743000cc70274a2d2fed01c72e2ac51aa6b876a6) Thanks [@AirBorne04](https://github.com/AirBorne04)! - Now building for Cloudflare directory mode takes advantage of the standard asset handling from Cloudflare Pages, and therefore does not call a function script to deliver static assets anymore.
|
|
168
|
-
Also supports the use of `_routes.json`, `_redirects` and `_headers` files when placed into the `public` folder.
|
|
169
|
-
|
|
170
|
-
### Patch Changes
|
|
171
|
-
|
|
172
|
-
- Updated dependencies [[`936c1e411`](https://github.com/withastro/astro/commit/936c1e411d77c69b2b60a061c54704200716800a), [`4b188132e`](https://github.com/withastro/astro/commit/4b188132ef68f8d9951cec86418ef50bb4df4a96), [`f5ed630bc`](https://github.com/withastro/astro/commit/f5ed630bca05ebbfcc6ac994ced3911e41daedcc)]:
|
|
173
|
-
- astro@1.6.11
|
|
174
|
-
|
|
175
|
-
## 4.0.1
|
|
176
|
-
|
|
177
|
-
### Patch Changes
|
|
178
|
-
|
|
179
|
-
- [#5301](https://github.com/withastro/astro/pull/5301) [`a79a37cad`](https://github.com/withastro/astro/commit/a79a37cad549b21f91599ff86899e456d9dcc7df) Thanks [@bluwy](https://github.com/bluwy)! - Fix environment variables usage in worker output and warn if environment variables are accessedd too early
|
|
180
|
-
|
|
181
|
-
- Updated dependencies [[`88c1bbe3a`](https://github.com/withastro/astro/commit/88c1bbe3a71f85e92f42f13d0f310c6b2a264ade), [`a79a37cad`](https://github.com/withastro/astro/commit/a79a37cad549b21f91599ff86899e456d9dcc7df)]:
|
|
182
|
-
- astro@1.6.5
|
|
183
|
-
|
|
184
|
-
## 4.0.0
|
|
185
|
-
|
|
186
|
-
### Major Changes
|
|
187
|
-
|
|
188
|
-
- [#5290](https://github.com/withastro/astro/pull/5290) [`b2b291d29`](https://github.com/withastro/astro/commit/b2b291d29143703cece0d12c8e74b2e1151d2061) Thanks [@matthewp](https://github.com/matthewp)! - Handle base configuration in adapters
|
|
189
|
-
|
|
190
|
-
This allows adapters to correctly handle `base` configuration. Internally Astro now matches routes when the URL includes the `base`.
|
|
191
|
-
|
|
192
|
-
Adapters now also have access to the `removeBase` method which will remove the `base` from a pathname. This is useful to look up files for static assets.
|
|
193
|
-
|
|
194
|
-
### Patch Changes
|
|
195
|
-
|
|
196
|
-
- Updated dependencies [[`b2b291d29`](https://github.com/withastro/astro/commit/b2b291d29143703cece0d12c8e74b2e1151d2061), [`97e2b6ad7`](https://github.com/withastro/astro/commit/97e2b6ad7a6fa23e82be28b2f57cdf3f85fab112), [`4af4d8fa0`](https://github.com/withastro/astro/commit/4af4d8fa0035130fbf31c82d72777c3679bc1ca5), [`f6add3924`](https://github.com/withastro/astro/commit/f6add3924d5cd59925a6ea4bf7f2f731709bc893), [`247eb7411`](https://github.com/withastro/astro/commit/247eb7411f429317e5cd7d401a6660ee73641313)]:
|
|
197
|
-
- astro@1.6.4
|
|
198
|
-
|
|
199
|
-
## 3.1.2
|
|
200
|
-
|
|
201
|
-
### Patch Changes
|
|
202
|
-
|
|
203
|
-
- [#5230](https://github.com/withastro/astro/pull/5230) [`69a532ab6`](https://github.com/withastro/astro/commit/69a532ab60a85d30c2395969593c4d38f9a2fbbe) Thanks [@matthewp](https://github.com/matthewp)! - Exports new runtime entrypoint's types
|
|
204
|
-
|
|
205
|
-
## 3.1.1
|
|
206
|
-
|
|
207
|
-
### Patch Changes
|
|
208
|
-
|
|
209
|
-
- [#5103](https://github.com/withastro/astro/pull/5103) [`d151d9f3f`](https://github.com/withastro/astro/commit/d151d9f3f29c0a57c59b8029a18717808ccc7f8f) Thanks [@AirBorne04](https://github.com/AirBorne04)! - enable access to Cloudflare runtime [KV, R2, Durable Objects]
|
|
210
|
-
- access native Cloudflare runtime through `import { getRuntime } from "@astrojs/cloudflare/runtime"`; now you can call `getRuntime(Astro.request)` and get access to the runtime environment.
|
|
211
|
-
|
|
212
|
-
## 3.1.0
|
|
213
|
-
|
|
214
|
-
### Minor Changes
|
|
215
|
-
|
|
216
|
-
- [#5056](https://github.com/withastro/astro/pull/5056) [`e55af8a23`](https://github.com/withastro/astro/commit/e55af8a23233b6335f45b7a04b9d026990fb616c) Thanks [@matthewp](https://github.com/matthewp)! - # New build configuration
|
|
217
|
-
|
|
218
|
-
The ability to customize SSR build configuration more granularly is now available in Astro. You can now customize the output folder for `server` (the server code for SSR), `client` (your client-side JavaScript and assets), and `serverEntry` (the name of the entrypoint server module). Here are the defaults:
|
|
219
|
-
|
|
220
|
-
```js
|
|
221
|
-
import { defineConfig } from 'astro/config';
|
|
222
|
-
|
|
223
|
-
export default defineConfig({
|
|
224
|
-
output: 'server',
|
|
225
|
-
build: {
|
|
226
|
-
server: './dist/server/',
|
|
227
|
-
client: './dist/client/',
|
|
228
|
-
serverEntry: 'entry.mjs',
|
|
229
|
-
},
|
|
230
|
-
});
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
These new configuration options are only supported in SSR mode and are ignored when building to SSG (a static site).
|
|
234
|
-
|
|
235
|
-
## Integration hook change
|
|
236
|
-
|
|
237
|
-
The integration hook `astro:build:start` includes a param `buildConfig` which includes all of these same options. You can continue to use this param in Astro 1.x, but it is deprecated in favor of the new `build.config` options. All of the built-in adapters have been updated to the new format. If you have an integration that depends on this param we suggest upgrading to do this instead:
|
|
238
|
-
|
|
239
|
-
```js
|
|
240
|
-
export default function myIntegration() {
|
|
241
|
-
return {
|
|
242
|
-
name: 'my-integration',
|
|
243
|
-
hooks: {
|
|
244
|
-
'astro:config:setup': ({ updateConfig }) => {
|
|
245
|
-
updateConfig({
|
|
246
|
-
build: {
|
|
247
|
-
server: '...',
|
|
248
|
-
},
|
|
249
|
-
});
|
|
250
|
-
},
|
|
251
|
-
},
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
## 3.0.0
|
|
257
|
-
|
|
258
|
-
### Major Changes
|
|
259
|
-
|
|
260
|
-
- [#4888](https://github.com/withastro/astro/pull/4888) [`2dc582ac5`](https://github.com/withastro/astro/commit/2dc582ac5e2d6e1d434ccfe21616182e453feec3) Thanks [@AirBorne04](https://github.com/AirBorne04)! - adjusting the build settings for cloudflare (reverting back to platform browser over neutral)
|
|
261
|
-
adjusting the ssr settings for solidjs (to build for node)
|
|
262
|
-
|
|
263
|
-
## 2.1.0
|
|
264
|
-
|
|
265
|
-
### Minor Changes
|
|
266
|
-
|
|
267
|
-
- [#4876](https://github.com/withastro/astro/pull/4876) [`d3091f89e`](https://github.com/withastro/astro/commit/d3091f89e92fcfe1ad48daca74055d54b1c853a3) Thanks [@matthewp](https://github.com/matthewp)! - Adds the Astro.cookies API
|
|
268
|
-
|
|
269
|
-
`Astro.cookies` is a new API for manipulating cookies in Astro components and API routes.
|
|
270
|
-
|
|
271
|
-
In Astro components, the new `Astro.cookies` object is a map-like object that allows you to get, set, delete, and check for a cookie's existence (`has`):
|
|
272
|
-
|
|
273
|
-
```astro
|
|
274
|
-
---
|
|
275
|
-
type Prefs = {
|
|
276
|
-
darkMode: boolean;
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
Astro.cookies.set<Prefs>(
|
|
280
|
-
'prefs',
|
|
281
|
-
{ darkMode: true },
|
|
282
|
-
{
|
|
283
|
-
expires: '1 month',
|
|
284
|
-
}
|
|
285
|
-
);
|
|
286
|
-
|
|
287
|
-
const prefs = Astro.cookies.get<Prefs>('prefs').json();
|
|
288
|
-
---
|
|
289
|
-
|
|
290
|
-
<body data-theme={prefs.darkMode ? 'dark' : 'light'}></body>
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
Once you've set a cookie with Astro.cookies it will automatically be included in the outgoing response.
|
|
294
|
-
|
|
295
|
-
This API is also available with the same functionality in API routes:
|
|
296
|
-
|
|
297
|
-
```js
|
|
298
|
-
export function post({ cookies }) {
|
|
299
|
-
cookies.set('loggedIn', false);
|
|
300
|
-
|
|
301
|
-
return new Response(null, {
|
|
302
|
-
status: 302,
|
|
303
|
-
headers: {
|
|
304
|
-
Location: '/login',
|
|
305
|
-
},
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
See [the RFC](https://github.com/withastro/rfcs/blob/main/proposals/0025-cookie-management.md) to learn more.
|
|
311
|
-
|
|
312
|
-
## 2.0.0
|
|
313
|
-
|
|
314
|
-
### Major Changes
|
|
315
|
-
|
|
316
|
-
- [#4815](https://github.com/withastro/astro/pull/4815) [`ce0b92ba7`](https://github.com/withastro/astro/commit/ce0b92ba73072c0f0143829a53f870155ad4c7ff) Thanks [@AirBorne04](https://github.com/AirBorne04)! - adjusted esbuild config to work with worker environment (fixing solid js ssr)
|
|
317
|
-
|
|
318
|
-
## 1.0.2
|
|
319
|
-
|
|
320
|
-
### Patch Changes
|
|
321
|
-
|
|
322
|
-
- [#4558](https://github.com/withastro/astro/pull/4558) [`742966456`](https://github.com/withastro/astro/commit/7429664566f05ecebf6d57906f950627e62e690c) Thanks [@tony-sull](https://github.com/tony-sull)! - Adding the `withastro` keyword to include the adapters on the [Integrations Catalog](https://astro.build/integrations)
|
|
323
|
-
|
|
324
|
-
## 1.0.1
|
|
325
|
-
|
|
326
|
-
### Patch Changes
|
|
327
|
-
|
|
328
|
-
- [#4232](https://github.com/withastro/astro/pull/4232) [`bfbd32588`](https://github.com/withastro/astro/commit/bfbd32588f7e2c0a9e43cd1a571a0dc9c5f7e645) Thanks [@Ekwuno](https://github.com/Ekwuno)! - Update README
|
|
329
|
-
|
|
330
|
-
## 1.0.0
|
|
331
|
-
|
|
332
|
-
### Major Changes
|
|
333
|
-
|
|
334
|
-
- [`04ad44563`](https://github.com/withastro/astro/commit/04ad445632c67bdd60c1704e1e0dcbcaa27b9308) - > Astro v1.0 is out! Read the [official announcement post](https://astro.build/blog/astro-1/).
|
|
335
|
-
|
|
336
|
-
**No breaking changes**. This package is now officially stable and compatible with `astro@1.0.0`!
|
|
337
|
-
|
|
338
|
-
## 0.5.0
|
|
339
|
-
|
|
340
|
-
### Minor Changes
|
|
341
|
-
|
|
342
|
-
- [#3806](https://github.com/withastro/astro/pull/3806) [`f4c571bdb`](https://github.com/withastro/astro/commit/f4c571bdb0bbcd0dfed68a484dfbfe274f8a5f45) Thanks [@nrgnrg](https://github.com/nrgnrg)! - add support for compiling functions to a functions directory rather than `_worker.js`
|
|
343
|
-
|
|
344
|
-
## 0.4.0
|
|
345
|
-
|
|
346
|
-
### Minor Changes
|
|
347
|
-
|
|
348
|
-
- [#4068](https://github.com/withastro/astro/pull/4068) [`54b33d50f`](https://github.com/withastro/astro/commit/54b33d50fdb995ac056461be7e2128d911624f2d) Thanks [@matthewp](https://github.com/matthewp)! - Add explicit errors when omitting output config
|
|
349
|
-
|
|
350
|
-
### Patch Changes
|
|
351
|
-
|
|
352
|
-
- [#4072](https://github.com/withastro/astro/pull/4072) [`a198028b0`](https://github.com/withastro/astro/commit/a198028b04234d0b8dcb0b6bcb47c5831d7a15f9) Thanks [@matthewp](https://github.com/matthewp)! - Fixes Cloudflare throwing an error for process
|
|
353
|
-
|
|
354
|
-
## 0.3.0
|
|
355
|
-
|
|
356
|
-
### Minor Changes
|
|
357
|
-
|
|
358
|
-
- [#4015](https://github.com/withastro/astro/pull/4015) [`6fd161d76`](https://github.com/withastro/astro/commit/6fd161d7691cbf9d3ffa4646e46059dfd0940010) Thanks [@matthewp](https://github.com/matthewp)! - New `output` configuration option
|
|
359
|
-
|
|
360
|
-
This change introduces a new "output target" configuration option (`output`). Setting the output target lets you decide the format of your final build, either:
|
|
361
|
-
|
|
362
|
-
- `"static"` (default): A static site. Your final build will be a collection of static assets (HTML, CSS, JS) that you can deploy to any static site host.
|
|
363
|
-
- `"server"`: A dynamic server application. Your final build will be an application that will run in a hosted server environment, generating HTML dynamically for different requests.
|
|
364
|
-
|
|
365
|
-
If `output` is omitted from your config, the default value `"static"` will be used.
|
|
366
|
-
|
|
367
|
-
When using the `"server"` output target, you must also include a runtime adapter via the `adapter` configuration. An adapter will _adapt_ your final build to run on the deployed platform of your choice (Netlify, Vercel, Node.js, Deno, etc).
|
|
368
|
-
|
|
369
|
-
To migrate: No action is required for most users. If you currently define an `adapter`, you will need to also add `output: 'server'` to your config file to make it explicit that you are building a server. Here is an example of what that change would look like for someone deploying to Netlify:
|
|
370
|
-
|
|
371
|
-
```diff
|
|
372
|
-
import { defineConfig } from 'astro/config';
|
|
373
|
-
import netlify from '@astrojs/netlify/functions';
|
|
374
|
-
|
|
375
|
-
export default defineConfig({
|
|
376
|
-
adapter: netlify(),
|
|
377
|
-
+ output: 'server',
|
|
378
|
-
});
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
* [#4018](https://github.com/withastro/astro/pull/4018) [`0cc6ede36`](https://github.com/withastro/astro/commit/0cc6ede362996b9faba57481a790d6eb7fba2045) Thanks [@okikio](https://github.com/okikio)! - Support for 404 and 500 pages in SSR
|
|
382
|
-
|
|
383
|
-
- [#3973](https://github.com/withastro/astro/pull/3973) [`5a23483ef`](https://github.com/withastro/astro/commit/5a23483efb3ba614b05a00064f84415620605204) Thanks [@matthewp](https://github.com/matthewp)! - Adds support for Astro.clientAddress
|
|
384
|
-
|
|
385
|
-
The new `Astro.clientAddress` property allows you to get the IP address of the requested user.
|
|
386
|
-
|
|
387
|
-
```astro
|
|
388
|
-
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
This property is only available when building for SSR, and only if the adapter you are using supports providing the IP address. If you attempt to access the property in a SSG app it will throw an error.
|
|
392
|
-
|
|
393
|
-
## 0.2.4
|
|
394
|
-
|
|
395
|
-
### Patch Changes
|
|
396
|
-
|
|
397
|
-
- [#3885](https://github.com/withastro/astro/pull/3885) [`bf5d1cc1e`](https://github.com/withastro/astro/commit/bf5d1cc1e71da38a14658c615e9481f2145cc6e7) Thanks [@delucis](https://github.com/delucis)! - Integration README fixes
|
|
398
|
-
|
|
399
|
-
## 0.2.3
|
|
400
|
-
|
|
401
|
-
### Patch Changes
|
|
402
|
-
|
|
403
|
-
- [#3854](https://github.com/withastro/astro/pull/3854) [`b012ee55`](https://github.com/withastro/astro/commit/b012ee55b107dea0730286263b27d83e530fad5d) Thanks [@bholmesdev](https://github.com/bholmesdev)! - [astro add] Support adapters and third party packages
|
|
404
|
-
|
|
405
|
-
## 0.2.2
|
|
406
|
-
|
|
407
|
-
### Patch Changes
|
|
408
|
-
|
|
409
|
-
- [#3777](https://github.com/withastro/astro/pull/3777) [`976e1f17`](https://github.com/withastro/astro/commit/976e1f175a95ea39f737b8575e4fdf3c3d89e1ee) Thanks [@tony-sull](https://github.com/tony-sull)! - Disables HTTP streaming in Cloudflare Pages deployments
|
|
410
|
-
|
|
411
|
-
## 0.2.1
|
|
412
|
-
|
|
413
|
-
### Patch Changes
|
|
414
|
-
|
|
415
|
-
- [#3695](https://github.com/withastro/astro/pull/3695) [`0d667d0e`](https://github.com/withastro/astro/commit/0d667d0e572d76d4c819816ddf51ed14b43e2551) Thanks [@nrgnrg](https://github.com/nrgnrg)! - fix custom 404 pages not rendering
|
|
416
|
-
|
|
417
|
-
## 0.2.0
|
|
418
|
-
|
|
419
|
-
### Minor Changes
|
|
420
|
-
|
|
421
|
-
- [#3600](https://github.com/withastro/astro/pull/3600) [`7f423581`](https://github.com/withastro/astro/commit/7f423581411648c9a69b68918ff930581f12cf16) Thanks [@nrgnrg](https://github.com/nrgnrg)! - add SSR adaptor for Cloudflare Pages functions
|
package/src/index.ts
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import type { AstroAdapter, AstroConfig, AstroIntegration } from 'astro';
|
|
2
|
-
import esbuild from 'esbuild';
|
|
3
|
-
import * as fs from 'fs';
|
|
4
|
-
import * as os from 'os';
|
|
5
|
-
import glob from 'tiny-glob';
|
|
6
|
-
import { fileURLToPath, pathToFileURL } from 'url';
|
|
7
|
-
|
|
8
|
-
type Options = {
|
|
9
|
-
mode: 'directory' | 'advanced';
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
interface BuildConfig {
|
|
13
|
-
server: URL;
|
|
14
|
-
client: URL;
|
|
15
|
-
serverEntry: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function getAdapter(isModeDirectory: boolean): AstroAdapter {
|
|
19
|
-
return isModeDirectory
|
|
20
|
-
? {
|
|
21
|
-
name: '@astrojs/cloudflare',
|
|
22
|
-
serverEntrypoint: '@astrojs/cloudflare/server.directory.js',
|
|
23
|
-
exports: ['onRequest'],
|
|
24
|
-
}
|
|
25
|
-
: {
|
|
26
|
-
name: '@astrojs/cloudflare',
|
|
27
|
-
serverEntrypoint: '@astrojs/cloudflare/server.advanced.js',
|
|
28
|
-
exports: ['default'],
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const SHIM = `globalThis.process = {
|
|
33
|
-
argv: [],
|
|
34
|
-
env: {},
|
|
35
|
-
};`;
|
|
36
|
-
|
|
37
|
-
const SERVER_BUILD_FOLDER = '/$server_build/';
|
|
38
|
-
|
|
39
|
-
export default function createIntegration(args?: Options): AstroIntegration {
|
|
40
|
-
let _config: AstroConfig;
|
|
41
|
-
let _buildConfig: BuildConfig;
|
|
42
|
-
const isModeDirectory = args?.mode === 'directory';
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
name: '@astrojs/cloudflare',
|
|
46
|
-
hooks: {
|
|
47
|
-
'astro:config:setup': ({ config, updateConfig }) => {
|
|
48
|
-
updateConfig({
|
|
49
|
-
build: {
|
|
50
|
-
client: new URL(`.${config.base}`, config.outDir),
|
|
51
|
-
server: new URL(`.${SERVER_BUILD_FOLDER}`, config.outDir),
|
|
52
|
-
serverEntry: '_worker.mjs',
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
},
|
|
56
|
-
'astro:config:done': ({ setAdapter, config }) => {
|
|
57
|
-
setAdapter(getAdapter(isModeDirectory));
|
|
58
|
-
_config = config;
|
|
59
|
-
_buildConfig = config.build;
|
|
60
|
-
|
|
61
|
-
if (config.output === 'static') {
|
|
62
|
-
throw new Error(`
|
|
63
|
-
[@astrojs/cloudflare] \`output: "server"\` is required to use this adapter. Otherwise, this adapter is not necessary to deploy a static site to Cloudflare.
|
|
64
|
-
|
|
65
|
-
`);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (config.base === SERVER_BUILD_FOLDER) {
|
|
69
|
-
throw new Error(`
|
|
70
|
-
[@astrojs/cloudflare] \`base: "${SERVER_BUILD_FOLDER}"\` is not allowed. Please change your \`base\` config to something else.`);
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
'astro:build:setup': ({ vite, target }) => {
|
|
74
|
-
if (target === 'server') {
|
|
75
|
-
vite.resolve = vite.resolve || {};
|
|
76
|
-
vite.resolve.alias = vite.resolve.alias || {};
|
|
77
|
-
|
|
78
|
-
const aliases = [{ find: 'react-dom/server', replacement: 'react-dom/server.browser' }];
|
|
79
|
-
|
|
80
|
-
if (Array.isArray(vite.resolve.alias)) {
|
|
81
|
-
vite.resolve.alias = [...vite.resolve.alias, ...aliases];
|
|
82
|
-
} else {
|
|
83
|
-
for (const alias of aliases) {
|
|
84
|
-
(vite.resolve.alias as Record<string, string>)[alias.find] = alias.replacement;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
vite.ssr = vite.ssr || {};
|
|
88
|
-
vite.ssr.target = vite.ssr.target || 'webworker';
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
'astro:build:done': async ({ pages }) => {
|
|
92
|
-
const entryPath = fileURLToPath(new URL(_buildConfig.serverEntry, _buildConfig.server));
|
|
93
|
-
const entryUrl = new URL(_buildConfig.serverEntry, _config.outDir);
|
|
94
|
-
const buildPath = fileURLToPath(entryUrl);
|
|
95
|
-
// A URL for the final build path after renaming
|
|
96
|
-
const finalBuildUrl = pathToFileURL(buildPath.replace(/\.mjs$/, '.js'));
|
|
97
|
-
|
|
98
|
-
await esbuild.build({
|
|
99
|
-
target: 'es2020',
|
|
100
|
-
platform: 'browser',
|
|
101
|
-
entryPoints: [entryPath],
|
|
102
|
-
outfile: buildPath,
|
|
103
|
-
allowOverwrite: true,
|
|
104
|
-
format: 'esm',
|
|
105
|
-
bundle: true,
|
|
106
|
-
minify: _config.vite?.build?.minify !== false,
|
|
107
|
-
banner: {
|
|
108
|
-
js: SHIM,
|
|
109
|
-
},
|
|
110
|
-
logOverride: {
|
|
111
|
-
'ignored-bare-import': 'silent',
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
// Rename to worker.js
|
|
116
|
-
await fs.promises.rename(buildPath, finalBuildUrl);
|
|
117
|
-
|
|
118
|
-
// throw the server folder in the bin
|
|
119
|
-
const serverUrl = new URL(_buildConfig.server);
|
|
120
|
-
await fs.promises.rm(serverUrl, { recursive: true, force: true });
|
|
121
|
-
|
|
122
|
-
// move cloudflare specific files to the root
|
|
123
|
-
const cloudflareSpecialFiles = ['_headers', '_redirects', '_routes.json'];
|
|
124
|
-
if (_config.base !== '/') {
|
|
125
|
-
for (const file of cloudflareSpecialFiles) {
|
|
126
|
-
try {
|
|
127
|
-
await fs.promises.rename(
|
|
128
|
-
new URL(file, _buildConfig.client),
|
|
129
|
-
new URL(file, _config.outDir)
|
|
130
|
-
);
|
|
131
|
-
} catch (e) {
|
|
132
|
-
// ignore
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const routesExists = await fs.promises
|
|
138
|
-
.stat(new URL('./_routes.json', _config.outDir))
|
|
139
|
-
.then((stat) => stat.isFile())
|
|
140
|
-
.catch(() => false);
|
|
141
|
-
|
|
142
|
-
// this creates a _routes.json, in case there is none present to enable
|
|
143
|
-
// cloudflare to handle static files and support _redirects configuration
|
|
144
|
-
// (without calling the function)
|
|
145
|
-
if (!routesExists) {
|
|
146
|
-
const staticPathList: Array<string> = (
|
|
147
|
-
await glob(`${fileURLToPath(_buildConfig.client)}/**/*`, {
|
|
148
|
-
cwd: fileURLToPath(_config.outDir),
|
|
149
|
-
filesOnly: true,
|
|
150
|
-
})
|
|
151
|
-
)
|
|
152
|
-
.filter((file: string) => cloudflareSpecialFiles.indexOf(file) < 0)
|
|
153
|
-
.map((file: string) => `/${file}`);
|
|
154
|
-
|
|
155
|
-
for (let page of pages) {
|
|
156
|
-
let pagePath = prependForwardSlash(page.pathname);
|
|
157
|
-
if (_config.base !== '/') {
|
|
158
|
-
const base = _config.base.endsWith('/') ? _config.base.slice(0, -1) : _config.base;
|
|
159
|
-
pagePath = `${base}${pagePath}`;
|
|
160
|
-
}
|
|
161
|
-
staticPathList.push(pagePath);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
const redirectsExists = await fs.promises
|
|
165
|
-
.stat(new URL('./_redirects', _config.outDir))
|
|
166
|
-
.then((stat) => stat.isFile())
|
|
167
|
-
.catch(() => false);
|
|
168
|
-
|
|
169
|
-
// convert all redirect source paths into a list of routes
|
|
170
|
-
// and add them to the static path
|
|
171
|
-
if (redirectsExists) {
|
|
172
|
-
const redirects = (
|
|
173
|
-
await fs.promises.readFile(new URL('./_redirects', _config.outDir), 'utf-8')
|
|
174
|
-
)
|
|
175
|
-
.split(os.EOL)
|
|
176
|
-
.map((line) => {
|
|
177
|
-
const parts = line.split(' ');
|
|
178
|
-
if (parts.length < 2) {
|
|
179
|
-
return null;
|
|
180
|
-
} else {
|
|
181
|
-
// convert /products/:id to /products/*
|
|
182
|
-
return (
|
|
183
|
-
parts[0]
|
|
184
|
-
.replace(/\/:.*?(?=\/|$)/g, '/*')
|
|
185
|
-
// remove query params as they are not supported by cloudflare
|
|
186
|
-
.replace(/\?.*$/, '')
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
})
|
|
190
|
-
.filter(
|
|
191
|
-
(line, index, arr) => line !== null && arr.indexOf(line) === index
|
|
192
|
-
) as string[];
|
|
193
|
-
|
|
194
|
-
if (redirects.length > 0) {
|
|
195
|
-
staticPathList.push(...redirects);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
await fs.promises.writeFile(
|
|
200
|
-
new URL('./_routes.json', _config.outDir),
|
|
201
|
-
JSON.stringify(
|
|
202
|
-
{
|
|
203
|
-
version: 1,
|
|
204
|
-
include: ['/*'],
|
|
205
|
-
exclude: staticPathList,
|
|
206
|
-
},
|
|
207
|
-
null,
|
|
208
|
-
2
|
|
209
|
-
)
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if (isModeDirectory) {
|
|
214
|
-
const functionsUrl = new URL('functions/', _config.root);
|
|
215
|
-
await fs.promises.mkdir(functionsUrl, { recursive: true });
|
|
216
|
-
|
|
217
|
-
const directoryUrl = new URL('[[path]].js', functionsUrl);
|
|
218
|
-
await fs.promises.rename(finalBuildUrl, directoryUrl);
|
|
219
|
-
}
|
|
220
|
-
},
|
|
221
|
-
},
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function prependForwardSlash(path: string) {
|
|
226
|
-
return path[0] === '/' ? path : '/' + path;
|
|
227
|
-
}
|
package/src/runtime.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export type WorkerRuntime<T = unknown> = {
|
|
2
|
-
name: 'cloudflare';
|
|
3
|
-
env: T;
|
|
4
|
-
waitUntil(promise: Promise<any>): void;
|
|
5
|
-
passThroughOnException(): void;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type PagesRuntime<T = unknown, U = unknown> = {
|
|
9
|
-
name: 'cloudflare';
|
|
10
|
-
env: T;
|
|
11
|
-
functionPath: string;
|
|
12
|
-
params: Record<string, string>;
|
|
13
|
-
data: U;
|
|
14
|
-
waitUntil(promise: Promise<any>): void;
|
|
15
|
-
next(request: Request): void;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export function getRuntime<T = unknown, U = unknown>(
|
|
19
|
-
request: Request
|
|
20
|
-
): WorkerRuntime<T> | PagesRuntime<T, U> {
|
|
21
|
-
if (!!request) {
|
|
22
|
-
return Reflect.get(request, Symbol.for('runtime'));
|
|
23
|
-
} else {
|
|
24
|
-
throw new Error(
|
|
25
|
-
'To retrieve the current cloudflare runtime you need to pass in the Astro request object'
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
}
|
package/src/server.advanced.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { SSRManifest } from 'astro';
|
|
2
|
-
import { App } from 'astro/app';
|
|
3
|
-
import { getProcessEnvProxy, isNode } from './util.js';
|
|
4
|
-
|
|
5
|
-
if (!isNode) {
|
|
6
|
-
process.env = getProcessEnvProxy();
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
type Env = {
|
|
10
|
-
ASSETS: { fetch: (req: Request) => Promise<Response> };
|
|
11
|
-
name: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export function createExports(manifest: SSRManifest) {
|
|
15
|
-
const app = new App(manifest);
|
|
16
|
-
|
|
17
|
-
const fetch = async (request: Request, env: Env, context: any) => {
|
|
18
|
-
process.env = env as any;
|
|
19
|
-
|
|
20
|
-
const { pathname } = new URL(request.url);
|
|
21
|
-
|
|
22
|
-
// static assets fallback, in case default _routes.json is not used
|
|
23
|
-
if (manifest.assets.has(pathname)) {
|
|
24
|
-
return env.ASSETS.fetch(request);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let routeData = app.match(request, { matchNotFound: true });
|
|
28
|
-
if (routeData) {
|
|
29
|
-
Reflect.set(
|
|
30
|
-
request,
|
|
31
|
-
Symbol.for('astro.clientAddress'),
|
|
32
|
-
request.headers.get('cf-connecting-ip')
|
|
33
|
-
);
|
|
34
|
-
Reflect.set(request, Symbol.for('runtime'), { env, name: 'cloudflare', ...context });
|
|
35
|
-
let response = await app.render(request, routeData);
|
|
36
|
-
|
|
37
|
-
if (app.setCookieHeaders) {
|
|
38
|
-
for (const setCookieHeader of app.setCookieHeaders(response)) {
|
|
39
|
-
response.headers.append('Set-Cookie', setCookieHeader);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return response;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return new Response(null, {
|
|
47
|
-
status: 404,
|
|
48
|
-
statusText: 'Not found',
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
return { default: { fetch } };
|
|
53
|
-
}
|
package/src/server.directory.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { SSRManifest } from 'astro';
|
|
2
|
-
import { App } from 'astro/app';
|
|
3
|
-
import { getProcessEnvProxy, isNode } from './util.js';
|
|
4
|
-
|
|
5
|
-
if (!isNode) {
|
|
6
|
-
process.env = getProcessEnvProxy();
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function createExports(manifest: SSRManifest) {
|
|
10
|
-
const app = new App(manifest);
|
|
11
|
-
|
|
12
|
-
const onRequest = async ({
|
|
13
|
-
request,
|
|
14
|
-
next,
|
|
15
|
-
...runtimeEnv
|
|
16
|
-
}: {
|
|
17
|
-
request: Request;
|
|
18
|
-
next: (request: Request) => void;
|
|
19
|
-
} & Record<string, unknown>) => {
|
|
20
|
-
process.env = runtimeEnv.env as any;
|
|
21
|
-
|
|
22
|
-
const { pathname } = new URL(request.url);
|
|
23
|
-
// static assets fallback, in case default _routes.json is not used
|
|
24
|
-
if (manifest.assets.has(pathname)) {
|
|
25
|
-
return next(request);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let routeData = app.match(request, { matchNotFound: true });
|
|
29
|
-
if (routeData) {
|
|
30
|
-
Reflect.set(
|
|
31
|
-
request,
|
|
32
|
-
Symbol.for('astro.clientAddress'),
|
|
33
|
-
request.headers.get('cf-connecting-ip')
|
|
34
|
-
);
|
|
35
|
-
Reflect.set(request, Symbol.for('runtime'), {
|
|
36
|
-
...runtimeEnv,
|
|
37
|
-
name: 'cloudflare',
|
|
38
|
-
next,
|
|
39
|
-
});
|
|
40
|
-
let response = await app.render(request, routeData);
|
|
41
|
-
|
|
42
|
-
if (app.setCookieHeaders) {
|
|
43
|
-
for (const setCookieHeader of app.setCookieHeaders(response)) {
|
|
44
|
-
response.headers.append('Set-Cookie', setCookieHeader);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return response;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return new Response(null, {
|
|
52
|
-
status: 404,
|
|
53
|
-
statusText: 'Not found',
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
return { onRequest };
|
|
58
|
-
}
|
package/src/util.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export const isNode =
|
|
2
|
-
typeof process === 'object' && Object.prototype.toString.call(process) === '[object process]';
|
|
3
|
-
|
|
4
|
-
export function getProcessEnvProxy() {
|
|
5
|
-
return new Proxy(
|
|
6
|
-
{},
|
|
7
|
-
{
|
|
8
|
-
get: (target, prop) => {
|
|
9
|
-
console.warn(
|
|
10
|
-
// NOTE: \0 prevents Vite replacement
|
|
11
|
-
`Unable to access \`import.meta\0.env.${prop.toString()}\` on initialization ` +
|
|
12
|
-
`as the Cloudflare platform only provides the environment variables per request. ` +
|
|
13
|
-
`Please move the environment variable access inside a function ` +
|
|
14
|
-
`that's only called after a request has been received.`
|
|
15
|
-
);
|
|
16
|
-
},
|
|
17
|
-
}
|
|
18
|
-
);
|
|
19
|
-
}
|
package/test/basics.test.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { loadFixture, runCLI } from './test-utils.js';
|
|
2
|
-
import { expect } from 'chai';
|
|
3
|
-
import * as cheerio from 'cheerio';
|
|
4
|
-
|
|
5
|
-
describe.skip('Basic app', () => {
|
|
6
|
-
/** @type {import('./test-utils').Fixture} */
|
|
7
|
-
let fixture;
|
|
8
|
-
|
|
9
|
-
before(async () => {
|
|
10
|
-
fixture = await loadFixture({
|
|
11
|
-
root: './fixtures/basics/',
|
|
12
|
-
});
|
|
13
|
-
await fixture.build();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('can render', async () => {
|
|
17
|
-
const { ready, stop } = runCLI('./fixtures/basics/', { silent: true });
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
await ready;
|
|
21
|
-
|
|
22
|
-
let res = await fetch(`http://localhost:8787/`);
|
|
23
|
-
expect(res.status).to.equal(200);
|
|
24
|
-
let html = await res.text();
|
|
25
|
-
let $ = cheerio.load(html);
|
|
26
|
-
expect($('h1').text()).to.equal('Testing');
|
|
27
|
-
expect($('#env').text()).to.equal('secret');
|
|
28
|
-
} finally {
|
|
29
|
-
stop();
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
});
|
package/test/directory.test.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { loadFixture } from './test-utils.js';
|
|
2
|
-
import { expect } from 'chai';
|
|
3
|
-
import cloudflare from '../dist/index.js';
|
|
4
|
-
|
|
5
|
-
/** @type {import('./test-utils').Fixture} */
|
|
6
|
-
describe('mode: "directory"', () => {
|
|
7
|
-
let fixture;
|
|
8
|
-
|
|
9
|
-
before(async () => {
|
|
10
|
-
fixture = await loadFixture({
|
|
11
|
-
root: './fixtures/basics/',
|
|
12
|
-
output: 'server',
|
|
13
|
-
adapter: cloudflare({ mode: 'directory' }),
|
|
14
|
-
});
|
|
15
|
-
await fixture.build();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('generates functions folder inside the project root', async () => {
|
|
19
|
-
expect(await fixture.pathExists('../functions')).to.be.true;
|
|
20
|
-
expect(await fixture.pathExists('../functions/[[path]].js')).to.be.true;
|
|
21
|
-
});
|
|
22
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
-
|
|
4
|
-
case `uname` in
|
|
5
|
-
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
-
esac
|
|
7
|
-
|
|
8
|
-
if [ -z "$NODE_PATH" ]; then
|
|
9
|
-
export NODE_PATH="/home/runner/work/astro/astro/packages/astro/node_modules:/home/runner/work/astro/astro/packages/node_modules:/home/runner/work/astro/astro/node_modules:/home/runner/work/astro/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
|
|
10
|
-
else
|
|
11
|
-
export NODE_PATH="/home/runner/work/astro/astro/packages/astro/node_modules:/home/runner/work/astro/astro/packages/node_modules:/home/runner/work/astro/astro/node_modules:/home/runner/work/astro/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
-
fi
|
|
13
|
-
if [ -x "$basedir/node" ]; then
|
|
14
|
-
exec "$basedir/node" "$basedir/../../../../../../../astro/astro.js" "$@"
|
|
15
|
-
else
|
|
16
|
-
exec node "$basedir/../../../../../../../astro/astro.js" "$@"
|
|
17
|
-
fi
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
-
|
|
4
|
-
case `uname` in
|
|
5
|
-
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
-
esac
|
|
7
|
-
|
|
8
|
-
if [ -z "$NODE_PATH" ]; then
|
|
9
|
-
export NODE_PATH="/home/runner/work/astro/astro/packages/astro/node_modules:/home/runner/work/astro/astro/packages/node_modules:/home/runner/work/astro/astro/node_modules:/home/runner/work/astro/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
|
|
10
|
-
else
|
|
11
|
-
export NODE_PATH="/home/runner/work/astro/astro/packages/astro/node_modules:/home/runner/work/astro/astro/packages/node_modules:/home/runner/work/astro/astro/node_modules:/home/runner/work/astro/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
-
fi
|
|
13
|
-
if [ -x "$basedir/node" ]; then
|
|
14
|
-
exec "$basedir/node" "$basedir/../../../../../../../astro/astro.js" "$@"
|
|
15
|
-
else
|
|
16
|
-
exec node "$basedir/../../../../../../../astro/astro.js" "$@"
|
|
17
|
-
fi
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
-
|
|
4
|
-
case `uname` in
|
|
5
|
-
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
-
esac
|
|
7
|
-
|
|
8
|
-
if [ -z "$NODE_PATH" ]; then
|
|
9
|
-
export NODE_PATH="/home/runner/work/astro/astro/packages/astro/node_modules:/home/runner/work/astro/astro/packages/node_modules:/home/runner/work/astro/astro/node_modules:/home/runner/work/astro/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
|
|
10
|
-
else
|
|
11
|
-
export NODE_PATH="/home/runner/work/astro/astro/packages/astro/node_modules:/home/runner/work/astro/astro/packages/node_modules:/home/runner/work/astro/astro/node_modules:/home/runner/work/astro/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
-
fi
|
|
13
|
-
if [ -x "$basedir/node" ]; then
|
|
14
|
-
exec "$basedir/node" "$basedir/../../../../../../../astro/astro.js" "$@"
|
|
15
|
-
else
|
|
16
|
-
exec node "$basedir/../../../../../../../astro/astro.js" "$@"
|
|
17
|
-
fi
|
package/test/no-output.test.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { loadFixture } from './test-utils.js';
|
|
2
|
-
import { expect } from 'chai';
|
|
3
|
-
|
|
4
|
-
describe('Missing output config', () => {
|
|
5
|
-
/** @type {import('./test-utils').Fixture} */
|
|
6
|
-
let fixture;
|
|
7
|
-
|
|
8
|
-
before(async () => {
|
|
9
|
-
fixture = await loadFixture({
|
|
10
|
-
root: './fixtures/no-output/',
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('throws during the build', async () => {
|
|
15
|
-
let error = undefined;
|
|
16
|
-
try {
|
|
17
|
-
await fixture.build();
|
|
18
|
-
} catch (err) {
|
|
19
|
-
error = err;
|
|
20
|
-
}
|
|
21
|
-
expect(error).to.not.be.equal(undefined);
|
|
22
|
-
expect(error.message).to.include(`output: "server"`);
|
|
23
|
-
});
|
|
24
|
-
});
|
package/test/prerender.test.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { loadFixture } from './test-utils.js';
|
|
2
|
-
import { expect } from 'chai';
|
|
3
|
-
|
|
4
|
-
describe('Prerendering', () => {
|
|
5
|
-
/** @type {import('./test-utils').Fixture} */
|
|
6
|
-
let fixture;
|
|
7
|
-
|
|
8
|
-
before(async () => {
|
|
9
|
-
fixture = await loadFixture({
|
|
10
|
-
root: './fixtures/prerender/',
|
|
11
|
-
});
|
|
12
|
-
await fixture.build();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('includes prerendered routes in the routes.json config', async () => {
|
|
16
|
-
const routes = JSON.parse(await fixture.readFile('/_routes.json'));
|
|
17
|
-
expect(routes.exclude).to.include('/one/');
|
|
18
|
-
});
|
|
19
|
-
});
|
package/test/test-utils.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { loadFixture as baseLoadFixture } from '../../../astro/test/test-utils.js';
|
|
2
|
-
import { spawn } from 'child_process';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
|
|
5
|
-
export { fixLineEndings } from '../../../astro/test/test-utils.js';
|
|
6
|
-
|
|
7
|
-
export function loadFixture(config) {
|
|
8
|
-
if (config?.root) {
|
|
9
|
-
config.root = new URL(config.root, import.meta.url);
|
|
10
|
-
}
|
|
11
|
-
return baseLoadFixture(config);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const wranglerPath = fileURLToPath(
|
|
15
|
-
new URL('../node_modules/wrangler/bin/wrangler.js', import.meta.url)
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
export function runCLI(basePath, { silent }) {
|
|
19
|
-
const script = fileURLToPath(new URL(`${basePath}/dist/_worker.js`, import.meta.url));
|
|
20
|
-
const p = spawn('node', [wranglerPath, 'dev', '-l', script]);
|
|
21
|
-
|
|
22
|
-
p.stderr.setEncoding('utf-8');
|
|
23
|
-
p.stdout.setEncoding('utf-8');
|
|
24
|
-
|
|
25
|
-
const timeout = 10000;
|
|
26
|
-
|
|
27
|
-
const ready = new Promise(async (resolve, reject) => {
|
|
28
|
-
const failed = setTimeout(
|
|
29
|
-
() => reject(new Error(`Timed out starting the wrangler CLI`)),
|
|
30
|
-
timeout
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
(async function () {
|
|
34
|
-
for (const msg of p.stderr) {
|
|
35
|
-
if (!silent) {
|
|
36
|
-
// eslint-disable-next-line
|
|
37
|
-
console.error(msg);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
})();
|
|
41
|
-
|
|
42
|
-
for await (const msg of p.stdout) {
|
|
43
|
-
if (!silent) {
|
|
44
|
-
// eslint-disable-next-line
|
|
45
|
-
console.log(msg);
|
|
46
|
-
}
|
|
47
|
-
if (msg.includes(`Listening on`)) {
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
clearTimeout(failed);
|
|
53
|
-
resolve();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
ready,
|
|
58
|
-
stop() {
|
|
59
|
-
p.kill();
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
}
|
package/test/wrangler.toml
DELETED