@astrojs/cloudflare 6.0.0-beta.1 → 6.1.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.
@@ -1,5 +1,5 @@
1
- @astrojs/cloudflare:build: cache hit, replaying output 93e997f468aca334
2
- @astrojs/cloudflare:build: 
3
- @astrojs/cloudflare:build: > @astrojs/cloudflare@6.0.0-beta.1 build /home/runner/work/astro/astro/packages/integrations/cloudflare
4
- @astrojs/cloudflare:build: > astro-scripts build "src/**/*.ts" && tsc
5
- @astrojs/cloudflare:build: 
1
+ @astrojs/cloudflare:build: cache hit, replaying output b77c78448d3e171a
2
+ @astrojs/cloudflare:build: 
3
+ @astrojs/cloudflare:build: > @astrojs/cloudflare@6.1.0 build /home/runner/work/astro/astro/packages/integrations/cloudflare
4
+ @astrojs/cloudflare:build: > astro-scripts build "src/**/*.ts" && tsc
5
+ @astrojs/cloudflare:build: 
package/CHANGELOG.md CHANGED
@@ -1,20 +1,58 @@
1
1
  # @astrojs/cloudflare
2
2
 
3
+ ## 6.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#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.
8
+
9
+ ### Patch Changes
10
+
11
+ - [#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
12
+
13
+ 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.
14
+
15
+ - 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)]:
16
+ - astro@2.0.2
17
+
18
+ ## 6.0.0
19
+
20
+ ### Major Changes
21
+
22
+ - [#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
23
+
24
+ - [#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
25
+
26
+ 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.
27
+
28
+ ### Patch Changes
29
+
30
+ - 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)]:
31
+ - astro@2.0.0
32
+
3
33
  ## 6.0.0-beta.1
4
34
 
35
+ <details>
36
+ <summary>See changes in 6.0.0-beta.1</summary>
37
+
5
38
  ### Major Changes
6
39
 
7
- - [#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
40
+ - [#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
8
41
 
9
- 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.
42
+ 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.
10
43
 
11
44
  ### Patch Changes
12
45
 
13
46
  - 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)]:
14
47
  - astro@2.0.0-beta.2
15
48
 
49
+ </details>
50
+
16
51
  ## 6.0.0-beta.0
17
52
 
53
+ <details>
54
+ <summary>See changes in 6.0.0-beta.0</summary>
55
+
18
56
  ### Major Changes
19
57
 
20
58
  - [#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
@@ -24,6 +62,8 @@
24
62
  - 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)]:
25
63
  - astro@2.0.0-beta.0
26
64
 
65
+ </details>
66
+
27
67
  ## 5.0.0
28
68
 
29
69
  ### Patch Changes
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ function createIntegration(args) {
31
31
  build: {
32
32
  client: new URL(`.${config.base}`, config.outDir),
33
33
  server: new URL(`.${SERVER_BUILD_FOLDER}`, config.outDir),
34
- serverEntry: "_worker.js"
34
+ serverEntry: "_worker.mjs"
35
35
  }
36
36
  });
37
37
  },
@@ -66,7 +66,7 @@ function createIntegration(args) {
66
66
  vite.ssr.target = vite.ssr.target || "webworker";
67
67
  }
68
68
  },
69
- "astro:build:done": async () => {
69
+ "astro:build:done": async ({ pages }) => {
70
70
  const entryPath = fileURLToPath(new URL(_buildConfig.serverEntry, _buildConfig.server)), entryUrl = new URL(_buildConfig.serverEntry, _config.outDir), buildPath = fileURLToPath(entryUrl);
71
71
  await esbuild.build({
72
72
  target: "es2020",
@@ -81,6 +81,7 @@ function createIntegration(args) {
81
81
  js: SHIM
82
82
  }
83
83
  });
84
+ await fs.promises.rename(buildPath, buildPath.replace(/\.mjs$/, ".js"));
84
85
  const serverUrl = new URL(_buildConfig.server);
85
86
  await fs.promises.rm(serverUrl, { recursive: true, force: true });
86
87
  const cloudflareSpecialFiles = ["_headers", "_redirects", "_routes.json"];
@@ -101,6 +102,9 @@ function createIntegration(args) {
101
102
  cwd: fileURLToPath(_config.outDir),
102
103
  filesOnly: true
103
104
  })).filter((file) => cloudflareSpecialFiles.indexOf(file) < 0).map((file) => `/${file}`);
105
+ for (let page of pages) {
106
+ staticPathList.push(prependForwardSlash(page.pathname));
107
+ }
104
108
  const redirectsExists = await fs.promises.stat(new URL("./_redirects", _config.outDir)).then((stat) => stat.isFile()).catch(() => false);
105
109
  if (redirectsExists) {
106
110
  const redirects = (await fs.promises.readFile(new URL("./_redirects", _config.outDir), "utf-8")).split(os.EOL).map((line) => {
@@ -140,6 +144,9 @@ function createIntegration(args) {
140
144
  }
141
145
  };
142
146
  }
147
+ function prependForwardSlash(path) {
148
+ return path[0] === "/" ? path : "/" + path;
149
+ }
143
150
  export {
144
151
  createIntegration as default,
145
152
  getAdapter
@@ -1,8 +1,10 @@
1
1
  import { App } from "astro/app";
2
- import { getProcessEnvProxy } from "./util.js";
3
- process.env = getProcessEnvProxy();
2
+ import { getProcessEnvProxy, isNode } from "./util.js";
3
+ if (!isNode) {
4
+ process.env = getProcessEnvProxy();
5
+ }
4
6
  function createExports(manifest) {
5
- const app = new App(manifest, false);
7
+ const app = new App(manifest);
6
8
  const fetch = async (request, env, context) => {
7
9
  process.env = env;
8
10
  const { pathname } = new URL(request.url);
@@ -1,8 +1,10 @@
1
1
  import { App } from "astro/app";
2
- import { getProcessEnvProxy } from "./util.js";
3
- process.env = getProcessEnvProxy();
2
+ import { getProcessEnvProxy, isNode } from "./util.js";
3
+ if (!isNode) {
4
+ process.env = getProcessEnvProxy();
5
+ }
4
6
  function createExports(manifest) {
5
- const app = new App(manifest, false);
7
+ const app = new App(manifest);
6
8
  const onRequest = async ({
7
9
  request,
8
10
  next,
package/dist/util.d.ts CHANGED
@@ -1 +1,2 @@
1
+ export declare const isNode: boolean;
1
2
  export declare function getProcessEnvProxy(): {};
package/dist/util.js CHANGED
@@ -1,3 +1,4 @@
1
+ const isNode = typeof process === "object" && Object.prototype.toString.call(process) === "[object process]";
1
2
  function getProcessEnvProxy() {
2
3
  return new Proxy(
3
4
  {},
@@ -11,5 +12,6 @@ function getProcessEnvProxy() {
11
12
  );
12
13
  }
13
14
  export {
14
- getProcessEnvProxy
15
+ getProcessEnvProxy,
16
+ isNode
15
17
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@astrojs/cloudflare",
3
3
  "description": "Deploy your site to cloudflare workers or cloudflare pages",
4
- "version": "6.0.0-beta.1",
4
+ "version": "6.1.0",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "author": "withastro",
@@ -32,11 +32,11 @@
32
32
  "tiny-glob": "^0.2.9"
33
33
  },
34
34
  "peerDependencies": {
35
- "astro": "^2.0.0-beta.2"
35
+ "astro": "^2.0.2"
36
36
  },
37
37
  "devDependencies": {
38
- "astro": "2.0.0-beta.2",
39
- "astro-scripts": "0.0.10-beta.0",
38
+ "astro": "2.0.2",
39
+ "astro-scripts": "0.0.10",
40
40
  "chai": "^4.3.6",
41
41
  "cheerio": "^1.0.0-rc.11",
42
42
  "mocha": "^9.2.2",
package/src/index.ts CHANGED
@@ -49,7 +49,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
49
49
  build: {
50
50
  client: new URL(`.${config.base}`, config.outDir),
51
51
  server: new URL(`.${SERVER_BUILD_FOLDER}`, config.outDir),
52
- serverEntry: '_worker.js',
52
+ serverEntry: '_worker.mjs',
53
53
  },
54
54
  });
55
55
  },
@@ -88,10 +88,11 @@ export default function createIntegration(args?: Options): AstroIntegration {
88
88
  vite.ssr.target = vite.ssr.target || 'webworker';
89
89
  }
90
90
  },
91
- 'astro:build:done': async () => {
91
+ 'astro:build:done': async ({ pages }) => {
92
92
  const entryPath = fileURLToPath(new URL(_buildConfig.serverEntry, _buildConfig.server)),
93
93
  entryUrl = new URL(_buildConfig.serverEntry, _config.outDir),
94
94
  buildPath = fileURLToPath(entryUrl);
95
+
95
96
  await esbuild.build({
96
97
  target: 'es2020',
97
98
  platform: 'browser',
@@ -106,6 +107,9 @@ export default function createIntegration(args?: Options): AstroIntegration {
106
107
  },
107
108
  });
108
109
 
110
+ // Rename to worker.js
111
+ await fs.promises.rename(buildPath, buildPath.replace(/\.mjs$/, '.js'));
112
+
109
113
  // throw the server folder in the bin
110
114
  const serverUrl = new URL(_buildConfig.server);
111
115
  await fs.promises.rm(serverUrl, { recursive: true, force: true });
@@ -143,6 +147,10 @@ export default function createIntegration(args?: Options): AstroIntegration {
143
147
  .filter((file: string) => cloudflareSpecialFiles.indexOf(file) < 0)
144
148
  .map((file: string) => `/${file}`);
145
149
 
150
+ for (let page of pages) {
151
+ staticPathList.push(prependForwardSlash(page.pathname));
152
+ }
153
+
146
154
  const redirectsExists = await fs.promises
147
155
  .stat(new URL('./_redirects', _config.outDir))
148
156
  .then((stat) => stat.isFile())
@@ -202,3 +210,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
202
210
  },
203
211
  };
204
212
  }
213
+
214
+ function prependForwardSlash(path: string) {
215
+ return path[0] === '/' ? path : '/' + path;
216
+ }
@@ -1,8 +1,10 @@
1
1
  import type { SSRManifest } from 'astro';
2
2
  import { App } from 'astro/app';
3
- import { getProcessEnvProxy } from './util.js';
3
+ import { getProcessEnvProxy, isNode } from './util.js';
4
4
 
5
- process.env = getProcessEnvProxy();
5
+ if (!isNode) {
6
+ process.env = getProcessEnvProxy();
7
+ }
6
8
 
7
9
  type Env = {
8
10
  ASSETS: { fetch: (req: Request) => Promise<Response> };
@@ -10,7 +12,7 @@ type Env = {
10
12
  };
11
13
 
12
14
  export function createExports(manifest: SSRManifest) {
13
- const app = new App(manifest, false);
15
+ const app = new App(manifest);
14
16
 
15
17
  const fetch = async (request: Request, env: Env, context: any) => {
16
18
  process.env = env as any;
@@ -1,11 +1,13 @@
1
1
  import type { SSRManifest } from 'astro';
2
2
  import { App } from 'astro/app';
3
- import { getProcessEnvProxy } from './util.js';
3
+ import { getProcessEnvProxy, isNode } from './util.js';
4
4
 
5
- process.env = getProcessEnvProxy();
5
+ if (!isNode) {
6
+ process.env = getProcessEnvProxy();
7
+ }
6
8
 
7
9
  export function createExports(manifest: SSRManifest) {
8
- const app = new App(manifest, false);
10
+ const app = new App(manifest);
9
11
 
10
12
  const onRequest = async ({
11
13
  request,
package/src/util.ts CHANGED
@@ -1,3 +1,6 @@
1
+ export const isNode =
2
+ typeof process === 'object' && Object.prototype.toString.call(process) === '[object process]';
3
+
1
4
  export function getProcessEnvProxy() {
2
5
  return new Proxy(
3
6
  {},
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from 'astro/config';
2
+ import cloudflare from '@astrojs/cloudflare';
3
+
4
+ export default defineConfig({
5
+ adapter: cloudflare(),
6
+ output: 'server',
7
+ });
@@ -0,0 +1,17 @@
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/node_modules/.pnpm/node_modules"
10
+ else
11
+ export NODE_PATH="$NODE_PATH:/home/runner/work/astro/astro/node_modules/.pnpm/node_modules"
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
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "@test/astro-cloudflare-prerender",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "dependencies": {
6
+ "@astrojs/cloudflare": "workspace:*",
7
+ "astro": "workspace:*"
8
+ }
9
+ }
@@ -0,0 +1,8 @@
1
+ <html>
2
+ <head>
3
+ <title>Testing</title>
4
+ </head>
5
+ <body>
6
+ <h1>Testing</h1>
7
+ </body>
8
+ </html>
@@ -0,0 +1,11 @@
1
+ ---
2
+ export const prerender = true;
3
+ ---
4
+ <html>
5
+ <head>
6
+ <title>Testing</title>
7
+ </head>
8
+ <body>
9
+ <h1>Testing</h1>
10
+ </body>
11
+ </html>
@@ -0,0 +1,19 @@
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
+ });