From 9512b151531fa925b3f3b0f8a73db7c4d66e2065 Mon Sep 17 00:00:00 2001 From: Richard Cooke Date: Thu, 16 Jun 2022 15:12:25 +0100 Subject: [PATCH 001/500] feat: add SSR adaptor for cloudflare pages functions (#3600) --- packages/integrations/cloudflare/README.md | 24 ++++++ packages/integrations/cloudflare/package.json | 33 +++++++++ packages/integrations/cloudflare/src/index.ts | 73 +++++++++++++++++++ .../integrations/cloudflare/src/server.ts | 34 +++++++++ packages/integrations/cloudflare/src/shim.ts | 4 + .../integrations/cloudflare/tsconfig.json | 10 +++ 6 files changed, 178 insertions(+) create mode 100644 packages/integrations/cloudflare/README.md create mode 100644 packages/integrations/cloudflare/package.json create mode 100644 packages/integrations/cloudflare/src/index.ts create mode 100644 packages/integrations/cloudflare/src/server.ts create mode 100644 packages/integrations/cloudflare/src/shim.ts create mode 100644 packages/integrations/cloudflare/tsconfig.json diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md new file mode 100644 index 000000000000..73064e821aec --- /dev/null +++ b/packages/integrations/cloudflare/README.md @@ -0,0 +1,24 @@ +# @astrojs/cloudflare + +An SSR adapter for use with Cloudflare Pages Functions targets. Write your code in Astro/Node and deploy to Cloudflare Pages. + +In your astro.config.mjs use: + +```js +import { defineConfig } from 'astro/config'; +import cloudflare from '@astrojs/cloudflare'; + +export default defineConfig({ + adapter: cloudflare() +}); +``` + +## Enabling Preview + +In order for preview to work you must install `wrangler` + +```sh +$ pnpm install wrangler --save-dev +``` + +It's then possible to update the preview script in your `package.json` to `"preview": "wrangler pages dev ./dist"` diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json new file mode 100644 index 000000000000..ff8f2c64102a --- /dev/null +++ b/packages/integrations/cloudflare/package.json @@ -0,0 +1,33 @@ +{ + "name": "@astrojs/cloudflare", + "description": "Deploy your site to cloudflare pages functions", + "version": "0.1.0", + "type": "module", + "types": "./dist/index.d.ts", + "author": "withastro", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/withastro/astro.git", + "directory": "packages/integrations/cloudflare" + }, + "bugs": "https://github.com/withastro/astro/issues", + "homepage": "https://astro.build", + "exports": { + ".": "./dist/index.js", + "./server.js": "./dist/server.js", + "./package.json": "./package.json" + }, + "scripts": { + "build": "astro-scripts build \"src/**/*.ts\" && tsc", + "build:ci": "astro-scripts build \"src/**/*.ts\"", + "dev": "astro-scripts dev \"src/**/*.ts\"" + }, + "dependencies": { + "esbuild": "^0.14.42" + }, + "devDependencies": { + "astro": "workspace:*", + "astro-scripts": "workspace:*" + } +} \ No newline at end of file diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts new file mode 100644 index 000000000000..dc65f23ce5b0 --- /dev/null +++ b/packages/integrations/cloudflare/src/index.ts @@ -0,0 +1,73 @@ +import type { AstroAdapter, AstroConfig, AstroIntegration, BuildConfig } from 'astro'; +import esbuild from 'esbuild'; +import * as fs from 'fs'; +import { fileURLToPath } from 'url'; + +export function getAdapter(): AstroAdapter { + return { + name: '@astrojs/cloudflare', + serverEntrypoint: '@astrojs/cloudflare/server.js', + exports: ['default'], + }; +} + +export default function createIntegration(): AstroIntegration { + let _config: AstroConfig; + let _buildConfig: BuildConfig; + + return { + name: '@astrojs/cloudflare', + hooks: { + 'astro:config:done': ({ setAdapter, config }) => { + setAdapter(getAdapter()); + _config = config; + }, + 'astro:build:start': ({ buildConfig }) => { + _buildConfig = buildConfig; + buildConfig.serverEntry = '_worker.js'; + buildConfig.client = new URL('./static/', _config.outDir); + buildConfig.server = new URL('./', _config.outDir); + }, + 'astro:build:setup': ({ vite, target }) => { + if (target === 'server') { + vite.resolve = vite.resolve || {}; + vite.resolve.alias = vite.resolve.alias || {}; + + const aliases = [{ find: 'react-dom/server', replacement: 'react-dom/server.browser' }]; + + if (Array.isArray(vite.resolve.alias)) { + vite.resolve.alias = [...vite.resolve.alias, ...aliases]; + } else { + for (const alias of aliases) { + (vite.resolve.alias as Record)[alias.find] = alias.replacement; + } + } + + vite.ssr = { + target: 'webworker', + noExternal: true, + }; + } + }, + 'astro:build:done': async () => { + const entryUrl = new URL(_buildConfig.serverEntry, _buildConfig.server); + const pkg = fileURLToPath(entryUrl); + + await esbuild.build({ + target: 'es2020', + platform: 'browser', + entryPoints: [pkg], + outfile: pkg, + allowOverwrite: true, + format: 'esm', + bundle: true, + minify: true, + }); + + // throw the server folder in the bin + const chunksUrl = new URL('./chunks', _buildConfig.server); + await fs.promises.rm(chunksUrl, { recursive: true, force: true }); + }, + }, + }; +} diff --git a/packages/integrations/cloudflare/src/server.ts b/packages/integrations/cloudflare/src/server.ts new file mode 100644 index 000000000000..6a76c06ff48c --- /dev/null +++ b/packages/integrations/cloudflare/src/server.ts @@ -0,0 +1,34 @@ +import './shim.js'; + +import type { SSRManifest } from 'astro'; +import { App } from 'astro/app'; + +type Env = { + ASSETS: { fetch: (req: Request) => Promise }; +}; + +export function createExports(manifest: SSRManifest) { + const app = new App(manifest); + + const fetch = async (request: Request, env: Env) => { + const { origin, pathname } = new URL(request.url); + + // static assets + if (manifest.assets.has(pathname)) { + const assetRequest = new Request(`${origin}/static${pathname}`, request); + return env.ASSETS.fetch(assetRequest); + } + + if (app.match(request)) { + return app.render(request); + } + + // 404 + return new Response(null, { + status: 404, + statusText: 'Not found', + }); + }; + + return { default: { fetch } }; +} diff --git a/packages/integrations/cloudflare/src/shim.ts b/packages/integrations/cloudflare/src/shim.ts new file mode 100644 index 000000000000..1a4a6ee9be4c --- /dev/null +++ b/packages/integrations/cloudflare/src/shim.ts @@ -0,0 +1,4 @@ +(globalThis as any).process = { + argv: [], + env: {}, +}; diff --git a/packages/integrations/cloudflare/tsconfig.json b/packages/integrations/cloudflare/tsconfig.json new file mode 100644 index 000000000000..44baf375c882 --- /dev/null +++ b/packages/integrations/cloudflare/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": ["src"], + "compilerOptions": { + "allowJs": true, + "module": "ES2020", + "outDir": "./dist", + "target": "ES2020" + } +} From e769f288dd2fa1efcd3de3ad9604a779182f3ebb Mon Sep 17 00:00:00 2001 From: matthewp Date: Thu, 16 Jun 2022 14:14:44 +0000 Subject: [PATCH 002/500] [ci] format --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index ff8f2c64102a..bf9407d669c1 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -30,4 +30,4 @@ "astro": "workspace:*", "astro-scripts": "workspace:*" } -} \ No newline at end of file +} From f678178bfca796693549fd180a1a4ffccb101aea Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 16 Jun 2022 12:05:10 -0400 Subject: [PATCH 003/500] [ci] release (#3604) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 7 +++++++ packages/integrations/cloudflare/package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 packages/integrations/cloudflare/CHANGELOG.md diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md new file mode 100644 index 000000000000..359165e237bb --- /dev/null +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -0,0 +1,7 @@ +# @astrojs/cloudflare + +## 0.2.0 + +### Minor Changes + +- [#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 diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index bf9407d669c1..d3f663b2a041 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare pages functions", - "version": "0.1.0", + "version": "0.2.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", From 6c359df03d406cdbce02bcd80a77ee0ad9852e18 Mon Sep 17 00:00:00 2001 From: Richard Cooke Date: Thu, 16 Jun 2022 21:16:25 +0100 Subject: [PATCH 004/500] feat: update `@astrojs/cloudflare` readme (#3616) --- packages/integrations/cloudflare/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 73064e821aec..a7f077dc4a5b 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -22,3 +22,11 @@ $ pnpm install wrangler --save-dev ``` It's then possible to update the preview script in your `package.json` to `"preview": "wrangler pages dev ./dist"` + +## Streams + +Some integrations such as (react)[https://github.com/withastro/astro/tree/main/packages/integrations/react] rely on web streams. Currently Cloudflare Pages functions are in beta and don't support the `streams_enable_constructors` feature flag. + +In order to work around this: +- install the `"web-streams-polyfill"` package +- add `import "web-streams-polyfill/es2018";` to the top of the front matter of every page which requires streams, such as server rendering a React component. \ No newline at end of file From 2fc2d5334b2e9cf510330b6517b362b79aee2ad0 Mon Sep 17 00:00:00 2001 From: Richard Cooke Date: Fri, 24 Jun 2022 20:30:47 +0100 Subject: [PATCH 005/500] fix: `@astrojs/clooudflare` 404 handling (#3695) --- packages/integrations/cloudflare/src/server.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/integrations/cloudflare/src/server.ts b/packages/integrations/cloudflare/src/server.ts index 6a76c06ff48c..032146691ea3 100644 --- a/packages/integrations/cloudflare/src/server.ts +++ b/packages/integrations/cloudflare/src/server.ts @@ -24,6 +24,11 @@ export function createExports(manifest: SSRManifest) { } // 404 + const _404Request = new Request(`${origin}/404`, request); + if (app.match(_404Request)) { + return app.render(_404Request); + } + return new Response(null, { status: 404, statusText: 'Not found', From dac7a99af48329e878cff148d45e4cde365602ac Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 24 Jun 2022 16:05:02 -0400 Subject: [PATCH 006/500] [ci] release (#3701) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 6 ++++++ packages/integrations/cloudflare/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 359165e237bb..88913d64b3de 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/cloudflare +## 0.2.1 + +### Patch Changes + +- [#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 + ## 0.2.0 ### Minor Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index d3f663b2a041..fabb771804c5 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare pages functions", - "version": "0.2.0", + "version": "0.2.1", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", From 41c976d840ce5880aacf4324a3c12929b813d403 Mon Sep 17 00:00:00 2001 From: Tony Sullivan Date: Fri, 1 Jul 2022 02:29:59 +0000 Subject: [PATCH 007/500] Adding an option to disable HTTP streaming (#3777) * Adding a flag to disable HTTP streaming * refactor: adding support for SSG builds * handling string responses in the server runtime, adding tests * removing streaming CLI flag * removing import.meta.env.STREAMING * include Content-Length header when streaming is disabled * Verifying content-length header in dev * fix: default streaming to enabled in the base App server * TEMP: disabling the production test to investigate the test-adapter * re-enabling the test with an adapter option to disable streaming for the test * fix: use the existing TextEncoder to get the body's byte length * moving config to build.streaming, ignoring it in `dev` * fixing dev test to expect response streaming * chore: add changsets * removing the new config option all together :tada: * remove temp debug log * Updating astro changeset now that streaming isn't a config option --- packages/integrations/cloudflare/src/server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/src/server.ts b/packages/integrations/cloudflare/src/server.ts index 032146691ea3..8e7f572c6ed1 100644 --- a/packages/integrations/cloudflare/src/server.ts +++ b/packages/integrations/cloudflare/src/server.ts @@ -8,7 +8,7 @@ type Env = { }; export function createExports(manifest: SSRManifest) { - const app = new App(manifest); + const app = new App(manifest, false); const fetch = async (request: Request, env: Env) => { const { origin, pathname } = new URL(request.url); From 8959e6af0fd38ccd43cbf159464b6189976a15f3 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Thu, 30 Jun 2022 20:09:17 -0700 Subject: [PATCH 008/500] [ci] release (#3783) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 6 ++++++ packages/integrations/cloudflare/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 88913d64b3de..afd4bb183d8c 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/cloudflare +## 0.2.2 + +### Patch Changes + +- [#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 + ## 0.2.1 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index fabb771804c5..54856276acd6 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare pages functions", - "version": "0.2.1", + "version": "0.2.2", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", From 32d4f7cba9b0d6cc308f56db3693ff993a2d71f0 Mon Sep 17 00:00:00 2001 From: Isaac McFadyen <6243993+isaac-mcfadyen@users.noreply.github.com> Date: Fri, 8 Jul 2022 15:47:16 -0400 Subject: [PATCH 009/500] Fixed broken Markdown link (#3868) --- packages/integrations/cloudflare/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index a7f077dc4a5b..898949a5fcb5 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -25,8 +25,8 @@ It's then possible to update the preview script in your `package.json` to `"prev ## Streams -Some integrations such as (react)[https://github.com/withastro/astro/tree/main/packages/integrations/react] rely on web streams. Currently Cloudflare Pages functions are in beta and don't support the `streams_enable_constructors` feature flag. +Some integrations such as [React](https://github.com/withastro/astro/tree/main/packages/integrations/react) rely on web streams. Currently Cloudflare Pages functions are in beta and don't support the `streams_enable_constructors` feature flag. In order to work around this: - install the `"web-streams-polyfill"` package -- add `import "web-streams-polyfill/es2018";` to the top of the front matter of every page which requires streams, such as server rendering a React component. \ No newline at end of file +- add `import "web-streams-polyfill/es2018";` to the top of the front matter of every page which requires streams, such as server rendering a React component. From c3b62f3bf4d07c6dcdd201d42ed77503d44e2042 Mon Sep 17 00:00:00 2001 From: Ben Holmes Date: Fri, 8 Jul 2022 16:55:33 -0400 Subject: [PATCH 010/500] [astro add] Support adapters and third party packages (#3854) * feat: support adapters and third part integrations by keywords * refactor: add keywords to all official integrations * docs: add adapter ex to astro add help * nit: clarify astro add usage * nit: highlight link * fix: use process.exit(1) on error * chore: changeset * nit: bold integration name * fix: log install instructions for adapters instead * nit: change to logAdapterConfigInstructions * Revert "fix: log install instructions for adapters instead" This reverts commit 1a459f152bc7b7991db289999f7393e5be64ea3e. * feat: add hardcoded adapter export map * refactor: inline adapter config log --- packages/integrations/cloudflare/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 54856276acd6..cd4a637b7bf7 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -11,6 +11,7 @@ "url": "https://github.com/withastro/astro.git", "directory": "packages/integrations/cloudflare" }, + "keywords": ["astro-adapter"], "bugs": "https://github.com/withastro/astro/issues", "homepage": "https://astro.build", "exports": { From f110db47b4e7ffc57cfdd3f10bb5ac9353f4bd3a Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Fri, 8 Jul 2022 20:57:10 +0000 Subject: [PATCH 011/500] [ci] format --- packages/integrations/cloudflare/package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index cd4a637b7bf7..425f5aa42dfc 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -11,7 +11,9 @@ "url": "https://github.com/withastro/astro.git", "directory": "packages/integrations/cloudflare" }, - "keywords": ["astro-adapter"], + "keywords": [ + "astro-adapter" + ], "bugs": "https://github.com/withastro/astro/issues", "homepage": "https://astro.build", "exports": { From 9dab33283b57ca04d21f0f91aab2b431fea47063 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Fri, 8 Jul 2022 17:54:39 -0700 Subject: [PATCH 012/500] [ci] release (#3850) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 6 ++++++ packages/integrations/cloudflare/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index afd4bb183d8c..90f1e85af126 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/cloudflare +## 0.2.3 + +### Patch Changes + +- [#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 + ## 0.2.2 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 425f5aa42dfc..f9b16db21a74 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare pages functions", - "version": "0.2.2", + "version": "0.2.3", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", From 7ae9f9f01fddde93cd10bc87efa0fef626df333f Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Mon, 11 Jul 2022 21:10:34 +0200 Subject: [PATCH 013/500] More integration README fixes (#3885) * Integration README fixes * More tweaks (mostly code backticks for filenames) * Update changeset * Few more tweaks * Make sure code blocks all have a code language * Use URLs of new docs pages for package homepage * One more stray `
` :boot: * Standardise to `sh` instead of `shell` --- packages/integrations/cloudflare/README.md | 2 +- packages/integrations/cloudflare/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 898949a5fcb5..3417149b84c0 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -2,7 +2,7 @@ An SSR adapter for use with Cloudflare Pages Functions targets. Write your code in Astro/Node and deploy to Cloudflare Pages. -In your astro.config.mjs use: +In your `astro.config.mjs` use: ```js import { defineConfig } from 'astro/config'; diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index f9b16db21a74..dcfbfe77ea41 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -15,7 +15,7 @@ "astro-adapter" ], "bugs": "https://github.com/withastro/astro/issues", - "homepage": "https://astro.build", + "homepage": "https://docs.astro.build/en/guides/integrations-guide/cloudflare/", "exports": { ".": "./dist/index.js", "./server.js": "./dist/server.js", From bfb6eb6ecfefa810963a13350597d296c1ebd7e8 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Tue, 12 Jul 2022 06:08:15 -0700 Subject: [PATCH 014/500] [ci] release (#3894) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 6 ++++++ packages/integrations/cloudflare/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 90f1e85af126..c6eae1744786 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/cloudflare +## 0.2.4 + +### Patch Changes + +- [#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 + ## 0.2.3 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index dcfbfe77ea41..4835549c0bd7 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare pages functions", - "version": "0.2.3", + "version": "0.2.4", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", From b9ec61f06b00417ad6572ac72f3e5a97a7164ec9 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Tue, 19 Jul 2022 16:10:15 -0400 Subject: [PATCH 015/500] Adds support for Astro.clientAddress (#3973) * Adds support for Astro.clientAddress * Pass through mode and adapterName in SSG * Pass through the mode provided * Provide an adapter specific error message when possible --- packages/integrations/cloudflare/src/server.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/integrations/cloudflare/src/server.ts b/packages/integrations/cloudflare/src/server.ts index 8e7f572c6ed1..07858a7ed250 100644 --- a/packages/integrations/cloudflare/src/server.ts +++ b/packages/integrations/cloudflare/src/server.ts @@ -20,6 +20,7 @@ export function createExports(manifest: SSRManifest) { } if (app.match(request)) { + Reflect.set(request, Symbol.for('astro.clientAddress'), request.headers.get('cf-connecting-ip')); return app.render(request); } From 975e27a1558a723c5a4b9418d38a3a56e855fc4e Mon Sep 17 00:00:00 2001 From: matthewp Date: Tue, 19 Jul 2022 20:11:53 +0000 Subject: [PATCH 016/500] [ci] format --- packages/integrations/cloudflare/src/server.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/src/server.ts b/packages/integrations/cloudflare/src/server.ts index 07858a7ed250..097f29d37cc5 100644 --- a/packages/integrations/cloudflare/src/server.ts +++ b/packages/integrations/cloudflare/src/server.ts @@ -20,7 +20,11 @@ export function createExports(manifest: SSRManifest) { } if (app.match(request)) { - Reflect.set(request, Symbol.for('astro.clientAddress'), request.headers.get('cf-connecting-ip')); + Reflect.set( + request, + Symbol.for('astro.clientAddress'), + request.headers.get('cf-connecting-ip') + ); return app.render(request); } From f4c8b3939727adf744275c2769024dcb83836d6c Mon Sep 17 00:00:00 2001 From: Okiki Ojo Date: Fri, 22 Jul 2022 16:30:17 -0400 Subject: [PATCH 017/500] SSR 404 and 500 routes in adapters (#4018) * fix(WIP): SSR 404 and 500 routes * Implement the feature Co-authored-by: Matthew Phillips --- packages/integrations/cloudflare/src/server.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/integrations/cloudflare/src/server.ts b/packages/integrations/cloudflare/src/server.ts index 097f29d37cc5..7b88c7b1e4d1 100644 --- a/packages/integrations/cloudflare/src/server.ts +++ b/packages/integrations/cloudflare/src/server.ts @@ -19,19 +19,14 @@ export function createExports(manifest: SSRManifest) { return env.ASSETS.fetch(assetRequest); } - if (app.match(request)) { + let routeData = app.match(request, { matchNotFound: true }); + if (routeData) { Reflect.set( request, Symbol.for('astro.clientAddress'), request.headers.get('cf-connecting-ip') ); - return app.render(request); - } - - // 404 - const _404Request = new Request(`${origin}/404`, request); - if (app.match(_404Request)) { - return app.render(_404Request); + return app.render(request, routeData); } return new Response(null, { From 9cb76fb83fd08f325565111ad73badbbd7dab1f6 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Mon, 25 Jul 2022 00:18:02 -0400 Subject: [PATCH 018/500] Add the `output` option (#4015) * Start of work on astroConfig.mode === 'server' * Add tests and more * adapter -> deploy in some places * Add fallback for `adapter` config * Update more tests * Update image tests * Fix clientAddress test * Updates based on PR review * Add a changeset * Update integrations tests + readme * Oops * Remove old option * Rename `mode` to `output` * Update Node adapter test * Update test * fred pass * fred pass * fred pass * fix test Co-authored-by: Fred K. Schott --- packages/integrations/cloudflare/README.md | 1 + packages/integrations/cloudflare/src/index.ts | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 3417149b84c0..d2c886df6820 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -9,6 +9,7 @@ import { defineConfig } from 'astro/config'; import cloudflare from '@astrojs/cloudflare'; export default defineConfig({ + output: 'server', adapter: cloudflare() }); ``` diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index dc65f23ce5b0..7070af17fb95 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -21,6 +21,11 @@ export default function createIntegration(): AstroIntegration { 'astro:config:done': ({ setAdapter, config }) => { setAdapter(getAdapter()); _config = config; + + if(config.output === 'static') { + console.warn(`[@astrojs/cloudflare] \`output: "server"\` is required to use this adapter.`); + console.warn(`[@astrojs/cloudflare] Otherwise, this adapter is not required to deploy a static site to Cloudflare.`); + } }, 'astro:build:start': ({ buildConfig }) => { _buildConfig = buildConfig; From 7e48371a72454b532e6a44c241bff43edd14671a Mon Sep 17 00:00:00 2001 From: FredKSchott Date: Mon, 25 Jul 2022 04:20:38 +0000 Subject: [PATCH 019/500] [ci] format --- packages/integrations/cloudflare/src/index.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 7070af17fb95..29341453cd36 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -22,9 +22,13 @@ export default function createIntegration(): AstroIntegration { setAdapter(getAdapter()); _config = config; - if(config.output === 'static') { - console.warn(`[@astrojs/cloudflare] \`output: "server"\` is required to use this adapter.`); - console.warn(`[@astrojs/cloudflare] Otherwise, this adapter is not required to deploy a static site to Cloudflare.`); + if (config.output === 'static') { + console.warn( + `[@astrojs/cloudflare] \`output: "server"\` is required to use this adapter.` + ); + console.warn( + `[@astrojs/cloudflare] Otherwise, this adapter is not required to deploy a static site to Cloudflare.` + ); } }, 'astro:build:start': ({ buildConfig }) => { From 0394a270efef98795345170aac99756ec2f8f6ac Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Tue, 26 Jul 2022 06:58:38 -0700 Subject: [PATCH 020/500] [ci] release (#3972) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 39 +++++++++++++++++++ packages/integrations/cloudflare/package.json | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index c6eae1744786..4a6cac29ee39 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,44 @@ # @astrojs/cloudflare +## 0.3.0 + +### Minor Changes + +- [#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 + + This change introduces a new "output target" configuration option (`output`). Setting the output target lets you decide the format of your final build, either: + + - `"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. + - `"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. + + If `output` is omitted from your config, the default value `"static"` will be used. + + 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). + + 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: + + ```diff + import { defineConfig } from 'astro/config'; + import netlify from '@astrojs/netlify/functions'; + + export default defineConfig({ + adapter: netlify(), + + output: 'server', + }); + ``` + +* [#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 + +- [#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 + + The new `Astro.clientAddress` property allows you to get the IP address of the requested user. + + ```astro +
Your address { Astro.clientAddress }
+ ``` + + 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. + ## 0.2.4 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 4835549c0bd7..26c4fb30daa1 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare pages functions", - "version": "0.2.4", + "version": "0.3.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", From 97b0157367ec124cd4d9cdfa81335afb8a974baa Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Wed, 27 Jul 2022 11:50:48 -0400 Subject: [PATCH 021/500] Add errors to cloudflare/vercel adapters when no output config (#4068) --- packages/integrations/cloudflare/package.json | 3 ++- packages/integrations/cloudflare/src/index.ts | 10 +++----- .../test/fixtures/no-output/astro.config.mjs | 6 +++++ .../test/fixtures/no-output/package.json | 9 +++++++ .../cloudflare/test/no-output.test.js | 25 +++++++++++++++++++ .../cloudflare/test/test-utils.js | 10 ++++++++ 6 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 packages/integrations/cloudflare/test/fixtures/no-output/astro.config.mjs create mode 100644 packages/integrations/cloudflare/test/fixtures/no-output/package.json create mode 100644 packages/integrations/cloudflare/test/no-output.test.js create mode 100644 packages/integrations/cloudflare/test/test-utils.js diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 26c4fb30daa1..64a9e65a0e62 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -24,7 +24,8 @@ "scripts": { "build": "astro-scripts build \"src/**/*.ts\" && tsc", "build:ci": "astro-scripts build \"src/**/*.ts\"", - "dev": "astro-scripts dev \"src/**/*.ts\"" + "dev": "astro-scripts dev \"src/**/*.ts\"", + "test": "mocha --exit --timeout 20000 test/" }, "dependencies": { "esbuild": "^0.14.42" diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 29341453cd36..37faf690e156 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -23,12 +23,10 @@ export default function createIntegration(): AstroIntegration { _config = config; if (config.output === 'static') { - console.warn( - `[@astrojs/cloudflare] \`output: "server"\` is required to use this adapter.` - ); - console.warn( - `[@astrojs/cloudflare] Otherwise, this adapter is not required to deploy a static site to Cloudflare.` - ); + throw new Error(` + [@astrojs/cloudflare] \`output: "server"\` is required to use this adapter. Otherwise, this adapter is not necessary to deploy a static site to Cloudflare. + +`); } }, 'astro:build:start': ({ buildConfig }) => { diff --git a/packages/integrations/cloudflare/test/fixtures/no-output/astro.config.mjs b/packages/integrations/cloudflare/test/fixtures/no-output/astro.config.mjs new file mode 100644 index 000000000000..b90fd5b24208 --- /dev/null +++ b/packages/integrations/cloudflare/test/fixtures/no-output/astro.config.mjs @@ -0,0 +1,6 @@ +import { defineConfig } from 'astro/config'; +import cloudflare from '@astrojs/cloudflare'; + +export default defineConfig({ + adapter: cloudflare() +}); diff --git a/packages/integrations/cloudflare/test/fixtures/no-output/package.json b/packages/integrations/cloudflare/test/fixtures/no-output/package.json new file mode 100644 index 000000000000..569c30890043 --- /dev/null +++ b/packages/integrations/cloudflare/test/fixtures/no-output/package.json @@ -0,0 +1,9 @@ +{ + "name": "@test/astro-cloudflare-no-output", + "version": "0.0.0", + "private": true, + "dependencies": { + "@astrojs/cloudflare": "workspace:*", + "astro": "workspace:*" + } +} diff --git a/packages/integrations/cloudflare/test/no-output.test.js b/packages/integrations/cloudflare/test/no-output.test.js new file mode 100644 index 000000000000..c82d4521081c --- /dev/null +++ b/packages/integrations/cloudflare/test/no-output.test.js @@ -0,0 +1,25 @@ +import { loadFixture } from './test-utils.js'; +import { expect } from 'chai'; + +describe('Missing output config', () => { + /** @type {import('./test-utils').Fixture} */ + let fixture; + + before(async () => { + fixture = await loadFixture({ + root: './fixtures/no-output/', + }); + }); + + it('throws during the build', async () => { + let error = undefined; + try { + await fixture.build(); + } catch(err) { + error = err; + } + expect(error).to.not.be.equal(undefined); + expect(error.message).to.include(`output: "server"`); + }); +}); + diff --git a/packages/integrations/cloudflare/test/test-utils.js b/packages/integrations/cloudflare/test/test-utils.js new file mode 100644 index 000000000000..6bb3e7c253f7 --- /dev/null +++ b/packages/integrations/cloudflare/test/test-utils.js @@ -0,0 +1,10 @@ +import { loadFixture as baseLoadFixture } from '../../../astro/test/test-utils.js'; + +export { fixLineEndings } from '../../../astro/test/test-utils.js'; + +export function loadFixture(config) { + if (config?.root) { + config.root = new URL(config.root, import.meta.url); + } + return baseLoadFixture(config); +} From be55ba16197d1ec9cf9401241573b46bf726b64e Mon Sep 17 00:00:00 2001 From: matthewp Date: Wed, 27 Jul 2022 15:52:44 +0000 Subject: [PATCH 022/500] [ci] format --- packages/integrations/cloudflare/test/no-output.test.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/test/no-output.test.js b/packages/integrations/cloudflare/test/no-output.test.js index c82d4521081c..af4d9c2b6639 100644 --- a/packages/integrations/cloudflare/test/no-output.test.js +++ b/packages/integrations/cloudflare/test/no-output.test.js @@ -15,11 +15,10 @@ describe('Missing output config', () => { let error = undefined; try { await fixture.build(); - } catch(err) { + } catch (err) { error = err; } expect(error).to.not.be.equal(undefined); expect(error.message).to.include(`output: "server"`); }); }); - From fd3dfba5e192c98f8a61130a5b4f3e746e8d1d40 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Wed, 27 Jul 2022 16:15:19 -0400 Subject: [PATCH 023/500] Fixes cloudflare throwing over process (#4072) * Fixes cloudflare throwing over process * Up the timeout for slower CI servers * Fix linting * Up the timeout a bit --- packages/integrations/cloudflare/package.json | 5 +- packages/integrations/cloudflare/src/index.ts | 8 +++ .../cloudflare/test/basics.test.js | 32 ++++++++++++ .../test/fixtures/basics/astro.config.mjs | 7 +++ .../test/fixtures/basics/package.json | 9 ++++ .../fixtures/basics/src/pages/index.astro | 8 +++ .../cloudflare/test/test-utils.js | 52 +++++++++++++++++++ 7 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 packages/integrations/cloudflare/test/basics.test.js create mode 100644 packages/integrations/cloudflare/test/fixtures/basics/astro.config.mjs create mode 100644 packages/integrations/cloudflare/test/fixtures/basics/package.json create mode 100644 packages/integrations/cloudflare/test/fixtures/basics/src/pages/index.astro diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 64a9e65a0e62..90dd2917ba58 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -25,10 +25,11 @@ "build": "astro-scripts build \"src/**/*.ts\" && tsc", "build:ci": "astro-scripts build \"src/**/*.ts\"", "dev": "astro-scripts dev \"src/**/*.ts\"", - "test": "mocha --exit --timeout 20000 test/" + "test": "mocha --exit --timeout 30000 test/" }, "dependencies": { - "esbuild": "^0.14.42" + "esbuild": "^0.14.42", + "wrangler": "^2.0.23" }, "devDependencies": { "astro": "workspace:*", diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 37faf690e156..99560dfdd4e9 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -11,6 +11,11 @@ export function getAdapter(): AstroAdapter { }; } +const SHIM = `globalThis.process = { + argv: [], + env: {}, +};`; + export default function createIntegration(): AstroIntegration { let _config: AstroConfig; let _buildConfig: BuildConfig; @@ -69,6 +74,9 @@ export default function createIntegration(): AstroIntegration { format: 'esm', bundle: true, minify: true, + banner: { + js: SHIM + } }); // throw the server folder in the bin diff --git a/packages/integrations/cloudflare/test/basics.test.js b/packages/integrations/cloudflare/test/basics.test.js new file mode 100644 index 000000000000..67215374df8f --- /dev/null +++ b/packages/integrations/cloudflare/test/basics.test.js @@ -0,0 +1,32 @@ +import { loadFixture, runCLI } from './test-utils.js'; +import { expect } from 'chai'; +import * as cheerio from 'cheerio'; + +describe('Basic app', () => { + /** @type {import('./test-utils').Fixture} */ + let fixture; + + before(async () => { + fixture = await loadFixture({ + root: './fixtures/basics/', + }); + await fixture.build(); + }); + + it('can render', async () => { + const { ready, stop } = runCLI('./fixtures/basics/', { silent: true }); + + try { + await ready; + + let res = await fetch(`http://localhost:8787/`); + expect(res.status).to.equal(200); + let html = await res.text(); + let $ = cheerio.load(html); + expect($('h1').text()).to.equal('Testing'); + } finally { + await stop(); + } + }); +}); + diff --git a/packages/integrations/cloudflare/test/fixtures/basics/astro.config.mjs b/packages/integrations/cloudflare/test/fixtures/basics/astro.config.mjs new file mode 100644 index 000000000000..bf47a0a330b4 --- /dev/null +++ b/packages/integrations/cloudflare/test/fixtures/basics/astro.config.mjs @@ -0,0 +1,7 @@ +import { defineConfig } from 'astro/config'; +import cloudflare from '@astrojs/cloudflare'; + +export default defineConfig({ + adapter: cloudflare(), + output: 'server', +}); diff --git a/packages/integrations/cloudflare/test/fixtures/basics/package.json b/packages/integrations/cloudflare/test/fixtures/basics/package.json new file mode 100644 index 000000000000..c7cc97455ea1 --- /dev/null +++ b/packages/integrations/cloudflare/test/fixtures/basics/package.json @@ -0,0 +1,9 @@ +{ + "name": "@test/astro-cloudflare-basics", + "version": "0.0.0", + "private": true, + "dependencies": { + "@astrojs/cloudflare": "workspace:*", + "astro": "workspace:*" + } +} diff --git a/packages/integrations/cloudflare/test/fixtures/basics/src/pages/index.astro b/packages/integrations/cloudflare/test/fixtures/basics/src/pages/index.astro new file mode 100644 index 000000000000..9c077e2a381b --- /dev/null +++ b/packages/integrations/cloudflare/test/fixtures/basics/src/pages/index.astro @@ -0,0 +1,8 @@ + + + Testing + + +

Testing

+ + diff --git a/packages/integrations/cloudflare/test/test-utils.js b/packages/integrations/cloudflare/test/test-utils.js index 6bb3e7c253f7..41cc8a2c9413 100644 --- a/packages/integrations/cloudflare/test/test-utils.js +++ b/packages/integrations/cloudflare/test/test-utils.js @@ -1,4 +1,6 @@ import { loadFixture as baseLoadFixture } from '../../../astro/test/test-utils.js'; +import { spawn } from 'child_process'; +import { fileURLToPath } from 'url'; export { fixLineEndings } from '../../../astro/test/test-utils.js'; @@ -8,3 +10,53 @@ export function loadFixture(config) { } return baseLoadFixture(config); } + +const wranglerPath = fileURLToPath(new URL('../node_modules/wrangler/bin/wrangler.js', import.meta.url)); + +export function runCLI(basePath, { silent }) { + const script = fileURLToPath(new URL(`${basePath}/dist/_worker.js`, import.meta.url)); + const p = spawn('node', [wranglerPath, 'dev', '-l', script]); + + p.stderr.setEncoding('utf-8'); + p.stdout.setEncoding('utf-8'); + + const timeout = 10000; + + const ready = new Promise(async (resolve, reject) => { + const failed = setTimeout(() => reject(new Error(`Timed out starting the wrangler CLI`)), timeout); + + (async function () { + for(const msg of p.stderr) { + if(!silent) { + // eslint-disable-next-line + console.error(msg); + } + } + })(); + + for await(const msg of p.stdout) { + if(!silent) { + // eslint-disable-next-line + console.log(msg); + } + if(msg.includes(`Listening on`)) { + break; + } + } + + clearTimeout(failed); + resolve(); + }); + + return { + ready, + stop() { + p.kill(); + return new Promise(resolve => { + p.addListener('exit', () => { + resolve(); + }); + }) + } + } +} From 7f34c60881b551df4113e8f81a4cd48cfb845cce Mon Sep 17 00:00:00 2001 From: matthewp Date: Wed, 27 Jul 2022 20:17:38 +0000 Subject: [PATCH 024/500] [ci] format --- packages/integrations/cloudflare/src/index.ts | 4 +-- .../cloudflare/test/basics.test.js | 1 - .../cloudflare/test/test-utils.js | 27 +++++++++++-------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 99560dfdd4e9..76904ed95b40 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -75,8 +75,8 @@ export default function createIntegration(): AstroIntegration { bundle: true, minify: true, banner: { - js: SHIM - } + js: SHIM, + }, }); // throw the server folder in the bin diff --git a/packages/integrations/cloudflare/test/basics.test.js b/packages/integrations/cloudflare/test/basics.test.js index 67215374df8f..e6fe6642ee44 100644 --- a/packages/integrations/cloudflare/test/basics.test.js +++ b/packages/integrations/cloudflare/test/basics.test.js @@ -29,4 +29,3 @@ describe('Basic app', () => { } }); }); - diff --git a/packages/integrations/cloudflare/test/test-utils.js b/packages/integrations/cloudflare/test/test-utils.js index 41cc8a2c9413..e0f521949466 100644 --- a/packages/integrations/cloudflare/test/test-utils.js +++ b/packages/integrations/cloudflare/test/test-utils.js @@ -11,7 +11,9 @@ export function loadFixture(config) { return baseLoadFixture(config); } -const wranglerPath = fileURLToPath(new URL('../node_modules/wrangler/bin/wrangler.js', import.meta.url)); +const wranglerPath = fileURLToPath( + new URL('../node_modules/wrangler/bin/wrangler.js', import.meta.url) +); export function runCLI(basePath, { silent }) { const script = fileURLToPath(new URL(`${basePath}/dist/_worker.js`, import.meta.url)); @@ -23,23 +25,26 @@ export function runCLI(basePath, { silent }) { const timeout = 10000; const ready = new Promise(async (resolve, reject) => { - const failed = setTimeout(() => reject(new Error(`Timed out starting the wrangler CLI`)), timeout); + const failed = setTimeout( + () => reject(new Error(`Timed out starting the wrangler CLI`)), + timeout + ); (async function () { - for(const msg of p.stderr) { - if(!silent) { + for (const msg of p.stderr) { + if (!silent) { // eslint-disable-next-line console.error(msg); } } })(); - for await(const msg of p.stdout) { - if(!silent) { + for await (const msg of p.stdout) { + if (!silent) { // eslint-disable-next-line console.log(msg); } - if(msg.includes(`Listening on`)) { + if (msg.includes(`Listening on`)) { break; } } @@ -52,11 +57,11 @@ export function runCLI(basePath, { silent }) { ready, stop() { p.kill(); - return new Promise(resolve => { + return new Promise((resolve) => { p.addListener('exit', () => { resolve(); }); - }) - } - } + }); + }, + }; } From 94b5f074b706798c5a0767737d6d9755c84314dc Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Thu, 28 Jul 2022 05:17:45 -0700 Subject: [PATCH 025/500] [ci] release (#4056) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 10 ++++++++++ packages/integrations/cloudflare/package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 4a6cac29ee39..a7731bf1cea2 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,15 @@ # @astrojs/cloudflare +## 0.4.0 + +### Minor Changes + +- [#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 + +### Patch Changes + +- [#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 + ## 0.3.0 ### Minor Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 90dd2917ba58..6c024a4b7b18 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare pages functions", - "version": "0.3.0", + "version": "0.4.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", From 1c7a9ee94191c030102cf72c8d52ff5ba9731914 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Fri, 29 Jul 2022 10:46:09 -0400 Subject: [PATCH 026/500] Prevent hydration scripts from being rendered in the wrong order (#4080) * Prevent hydration scripts from being rendered in the wrong order * Remove comment * Update jsx * Remove promise for stop * Try skipping lit tests * Stringify these chunks too * Unskip lit --- packages/integrations/cloudflare/test/basics.test.js | 2 +- packages/integrations/cloudflare/test/test-utils.js | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/integrations/cloudflare/test/basics.test.js b/packages/integrations/cloudflare/test/basics.test.js index e6fe6642ee44..7e3e9bb93b21 100644 --- a/packages/integrations/cloudflare/test/basics.test.js +++ b/packages/integrations/cloudflare/test/basics.test.js @@ -25,7 +25,7 @@ describe('Basic app', () => { let $ = cheerio.load(html); expect($('h1').text()).to.equal('Testing'); } finally { - await stop(); + stop(); } }); }); diff --git a/packages/integrations/cloudflare/test/test-utils.js b/packages/integrations/cloudflare/test/test-utils.js index e0f521949466..58cb8f9dd6e6 100644 --- a/packages/integrations/cloudflare/test/test-utils.js +++ b/packages/integrations/cloudflare/test/test-utils.js @@ -57,11 +57,6 @@ export function runCLI(basePath, { silent }) { ready, stop() { p.kill(); - return new Promise((resolve) => { - p.addListener('exit', () => { - resolve(); - }); - }); }, }; } From 70077f2d4040b85f10da2c965dea35e7e6ff98aa Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Tue, 2 Aug 2022 10:26:00 -0500 Subject: [PATCH 027/500] chore: skip cloudflare test for now (#4117) Co-authored-by: Nate Moore --- packages/integrations/cloudflare/test/basics.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/test/basics.test.js b/packages/integrations/cloudflare/test/basics.test.js index 7e3e9bb93b21..7127a3f68430 100644 --- a/packages/integrations/cloudflare/test/basics.test.js +++ b/packages/integrations/cloudflare/test/basics.test.js @@ -2,7 +2,7 @@ import { loadFixture, runCLI } from './test-utils.js'; import { expect } from 'chai'; import * as cheerio from 'cheerio'; -describe('Basic app', () => { +describe.skip('Basic app', () => { /** @type {import('./test-utils').Fixture} */ let fixture; From a9e4b59d3080c12e5aa7f336eeadc79cdfd96755 Mon Sep 17 00:00:00 2001 From: Isaac McFadyen <6243993+isaac-mcfadyen@users.noreply.github.com> Date: Tue, 2 Aug 2022 11:26:25 -0400 Subject: [PATCH 028/500] Update README.md (#4119) --- packages/integrations/cloudflare/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index d2c886df6820..3ab29b44486e 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -1,6 +1,6 @@ # @astrojs/cloudflare -An SSR adapter for use with Cloudflare Pages Functions targets. Write your code in Astro/Node and deploy to Cloudflare Pages. +An SSR adapter for use with Cloudflare Pages Functions targets. Write your code in Astro/Javascript and deploy to Cloudflare Pages. In your `astro.config.mjs` use: From 4f87c5eae23d42f212d2889ae751af06c5e2dd6a Mon Sep 17 00:00:00 2001 From: Erika <3019731+Princesseuh@users.noreply.github.com> Date: Tue, 2 Aug 2022 16:08:21 -0400 Subject: [PATCH 029/500] Audit dependencies (#4096) * Remove some unused dependencies * Update lockfile * Add util * Remove util --- packages/integrations/cloudflare/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 6c024a4b7b18..da192ec0c7c6 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -28,11 +28,11 @@ "test": "mocha --exit --timeout 30000 test/" }, "dependencies": { - "esbuild": "^0.14.42", - "wrangler": "^2.0.23" + "esbuild": "^0.14.42" }, "devDependencies": { "astro": "workspace:*", - "astro-scripts": "workspace:*" + "astro-scripts": "workspace:*", + "wrangler": "^2.0.23" } } From 5158b0133beb4984793566ed2eac981fada39764 Mon Sep 17 00:00:00 2001 From: FredKSchott Date: Sat, 6 Aug 2022 04:39:26 +0000 Subject: [PATCH 030/500] [ci] format --- packages/integrations/cloudflare/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index a7731bf1cea2..f1bc70bca12e 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -44,7 +44,7 @@ The new `Astro.clientAddress` property allows you to get the IP address of the requested user. ```astro -
Your address { Astro.clientAddress }
+
Your address {Astro.clientAddress}
``` 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. From e7e298da86a6bdd82a9933d646897106124fe52e Mon Sep 17 00:00:00 2001 From: Richard Cooke Date: Mon, 8 Aug 2022 18:10:48 +0100 Subject: [PATCH 031/500] feat: add support to `@astrojs/cloudflare` directory deploy mode (#3806) Co-authored-by: Matthew Phillips Co-authored-by: Nate Moore --- packages/integrations/cloudflare/README.md | 23 +++++++++++ packages/integrations/cloudflare/package.json | 3 +- packages/integrations/cloudflare/src/index.ts | 37 ++++++++++++----- .../src/{server.ts => server.advanced.ts} | 0 .../cloudflare/src/server.directory.ts | 41 +++++++++++++++++++ 5 files changed, 93 insertions(+), 11 deletions(-) rename packages/integrations/cloudflare/src/{server.ts => server.advanced.ts} (100%) create mode 100644 packages/integrations/cloudflare/src/server.directory.ts diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 3ab29b44486e..1bd65f5aed2e 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -14,6 +14,29 @@ export default defineConfig({ }); ``` +## Options + + +### Mode + +`mode: "advanced" | "directory"` + +default `"advanced"` + +Cloudflare Pages has 2 different modes for deploying functions, `advanced` mode which picks up the `_worker.js` in `dist`, or a directory mode where pages will compile the worker out of a functions folder in the project root. + +For most projects the adaptor default of `advanced` will be sufficiant, when in this mode the `dist` folder will contain your compiled project. However if you'd like to use [pages plugins](https://developers.cloudflare.com/pages/platform/functions/plugins/) such as [Sentry](https://developers.cloudflare.com/pages/platform/functions/plugins/sentry/) for example to enable logging, you'll need to use directory mode. + +In directory mode the adaptor will compile the client side part of you app the same way, but it will move the worker script into a `functions` folder in the project root. The adaptor will only ever place a `[[path]].js` in that folder, allowing you to add additional plugins and pages middlewhere which can be checked into version control . + +```ts +// directory mode +export default defineConfig({ + adapter: cloudflare({ mode: "directory" }), +}); + +``` + ## Enabling Preview In order for preview to work you must install `wrangler` diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index da192ec0c7c6..0056cec12c70 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -18,7 +18,8 @@ "homepage": "https://docs.astro.build/en/guides/integrations-guide/cloudflare/", "exports": { ".": "./dist/index.js", - "./server.js": "./dist/server.js", + "./server.advanced.js": "./dist/server.advanced.js", + "./server.directory.js": "./dist/server.directory.js", "./package.json": "./package.json" }, "scripts": { diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 76904ed95b40..e207bdb44b16 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -3,12 +3,22 @@ import esbuild from 'esbuild'; import * as fs from 'fs'; import { fileURLToPath } from 'url'; -export function getAdapter(): AstroAdapter { - return { - name: '@astrojs/cloudflare', - serverEntrypoint: '@astrojs/cloudflare/server.js', - exports: ['default'], - }; +type Options = { + mode: 'directory' | 'advanced'; +}; + +export function getAdapter(isModeDirectory: boolean): AstroAdapter { + return isModeDirectory + ? { + name: '@astrojs/cloudflare', + serverEntrypoint: '@astrojs/cloudflare/server.directory.js', + exports: ['onRequest'], + } + : { + name: '@astrojs/cloudflare', + serverEntrypoint: '@astrojs/cloudflare/server.advanced.js', + exports: ['default'], + }; } const SHIM = `globalThis.process = { @@ -16,15 +26,16 @@ const SHIM = `globalThis.process = { env: {}, };`; -export default function createIntegration(): AstroIntegration { +export default function createIntegration(args?: Options): AstroIntegration { let _config: AstroConfig; let _buildConfig: BuildConfig; + const isModeDirectory = args?.mode === 'directory'; return { name: '@astrojs/cloudflare', hooks: { 'astro:config:done': ({ setAdapter, config }) => { - setAdapter(getAdapter()); + setAdapter(getAdapter(isModeDirectory)); _config = config; if (config.output === 'static') { @@ -36,8 +47,8 @@ export default function createIntegration(): AstroIntegration { }, 'astro:build:start': ({ buildConfig }) => { _buildConfig = buildConfig; - buildConfig.serverEntry = '_worker.js'; buildConfig.client = new URL('./static/', _config.outDir); + buildConfig.serverEntry = '_worker.js'; buildConfig.server = new URL('./', _config.outDir); }, 'astro:build:setup': ({ vite, target }) => { @@ -64,7 +75,6 @@ export default function createIntegration(): AstroIntegration { 'astro:build:done': async () => { const entryUrl = new URL(_buildConfig.serverEntry, _buildConfig.server); const pkg = fileURLToPath(entryUrl); - await esbuild.build({ target: 'es2020', platform: 'browser', @@ -82,6 +92,13 @@ export default function createIntegration(): AstroIntegration { // throw the server folder in the bin const chunksUrl = new URL('./chunks', _buildConfig.server); await fs.promises.rm(chunksUrl, { recursive: true, force: true }); + + if (isModeDirectory) { + const functionsUrl = new URL(`file://${process.cwd()}/functions/`); + await fs.promises.mkdir(functionsUrl, { recursive: true }); + const directoryUrl = new URL('[[path]].js', functionsUrl); + await fs.promises.rename(entryUrl, directoryUrl); + } }, }, }; diff --git a/packages/integrations/cloudflare/src/server.ts b/packages/integrations/cloudflare/src/server.advanced.ts similarity index 100% rename from packages/integrations/cloudflare/src/server.ts rename to packages/integrations/cloudflare/src/server.advanced.ts diff --git a/packages/integrations/cloudflare/src/server.directory.ts b/packages/integrations/cloudflare/src/server.directory.ts new file mode 100644 index 000000000000..abcc49b1079a --- /dev/null +++ b/packages/integrations/cloudflare/src/server.directory.ts @@ -0,0 +1,41 @@ +import './shim.js'; + +import type { SSRManifest } from 'astro'; +import { App } from 'astro/app'; + +export function createExports(manifest: SSRManifest) { + const app = new App(manifest, false) + + const onRequest = async ({ + request, + next, + }: { + request: Request; + next: (request: Request) => void; + }) => { + const { origin, pathname } = new URL(request.url); + + // static assets + if (manifest.assets.has(pathname)) { + const assetRequest = new Request(`${origin}/static${pathname}`, request); + return next(assetRequest); + } + + let routeData = app.match(request, { matchNotFound: true }); + if (routeData) { + Reflect.set( + request, + Symbol.for('astro.clientAddress'), + request.headers.get('cf-connecting-ip') + ); + return app.render(request, routeData); + } + + return new Response(null, { + status: 404, + statusText: 'Not found', + }); + }; + + return { onRequest }; +} From fcc43086aa7bcf3f63c9a1d49a53944ee54bac85 Mon Sep 17 00:00:00 2001 From: natemoo-re Date: Mon, 8 Aug 2022 17:12:48 +0000 Subject: [PATCH 032/500] [ci] format --- packages/integrations/cloudflare/src/server.directory.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/src/server.directory.ts b/packages/integrations/cloudflare/src/server.directory.ts index abcc49b1079a..58e83be34f05 100644 --- a/packages/integrations/cloudflare/src/server.directory.ts +++ b/packages/integrations/cloudflare/src/server.directory.ts @@ -4,7 +4,7 @@ import type { SSRManifest } from 'astro'; import { App } from 'astro/app'; export function createExports(manifest: SSRManifest) { - const app = new App(manifest, false) + const app = new App(manifest, false); const onRequest = async ({ request, From 8b99c153931ab2c2baf32059595b0bb6c0c1ccc9 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Mon, 8 Aug 2022 16:10:55 -0700 Subject: [PATCH 033/500] [ci] release (#4197) * [ci] release * Update CHANGELOG.md Co-authored-by: github-actions[bot] Co-authored-by: Nate Moore --- packages/integrations/cloudflare/CHANGELOG.md | 8 +++++++- packages/integrations/cloudflare/package.json | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index f1bc70bca12e..ee8eba2d4ab3 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/cloudflare +## 0.5.0 + +### Minor Changes + +- [#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` + ## 0.4.0 ### Minor Changes @@ -44,7 +50,7 @@ The new `Astro.clientAddress` property allows you to get the IP address of the requested user. ```astro -
Your address {Astro.clientAddress}
+ ``` 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. diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 0056cec12c70..c254ada381aa 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare pages functions", - "version": "0.4.0", + "version": "0.5.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", From bdb21aeb03ad1a0d717d56cc6e63f1a64e4b8dfa Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Tue, 9 Aug 2022 11:10:25 -0500 Subject: [PATCH 034/500] Astro 1.0.0 (#4214) * chore: remove changesets patch * chore: add changesets * chore: version packages * chore: normalize formatting * chore: update lockfile * chore: fix codeblocks * Update packages/astro/CHANGELOG.md Co-authored-by: Sarah Rainsberger * Update packages/astro/CHANGELOG.md Co-authored-by: Sarah Rainsberger * Update packages/astro/CHANGELOG.md Co-authored-by: Sarah Rainsberger * chore: fixup code samples * chore: move v0.25 message out of note Co-authored-by: Nate Moore Co-authored-by: Sarah Rainsberger --- packages/integrations/cloudflare/CHANGELOG.md | 10 +++++++++- packages/integrations/cloudflare/package.json | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index ee8eba2d4ab3..9280f7081f01 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,13 @@ # @astrojs/cloudflare +## 1.0.0 + +### Major Changes + +- [`04ad44563`](https://github.com/withastro/astro/commit/04ad445632c67bdd60c1704e1e0dcbcaa27b9308) - > Astro v1.0 is out! Read the [official announcement post](https://astro.build/blog/astro-1/). + + **No breaking changes**. This package is now officially stable and compatible with `astro@1.0.0`! + ## 0.5.0 ### Minor Changes @@ -50,7 +58,7 @@ The new `Astro.clientAddress` property allows you to get the IP address of the requested user. ```astro - +
Your address {Astro.clientAddress}
``` 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. diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index c254ada381aa..1c13bdbefde5 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare pages functions", - "version": "0.5.0", + "version": "1.0.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", From e054d2e1b5e49f91934dac2e14dcc16ebb84706c Mon Sep 17 00:00:00 2001 From: Obinna Ekwuno Date: Wed, 10 Aug 2022 20:11:19 +0100 Subject: [PATCH 035/500] [Docs]: Update Cloudflare README (#4232) * update cloudflare readme * Create modern-papayas-rhyme.md Co-authored-by: Nate Moore --- packages/integrations/cloudflare/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 1bd65f5aed2e..2ca3bfac5e84 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -27,7 +27,7 @@ Cloudflare Pages has 2 different modes for deploying functions, `advanced` mode For most projects the adaptor default of `advanced` will be sufficiant, when in this mode the `dist` folder will contain your compiled project. However if you'd like to use [pages plugins](https://developers.cloudflare.com/pages/platform/functions/plugins/) such as [Sentry](https://developers.cloudflare.com/pages/platform/functions/plugins/sentry/) for example to enable logging, you'll need to use directory mode. -In directory mode the adaptor will compile the client side part of you app the same way, but it will move the worker script into a `functions` folder in the project root. The adaptor will only ever place a `[[path]].js` in that folder, allowing you to add additional plugins and pages middlewhere which can be checked into version control . +In directory mode the adaptor will compile the client side part of you app the same way, but it will move the worker script into a `functions` folder in the project root. The adaptor will only ever place a `[[path]].js` in that folder, allowing you to add additional plugins and pages middleware which can be checked into version control. ```ts // directory mode @@ -45,7 +45,7 @@ In order for preview to work you must install `wrangler` $ pnpm install wrangler --save-dev ``` -It's then possible to update the preview script in your `package.json` to `"preview": "wrangler pages dev ./dist"` +It's then possible to update the preview script in your `package.json` to `"preview": "wrangler pages dev ./dist"`.This will allow you run your entire application locally with [Wrangler](https://github.com/cloudflare/wrangler2), which supports secrets, environment variables, KV namespaces, Durable Objects and [all other supported Cloudflare bindings](https://developers.cloudflare.com/pages/platform/functions/#adding-bindings). ## Streams @@ -54,3 +54,4 @@ Some integrations such as [React](https://github.com/withastro/astro/tree/main/p In order to work around this: - install the `"web-streams-polyfill"` package - add `import "web-streams-polyfill/es2018";` to the top of the front matter of every page which requires streams, such as server rendering a React component. + From a58cdcb8cba814d0153152de68345532ead4cde3 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Wed, 10 Aug 2022 13:54:12 -0700 Subject: [PATCH 036/500] [ci] release (#4228) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 8 +++++++- packages/integrations/cloudflare/package.json | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 9280f7081f01..4014369f039c 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/cloudflare +## 1.0.1 + +### Patch Changes + +- [#4232](https://github.com/withastro/astro/pull/4232) [`bfbd32588`](https://github.com/withastro/astro/commit/bfbd32588f7e2c0a9e43cd1a571a0dc9c5f7e645) Thanks [@Ekwuno](https://github.com/Ekwuno)! - Update README + ## 1.0.0 ### Major Changes @@ -58,7 +64,7 @@ The new `Astro.clientAddress` property allows you to get the IP address of the requested user. ```astro -
Your address {Astro.clientAddress}
+ ``` 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. diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 1c13bdbefde5..c5341d7d0218 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare pages functions", - "version": "1.0.0", + "version": "1.0.1", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", From 2d2e29db60290f5ab873e7375c9f6b1b440cd19c Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Fri, 26 Aug 2022 21:03:22 +0800 Subject: [PATCH 037/500] Note private env var handling with cloudflare builds (#4490) --- packages/integrations/cloudflare/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 2ca3bfac5e84..bb59b565853c 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -55,3 +55,17 @@ In order to work around this: - install the `"web-streams-polyfill"` package - add `import "web-streams-polyfill/es2018";` to the top of the front matter of every page which requires streams, such as server rendering a React component. +## Environment Variables + +As Cloudflare Pages Functions [provides environment variables differently](https://developers.cloudflare.com/pages/platform/functions/#adding-environment-variables-locally), private environment variables needs to be set through [`vite.define`](https://vitejs.dev/config/shared-options.html#define) to work in builds. + +```js +// astro.config.mjs +export default { + vite: { + define: { + 'process.env.MY_SECRET': JSON.stringify(process.env.MY_SECRET), + }, + }, +} +``` From 59f2919c60a91d90525b0752d842f4f3e3bcc388 Mon Sep 17 00:00:00 2001 From: Tony Sullivan Date: Tue, 30 Aug 2022 20:19:19 +0000 Subject: [PATCH 038/500] Adds the "withastro" keyword to adapter packages (#4558) * adds the "withastro" keyword to adapter packages * chore: add changeset --- packages/integrations/cloudflare/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index c5341d7d0218..9b08b986bf58 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -12,6 +12,7 @@ "directory": "packages/integrations/cloudflare" }, "keywords": [ + "withastro", "astro-adapter" ], "bugs": "https://github.com/withastro/astro/issues", From 0d5e7c015b1a8c8fbf1bbe4c10de15372450fad6 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Wed, 31 Aug 2022 15:03:27 -0700 Subject: [PATCH 039/500] [ci] release (#4555) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 6 ++++++ packages/integrations/cloudflare/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 4014369f039c..8f8a9f806b06 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/cloudflare +## 1.0.2 + +### Patch Changes + +- [#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) + ## 1.0.1 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 9b08b986bf58..867948ef7d0d 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare pages functions", - "version": "1.0.1", + "version": "1.0.2", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", From bd7bcbd39002309ce4197843a64a413cea7ff276 Mon Sep 17 00:00:00 2001 From: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> Date: Sat, 3 Sep 2022 17:23:44 -0300 Subject: [PATCH 040/500] Add deploy guides links to integrations READMEs (#4612) --- packages/integrations/cloudflare/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index bb59b565853c..610d5c36ba79 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -2,6 +2,8 @@ An SSR adapter for use with Cloudflare Pages Functions targets. Write your code in Astro/Javascript and deploy to Cloudflare Pages. +Learn how to deploy your Astro site in our [Cloudflare Pages deployment guide](https://docs.astro.build/en/guides/deploy/cloudflare/). + In your `astro.config.mjs` use: ```js From b1c2fe6f41657d26eb7e099fb6ea42c2e211f8ec Mon Sep 17 00:00:00 2001 From: Sarah Rainsberger Date: Tue, 6 Sep 2022 09:53:47 -0300 Subject: [PATCH 041/500] [docs] update adapter READMESs to include astro add (#4595) * update adapter READMES to include astro add * missing space Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> Co-authored-by: Matthew Phillips --- packages/integrations/cloudflare/README.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 610d5c36ba79..8351a8c74c58 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -2,11 +2,25 @@ An SSR adapter for use with Cloudflare Pages Functions targets. Write your code in Astro/Javascript and deploy to Cloudflare Pages. -Learn how to deploy your Astro site in our [Cloudflare Pages deployment guide](https://docs.astro.build/en/guides/deploy/cloudflare/). +## Install -In your `astro.config.mjs` use: +Add the Cloudflare adapter to enable SSR in your Astro project with the following `astro add` command. This will install the adapter and make the appropriate changes to your `astro.config.mjs` file in one step. -```js +```bash +npx astro add cloudflare +``` + +If you prefer to install the adapter manually instead, complete the following two steps: + +1. Add the Cloudflare adapter to your project's dependencies using your preferred package manager. If you’re using npm or aren’t sure, run this in the terminal: + +```bash +npm install @astrojs/cloudflare +``` + +2. Add the following to your `astro.config.mjs` file: + +```js title="astro.config.mjs" ins={2, 5-6} import { defineConfig } from 'astro/config'; import cloudflare from '@astrojs/cloudflare'; From d36d27acf3d07241defe06a228b445099ed94355 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 20 Sep 2022 18:36:58 +0200 Subject: [PATCH 042/500] update cloudflare esbuild config (fixing solid ssr) (#4815) * fixing esbuild platform setting, to enable solid build * added changeset * changed change to major Co-authored-by: AirBorne04 --- packages/integrations/cloudflare/src/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index e207bdb44b16..357f8a0640f4 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -67,8 +67,8 @@ export default function createIntegration(args?: Options): AstroIntegration { } vite.ssr = { - target: 'webworker', - noExternal: true, + ...vite.ssr, + target: 'webworker' }; } }, @@ -77,7 +77,9 @@ export default function createIntegration(args?: Options): AstroIntegration { const pkg = fileURLToPath(entryUrl); await esbuild.build({ target: 'es2020', - platform: 'browser', + platform: 'neutral', + mainFields: ['main', 'module'], + conditions: ['worker', 'node'], entryPoints: [pkg], outfile: pkg, allowOverwrite: true, From e3fc6d8dc14d8acb6f4c6ab833f571e2b07f0e39 Mon Sep 17 00:00:00 2001 From: matthewp Date: Tue, 20 Sep 2022 16:39:24 +0000 Subject: [PATCH 043/500] [ci] format --- packages/integrations/cloudflare/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 357f8a0640f4..ef7dec2d4cd2 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -68,7 +68,7 @@ export default function createIntegration(args?: Options): AstroIntegration { vite.ssr = { ...vite.ssr, - target: 'webworker' + target: 'webworker', }; } }, From 7406623468c4cb8985977f9e2f79cddb98592d21 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Tue, 20 Sep 2022 12:15:54 -0700 Subject: [PATCH 044/500] [ci] release (#4811) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 6 ++++++ packages/integrations/cloudflare/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 8f8a9f806b06..bfaa560130c3 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/cloudflare +## 2.0.0 + +### Major Changes + +- [#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) + ## 1.0.2 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 867948ef7d0d..1b018167d290 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare pages functions", - "version": "1.0.2", + "version": "2.0.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", From b0dd82d92516902a1994ccaf31d140d2b9a3865e Mon Sep 17 00:00:00 2001 From: Michael Rienstra Date: Thu, 22 Sep 2022 04:16:02 -0700 Subject: [PATCH 045/500] docs: integrations: yarn & pnpm (#4836) --- packages/integrations/cloudflare/README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 8351a8c74c58..0f5609d5c320 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -6,8 +6,13 @@ An SSR adapter for use with Cloudflare Pages Functions targets. Write your code Add the Cloudflare adapter to enable SSR in your Astro project with the following `astro add` command. This will install the adapter and make the appropriate changes to your `astro.config.mjs` file in one step. -```bash +```sh +# Using NPM npx astro add cloudflare +# Using Yarn +yarn astro add cloudflare +# Using PNPM +pnpm astro add cloudflare ``` If you prefer to install the adapter manually instead, complete the following two steps: From e7708fdf0d9708aeea7ea8f393df64ae6adefe6c Mon Sep 17 00:00:00 2001 From: Jake Strawn Date: Mon, 26 Sep 2022 10:14:34 -0400 Subject: [PATCH 046/500] docs: Standardize common integration READMEs (#4874) --- packages/integrations/cloudflare/README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 0f5609d5c320..80d7808ae82a 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -90,3 +90,15 @@ export default { }, } ``` + +## Troubleshooting + +For help, check out the `#support` channel on [Discord](https://astro.build/chat). Our friendly Support Squad members are here to help! + +You can also check our [Astro Integration Documentation][astro-integration] for more on integrations. + +## Contributing + +This package is maintained by Astro's Core team. You're welcome to submit an issue or PR! + +[astro-integration]: https://docs.astro.build/en/guides/integrations-guide/ From cee8fd8114ac4608ac83787359201373bb908c5c Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Wed, 28 Sep 2022 23:13:33 +0800 Subject: [PATCH 047/500] Remove shamefully-hoist (#4842) --- packages/integrations/cloudflare/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 1b018167d290..b3745557c15e 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -35,6 +35,9 @@ "devDependencies": { "astro": "workspace:*", "astro-scripts": "workspace:*", + "chai": "^4.3.6", + "cheerio": "^1.0.0-rc.11", + "mocha": "^9.2.2", "wrangler": "^2.0.23" } } From a8172ea926b1d5f9b6ed1303e81ed67c533df781 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Wed, 28 Sep 2022 16:55:27 -0400 Subject: [PATCH 048/500] Astro.cookies implementation (#4876) * Astro.cookies implementation * Remove unused var * Fix build * Add a changesetp * Remove spoken-word expires --- .../integrations/cloudflare/src/server.advanced.ts | 10 +++++++++- .../integrations/cloudflare/src/server.directory.ts | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/src/server.advanced.ts b/packages/integrations/cloudflare/src/server.advanced.ts index 7b88c7b1e4d1..62adb44ece00 100644 --- a/packages/integrations/cloudflare/src/server.advanced.ts +++ b/packages/integrations/cloudflare/src/server.advanced.ts @@ -26,7 +26,15 @@ export function createExports(manifest: SSRManifest) { Symbol.for('astro.clientAddress'), request.headers.get('cf-connecting-ip') ); - return app.render(request, routeData); + let response = await app.render(request, routeData); + + if(app.setCookieHeaders) { + for(const setCookieHeader of app.setCookieHeaders(response)) { + response.headers.append('Set-Cookie', setCookieHeader); + } + } + + return response; } return new Response(null, { diff --git a/packages/integrations/cloudflare/src/server.directory.ts b/packages/integrations/cloudflare/src/server.directory.ts index 58e83be34f05..7a484378cca0 100644 --- a/packages/integrations/cloudflare/src/server.directory.ts +++ b/packages/integrations/cloudflare/src/server.directory.ts @@ -28,7 +28,15 @@ export function createExports(manifest: SSRManifest) { Symbol.for('astro.clientAddress'), request.headers.get('cf-connecting-ip') ); - return app.render(request, routeData); + let response = await app.render(request, routeData); + + if(app.setCookieHeaders) { + for(const setCookieHeader of app.setCookieHeaders(response)) { + response.headers.append('Set-Cookie', setCookieHeader); + } + } + + return response; } return new Response(null, { From 56fd9e49f1816a78cf2c85e08c03768737851bce Mon Sep 17 00:00:00 2001 From: matthewp Date: Wed, 28 Sep 2022 20:57:35 +0000 Subject: [PATCH 049/500] [ci] format --- packages/integrations/cloudflare/src/server.advanced.ts | 4 ++-- packages/integrations/cloudflare/src/server.directory.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/integrations/cloudflare/src/server.advanced.ts b/packages/integrations/cloudflare/src/server.advanced.ts index 62adb44ece00..c285ccaba044 100644 --- a/packages/integrations/cloudflare/src/server.advanced.ts +++ b/packages/integrations/cloudflare/src/server.advanced.ts @@ -28,8 +28,8 @@ export function createExports(manifest: SSRManifest) { ); let response = await app.render(request, routeData); - if(app.setCookieHeaders) { - for(const setCookieHeader of app.setCookieHeaders(response)) { + if (app.setCookieHeaders) { + for (const setCookieHeader of app.setCookieHeaders(response)) { response.headers.append('Set-Cookie', setCookieHeader); } } diff --git a/packages/integrations/cloudflare/src/server.directory.ts b/packages/integrations/cloudflare/src/server.directory.ts index 7a484378cca0..e51d0ea57c7a 100644 --- a/packages/integrations/cloudflare/src/server.directory.ts +++ b/packages/integrations/cloudflare/src/server.directory.ts @@ -30,8 +30,8 @@ export function createExports(manifest: SSRManifest) { ); let response = await app.render(request, routeData); - if(app.setCookieHeaders) { - for(const setCookieHeader of app.setCookieHeaders(response)) { + if (app.setCookieHeaders) { + for (const setCookieHeader of app.setCookieHeaders(response)) { response.headers.append('Set-Cookie', setCookieHeader); } } From 35fe8e85f8ea4446b2ab1825ff173205832cec54 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Thu, 29 Sep 2022 08:20:00 -0700 Subject: [PATCH 050/500] [ci] release (#4903) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 49 +++++++++++++++++++ packages/integrations/cloudflare/package.json | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index bfaa560130c3..b694af33f516 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,54 @@ # @astrojs/cloudflare +## 2.1.0 + +### Minor Changes + +- [#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 + + `Astro.cookies` is a new API for manipulating cookies in Astro components and API routes. + + 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`): + + ```astro + --- + type Prefs = { + darkMode: boolean; + }; + + Astro.cookies.set( + 'prefs', + { darkMode: true }, + { + expires: '1 month', + } + ); + + const prefs = Astro.cookies.get('prefs').json(); + --- + + + ``` + + Once you've set a cookie with Astro.cookies it will automatically be included in the outgoing response. + + This API is also available with the same functionality in API routes: + + ```js + export function post({ cookies }) { + cookies.set('loggedIn', false); + + return new Response(null, { + status: 302, + headers: { + Location: '/login', + }, + }); + } + ``` + + See [the RFC](https://github.com/withastro/rfcs/blob/main/proposals/0025-cookie-management.md) to learn more. + ## 2.0.0 ### Major Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index b3745557c15e..d38017176756 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare pages functions", - "version": "2.0.0", + "version": "2.1.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", From 198fa7d3c677759393f5c3c3fa9db5a2ead9ad08 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 6 Oct 2022 16:28:47 +0200 Subject: [PATCH 051/500] adjusting cloudflare adapter and solid ssr to work together (#4888) * adjusting cloudflare adapter (respecting user config) define better solid ssr config * only inline the framework this needs to happen for worker build in order to have the correct build mode for the framework, which needs the nodejs no matter if it is for node or the browser. Co-authored-by: AirBorne04 --- packages/integrations/cloudflare/src/index.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index ef7dec2d4cd2..13c8578eeb8d 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -65,11 +65,8 @@ export default function createIntegration(args?: Options): AstroIntegration { (vite.resolve.alias as Record)[alias.find] = alias.replacement; } } - - vite.ssr = { - ...vite.ssr, - target: 'webworker', - }; + vite.ssr = vite.ssr || {}; + vite.ssr.target = vite.ssr.target || 'webworker'; } }, 'astro:build:done': async () => { @@ -77,9 +74,7 @@ export default function createIntegration(args?: Options): AstroIntegration { const pkg = fileURLToPath(entryUrl); await esbuild.build({ target: 'es2020', - platform: 'neutral', - mainFields: ['main', 'module'], - conditions: ['worker', 'node'], + platform: 'browser', entryPoints: [pkg], outfile: pkg, allowOverwrite: true, From 9208dd2834a0f9f0009017ccc6f2c70146f0d75e Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Thu, 6 Oct 2022 10:47:10 -0700 Subject: [PATCH 052/500] [ci] release (#4976) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 7 +++++++ packages/integrations/cloudflare/package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index b694af33f516..6eb0368ced60 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,12 @@ # @astrojs/cloudflare +## 3.0.0 + +### Major Changes + +- [#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) + adjusting the ssr settings for solidjs (to build for node) + ## 2.1.0 ### Minor Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index d38017176756..94834b609c0e 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare pages functions", - "version": "2.1.0", + "version": "3.0.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", From decef13fc06310adaeb14efa8b758de526b6413f Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Wed, 12 Oct 2022 17:25:51 -0400 Subject: [PATCH 053/500] Node.js standalone mode + support for astro preview (#5056) * wip * Deprecate buildConfig and move to config.build * Implement the standalone server * Stay backwards compat * Add changesets * correctly merge URLs * Get config earlier * update node tests * Return the preview server * update remaining tests * swap usage and config ordering * Update packages/astro/src/@types/astro.ts Co-authored-by: Sarah Rainsberger * Update .changeset/metal-pumas-walk.md Co-authored-by: Sarah Rainsberger * Update .changeset/metal-pumas-walk.md Co-authored-by: Sarah Rainsberger * Update .changeset/stupid-points-refuse.md Co-authored-by: Sarah Rainsberger * Update .changeset/stupid-points-refuse.md Co-authored-by: Sarah Rainsberger * Link to build.server config Co-authored-by: Fred K. Schott Co-authored-by: Sarah Rainsberger --- packages/integrations/cloudflare/src/index.ts | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 13c8578eeb8d..9cf6412b8f27 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -1,4 +1,4 @@ -import type { AstroAdapter, AstroConfig, AstroIntegration, BuildConfig } from 'astro'; +import type { AstroAdapter, AstroConfig, AstroIntegration } from 'astro'; import esbuild from 'esbuild'; import * as fs from 'fs'; import { fileURLToPath } from 'url'; @@ -7,6 +7,12 @@ type Options = { mode: 'directory' | 'advanced'; }; +interface BuildConfig { + server: URL; + client: URL; + serverEntry: string; +} + export function getAdapter(isModeDirectory: boolean): AstroAdapter { return isModeDirectory ? { @@ -29,14 +35,26 @@ const SHIM = `globalThis.process = { export default function createIntegration(args?: Options): AstroIntegration { let _config: AstroConfig; let _buildConfig: BuildConfig; + let needsBuildConfig = false; const isModeDirectory = args?.mode === 'directory'; return { name: '@astrojs/cloudflare', hooks: { + 'astro:config:setup': ({ config, updateConfig }) => { + needsBuildConfig = !config.build.client; + updateConfig({ + build: { + client: new URL('./static/', config.outDir), + server: new URL('./', config.outDir), + serverEntry: '_worker.js', + } + }); + }, 'astro:config:done': ({ setAdapter, config }) => { setAdapter(getAdapter(isModeDirectory)); _config = config; + _buildConfig = config.build; if (config.output === 'static') { throw new Error(` @@ -45,12 +63,6 @@ export default function createIntegration(args?: Options): AstroIntegration { `); } }, - 'astro:build:start': ({ buildConfig }) => { - _buildConfig = buildConfig; - buildConfig.client = new URL('./static/', _config.outDir); - buildConfig.serverEntry = '_worker.js'; - buildConfig.server = new URL('./', _config.outDir); - }, 'astro:build:setup': ({ vite, target }) => { if (target === 'server') { vite.resolve = vite.resolve || {}; @@ -69,6 +81,14 @@ export default function createIntegration(args?: Options): AstroIntegration { vite.ssr.target = vite.ssr.target || 'webworker'; } }, + 'astro:build:start': ({ buildConfig }) => { + // Backwards compat + if(needsBuildConfig) { + buildConfig.client = new URL('./static/', _config.outDir); + buildConfig.server = new URL('./', _config.outDir); + buildConfig.serverEntry = '_worker.js'; + } + }, 'astro:build:done': async () => { const entryUrl = new URL(_buildConfig.serverEntry, _buildConfig.server); const pkg = fileURLToPath(entryUrl); From 00aa4fd09c407d9d8f2e4fcfa213ba288427195b Mon Sep 17 00:00:00 2001 From: matthewp Date: Wed, 12 Oct 2022 21:27:56 +0000 Subject: [PATCH 054/500] [ci] format --- packages/integrations/cloudflare/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 9cf6412b8f27..44112e8be15c 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -48,7 +48,7 @@ export default function createIntegration(args?: Options): AstroIntegration { client: new URL('./static/', config.outDir), server: new URL('./', config.outDir), serverEntry: '_worker.js', - } + }, }); }, 'astro:config:done': ({ setAdapter, config }) => { @@ -83,7 +83,7 @@ export default function createIntegration(args?: Options): AstroIntegration { }, 'astro:build:start': ({ buildConfig }) => { // Backwards compat - if(needsBuildConfig) { + if (needsBuildConfig) { buildConfig.client = new URL('./static/', _config.outDir); buildConfig.server = new URL('./', _config.outDir); buildConfig.serverEntry = '_worker.js'; From 78834686e01d8d592365c21776e3bf37bdd0f926 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Thu, 13 Oct 2022 09:29:24 -0700 Subject: [PATCH 055/500] [ci] release (#5046) * [ci] release * Update packages/integrations/node/CHANGELOG.md Co-authored-by: Sarah Rainsberger Co-authored-by: github-actions[bot] Co-authored-by: Matthew Phillips Co-authored-by: Sarah Rainsberger --- packages/integrations/cloudflare/CHANGELOG.md | 44 +++++++++++++++++++ packages/integrations/cloudflare/package.json | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 6eb0368ced60..19c246cdfbdb 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,49 @@ # @astrojs/cloudflare +## 3.1.0 + +### Minor Changes + +- [#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 + + 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: + + ```js + import { defineConfig } from 'astro/config'; + + export default defineConfig({ + output: 'server', + build: { + server: './dist/server/', + client: './dist/client/', + serverEntry: 'entry.mjs', + }, + }); + ``` + + These new configuration options are only supported in SSR mode and are ignored when building to SSG (a static site). + + ## Integration hook change + + 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: + + ```js + export default function myIntegration() { + return { + name: 'my-integration', + hooks: { + 'astro:config:setup': ({ updateConfig }) => { + updateConfig({ + build: { + server: '...', + }, + }); + }, + }, + }; + } + ``` + ## 3.0.0 ### Major Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 94834b609c0e..b33216c09063 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare pages functions", - "version": "3.0.0", + "version": "3.1.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", From b98672f0d6ee5c9e5c47dc7d2c9f20c6d9f70728 Mon Sep 17 00:00:00 2001 From: Isaac McFadyen Date: Tue, 25 Oct 2022 10:27:39 -0400 Subject: [PATCH 056/500] Added information about Pages flags (#5188) --- packages/integrations/cloudflare/README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 80d7808ae82a..755451185a71 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -70,11 +70,13 @@ It's then possible to update the preview script in your `package.json` to `"prev ## Streams -Some integrations such as [React](https://github.com/withastro/astro/tree/main/packages/integrations/react) rely on web streams. Currently Cloudflare Pages functions are in beta and don't support the `streams_enable_constructors` feature flag. +Some integrations such as [React](https://github.com/withastro/astro/tree/main/packages/integrations/react) rely on web streams. Currently Cloudflare Pages Functions require enabling a flag to support Streams. -In order to work around this: -- install the `"web-streams-polyfill"` package -- add `import "web-streams-polyfill/es2018";` to the top of the front matter of every page which requires streams, such as server rendering a React component. +To do this: +- go to the Cloudflare Pages project +- click on Settings in the top bar, then Functions in the sidebar +- scroll down to Compatibility Flags, click Configure Production Compatibility Flags, and add `streams_enable_constructors` +- do this for both the Production Compatibility Flags and Preview Compatibility Flags ## Environment Variables From 9cd362fd9bf4e66a54ba4bb7f4f9db21453cbc93 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 26 Oct 2022 15:46:25 +0200 Subject: [PATCH 057/500] enable access to cloudflare runtime (#5103) * enable access to cloudflare runtime * added get runtime api added context to the runtime in "advanced" mode * added typings and adjusted some return vars * added default types * added usage description to changeset and readme Co-authored-by: AirBorne04 Co-authored-by: AirBorne04 <> --- packages/integrations/cloudflare/README.md | 12 ++++++++ packages/integrations/cloudflare/package.json | 3 +- .../integrations/cloudflare/src/runtime.ts | 28 +++++++++++++++++++ .../cloudflare/src/server.advanced.ts | 4 ++- .../cloudflare/src/server.directory.ts | 9 ++++-- 5 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 packages/integrations/cloudflare/src/runtime.ts diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 755451185a71..66f4fdd209e4 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -68,6 +68,18 @@ $ pnpm install wrangler --save-dev It's then possible to update the preview script in your `package.json` to `"preview": "wrangler pages dev ./dist"`.This will allow you run your entire application locally with [Wrangler](https://github.com/cloudflare/wrangler2), which supports secrets, environment variables, KV namespaces, Durable Objects and [all other supported Cloudflare bindings](https://developers.cloudflare.com/pages/platform/functions/#adding-bindings). +## Access to the cloudflare runtime + +You have the posibility to access all the cloudflare bindings and environment variables from your astro pages and api routes through the adapter API + +``` +import { getRuntime } from "@astrojs/cloudflare/runtime"; + +getRuntime(Astro.request); +``` + +Depending your adapter mode (advanced = worker, directory = pages) the runtime object will look a little different due to the difference in the cloudflare API. + ## Streams Some integrations such as [React](https://github.com/withastro/astro/tree/main/packages/integrations/react) rely on web streams. Currently Cloudflare Pages Functions require enabling a flag to support Streams. diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index b33216c09063..df1348a18868 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/cloudflare", - "description": "Deploy your site to cloudflare pages functions", + "description": "Deploy your site to cloudflare workers or cloudflare pages", "version": "3.1.0", "type": "module", "types": "./dist/index.d.ts", @@ -19,6 +19,7 @@ "homepage": "https://docs.astro.build/en/guides/integrations-guide/cloudflare/", "exports": { ".": "./dist/index.js", + "./runtime": "./dist/runtime.js", "./server.advanced.js": "./dist/server.advanced.js", "./server.directory.js": "./dist/server.directory.js", "./package.json": "./package.json" diff --git a/packages/integrations/cloudflare/src/runtime.ts b/packages/integrations/cloudflare/src/runtime.ts new file mode 100644 index 000000000000..ddf372cb4d40 --- /dev/null +++ b/packages/integrations/cloudflare/src/runtime.ts @@ -0,0 +1,28 @@ +export type WorkerRuntime = { + name: 'cloudflare'; + env: T; + waitUntil(promise: Promise): void; + passThroughOnException(): void; +}; + +export type PagesRuntime = { + name: 'cloudflare'; + env: T; + functionPath: string; + params: Record; + data: U; + waitUntil(promise: Promise): void; + next(request: Request): void; +}; + +export function getRuntime( + request: Request +): WorkerRuntime | PagesRuntime { + if (!!request) { + return Reflect.get(request, Symbol.for('runtime')); + } else { + throw new Error( + 'To retrieve the current cloudflare runtime you need to pass in the Astro request object' + ); + } +} diff --git a/packages/integrations/cloudflare/src/server.advanced.ts b/packages/integrations/cloudflare/src/server.advanced.ts index c285ccaba044..502700e0be97 100644 --- a/packages/integrations/cloudflare/src/server.advanced.ts +++ b/packages/integrations/cloudflare/src/server.advanced.ts @@ -5,12 +5,13 @@ import { App } from 'astro/app'; type Env = { ASSETS: { fetch: (req: Request) => Promise }; + name: string; }; export function createExports(manifest: SSRManifest) { const app = new App(manifest, false); - const fetch = async (request: Request, env: Env) => { + const fetch = async (request: Request, env: Env, context: any) => { const { origin, pathname } = new URL(request.url); // static assets @@ -26,6 +27,7 @@ export function createExports(manifest: SSRManifest) { Symbol.for('astro.clientAddress'), request.headers.get('cf-connecting-ip') ); + Reflect.set(request, Symbol.for('runtime'), { env, name: 'cloudflare', ...context }); let response = await app.render(request, routeData); if (app.setCookieHeaders) { diff --git a/packages/integrations/cloudflare/src/server.directory.ts b/packages/integrations/cloudflare/src/server.directory.ts index e51d0ea57c7a..d31e2189fde6 100644 --- a/packages/integrations/cloudflare/src/server.directory.ts +++ b/packages/integrations/cloudflare/src/server.directory.ts @@ -9,12 +9,12 @@ export function createExports(manifest: SSRManifest) { const onRequest = async ({ request, next, + ...runtimeEnv }: { request: Request; next: (request: Request) => void; - }) => { + } & Record) => { const { origin, pathname } = new URL(request.url); - // static assets if (manifest.assets.has(pathname)) { const assetRequest = new Request(`${origin}/static${pathname}`, request); @@ -28,6 +28,11 @@ export function createExports(manifest: SSRManifest) { Symbol.for('astro.clientAddress'), request.headers.get('cf-connecting-ip') ); + Reflect.set(request, Symbol.for('runtime'), { + ...runtimeEnv, + name: 'cloudflare', + next, + }); let response = await app.render(request, routeData); if (app.setCookieHeaders) { From cc2fb2ed8c40dcd957e51d9b9bc2a502719dbbd2 Mon Sep 17 00:00:00 2001 From: Sarah Rainsberger Date: Wed, 26 Oct 2022 15:23:47 -0300 Subject: [PATCH 058/500] [docs] Cloudflare integration README edits (#5205) Co-authored-by: Matthew Phillips --- packages/integrations/cloudflare/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 66f4fdd209e4..12566b97a50c 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -68,9 +68,9 @@ $ pnpm install wrangler --save-dev It's then possible to update the preview script in your `package.json` to `"preview": "wrangler pages dev ./dist"`.This will allow you run your entire application locally with [Wrangler](https://github.com/cloudflare/wrangler2), which supports secrets, environment variables, KV namespaces, Durable Objects and [all other supported Cloudflare bindings](https://developers.cloudflare.com/pages/platform/functions/#adding-bindings). -## Access to the cloudflare runtime +## Access to the Cloudflare runtime -You have the posibility to access all the cloudflare bindings and environment variables from your astro pages and api routes through the adapter API +You can access all the Cloudflare bindings and environment variables from Astro components and API routes through the adapter API. ``` import { getRuntime } from "@astrojs/cloudflare/runtime"; @@ -78,7 +78,7 @@ import { getRuntime } from "@astrojs/cloudflare/runtime"; getRuntime(Astro.request); ``` -Depending your adapter mode (advanced = worker, directory = pages) the runtime object will look a little different due to the difference in the cloudflare API. +Depending on your adapter mode (advanced = worker, directory = pages), the runtime object will look a little different due to differences in the Cloudflare API. ## Streams From 251f2f43523f27ad53e816e5e9db4d9e514c2339 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Thu, 27 Oct 2022 06:41:03 -0700 Subject: [PATCH 059/500] [ci] release (#5199) * [ci] release * Update packages/integrations/cloudflare/CHANGELOG.md Co-authored-by: Sarah Rainsberger Co-authored-by: github-actions[bot] Co-authored-by: Matthew Phillips Co-authored-by: Sarah Rainsberger --- packages/integrations/cloudflare/CHANGELOG.md | 7 +++++++ packages/integrations/cloudflare/package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 19c246cdfbdb..23a24dd07969 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,12 @@ # @astrojs/cloudflare +## 3.1.1 + +### Patch Changes + +- [#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] + - 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. + ## 3.1.0 ### Minor Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index df1348a18868..46f588908542 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare workers or cloudflare pages", - "version": "3.1.0", + "version": "3.1.1", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", From 396448579eb5144c8b3df061f8759269275108ff Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Thu, 27 Oct 2022 16:51:51 +0200 Subject: [PATCH 060/500] Add missing language to code block (#5210) --- packages/integrations/cloudflare/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 12566b97a50c..381d69fec7dd 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -72,7 +72,7 @@ It's then possible to update the preview script in your `package.json` to `"prev You can access all the Cloudflare bindings and environment variables from Astro components and API routes through the adapter API. -``` +```js import { getRuntime } from "@astrojs/cloudflare/runtime"; getRuntime(Astro.request); From 71f29145d36f725de762a320cfee4995b0b50268 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Fri, 28 Oct 2022 10:20:20 -0400 Subject: [PATCH 061/500] Export Cloudflare runtime types (#5230) * Export Cloudflare runtime types * Adding a changeset --- packages/integrations/cloudflare/package.json | 5 ++++- packages/integrations/cloudflare/runtime.d.ts | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 packages/integrations/cloudflare/runtime.d.ts diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 46f588908542..bdb1bb48d7ed 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -19,7 +19,10 @@ "homepage": "https://docs.astro.build/en/guides/integrations-guide/cloudflare/", "exports": { ".": "./dist/index.js", - "./runtime": "./dist/runtime.js", + "./runtime": { + "types": "./runtime.d.ts", + "default": "./dist/runtime.js" + }, "./server.advanced.js": "./dist/server.advanced.js", "./server.directory.js": "./dist/server.directory.js", "./package.json": "./package.json" diff --git a/packages/integrations/cloudflare/runtime.d.ts b/packages/integrations/cloudflare/runtime.d.ts new file mode 100644 index 000000000000..3b415153c0cc --- /dev/null +++ b/packages/integrations/cloudflare/runtime.d.ts @@ -0,0 +1,8 @@ +export type { + WorkerRuntime, + PagesRuntime +} from './dist/runtime'; + +export { + getRuntime +} from './dist/runtime'; From 36c629854146ea76e9d626af36a6d993ab322c62 Mon Sep 17 00:00:00 2001 From: matthewp Date: Fri, 28 Oct 2022 14:21:57 +0000 Subject: [PATCH 062/500] [ci] format --- packages/integrations/cloudflare/runtime.d.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/integrations/cloudflare/runtime.d.ts b/packages/integrations/cloudflare/runtime.d.ts index 3b415153c0cc..e2a72940a0c7 100644 --- a/packages/integrations/cloudflare/runtime.d.ts +++ b/packages/integrations/cloudflare/runtime.d.ts @@ -1,8 +1,3 @@ -export type { - WorkerRuntime, - PagesRuntime -} from './dist/runtime'; +export type { WorkerRuntime, PagesRuntime } from './dist/runtime'; -export { - getRuntime -} from './dist/runtime'; +export { getRuntime } from './dist/runtime'; From 1e06229b98dfe8389c660661238f06e3da321334 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Fri, 28 Oct 2022 09:14:55 -0700 Subject: [PATCH 063/500] [ci] release (#5215) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 6 ++++++ packages/integrations/cloudflare/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 23a24dd07969..cf16af10bc03 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/cloudflare +## 3.1.2 + +### Patch Changes + +- [#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 + ## 3.1.1 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index bdb1bb48d7ed..f94fb76ef468 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare workers or cloudflare pages", - "version": "3.1.1", + "version": "3.1.2", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", From c5180f2540a2bda277d92753ee023ec303cf1e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstr=C3=B6m?= Date: Wed, 2 Nov 2022 09:40:54 -0300 Subject: [PATCH 064/500] [docs] cloudflare `directory` nits (#5278) --- packages/integrations/cloudflare/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 381d69fec7dd..21891c05358f 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -46,9 +46,9 @@ default `"advanced"` Cloudflare Pages has 2 different modes for deploying functions, `advanced` mode which picks up the `_worker.js` in `dist`, or a directory mode where pages will compile the worker out of a functions folder in the project root. -For most projects the adaptor default of `advanced` will be sufficiant, when in this mode the `dist` folder will contain your compiled project. However if you'd like to use [pages plugins](https://developers.cloudflare.com/pages/platform/functions/plugins/) such as [Sentry](https://developers.cloudflare.com/pages/platform/functions/plugins/sentry/) for example to enable logging, you'll need to use directory mode. +For most projects the adaptor default of `advanced` will be sufficient; the `dist` folder will contain your compiled project. Switching to directory mode allows you to use [pages plugins](https://developers.cloudflare.com/pages/platform/functions/plugins/) such as [Sentry](https://developers.cloudflare.com/pages/platform/functions/plugins/sentry/) or write custom code to enable logging. -In directory mode the adaptor will compile the client side part of you app the same way, but it will move the worker script into a `functions` folder in the project root. The adaptor will only ever place a `[[path]].js` in that folder, allowing you to add additional plugins and pages middleware which can be checked into version control. +In directory mode the adaptor will compile the client side part of you app the same way, but moves the worker script into a `functions` folder in the project root. The adaptor will only ever place a `[[path]].js` in that folder, allowing you to add additional plugins and pages middleware which can be checked into version control. Cloudflare documentation contains more information about [writing custom functions](https://developers.cloudflare.com/pages/platform/functions/). ```ts // directory mode From 5a4e4f45887c11af9ebcb4bf4150528a658e9046 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Mon, 7 Nov 2022 10:05:12 -0500 Subject: [PATCH 065/500] Handle `base` in adapters (#5290) * Handle `base` in adapters * Use removeBase in the test adapter * Update packages/integrations/node/src/preview.ts Co-authored-by: Bjorn Lu * Update packages/integrations/cloudflare/src/server.advanced.ts Co-authored-by: Bjorn Lu * Include the subpath for links Co-authored-by: Bjorn Lu --- packages/integrations/cloudflare/package.json | 3 +++ packages/integrations/cloudflare/src/server.advanced.ts | 2 +- packages/integrations/cloudflare/src/server.directory.ts | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index f94fb76ef468..5a8142fffee4 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -36,6 +36,9 @@ "dependencies": { "esbuild": "^0.14.42" }, + "peerDependencies": { + "astro": "^1.6.3" + }, "devDependencies": { "astro": "workspace:*", "astro-scripts": "workspace:*", diff --git a/packages/integrations/cloudflare/src/server.advanced.ts b/packages/integrations/cloudflare/src/server.advanced.ts index 502700e0be97..ac040c9b2dcc 100644 --- a/packages/integrations/cloudflare/src/server.advanced.ts +++ b/packages/integrations/cloudflare/src/server.advanced.ts @@ -16,7 +16,7 @@ export function createExports(manifest: SSRManifest) { // static assets if (manifest.assets.has(pathname)) { - const assetRequest = new Request(`${origin}/static${pathname}`, request); + const assetRequest = new Request(`${origin}/static/${app.removeBase(pathname)}`, request); return env.ASSETS.fetch(assetRequest); } diff --git a/packages/integrations/cloudflare/src/server.directory.ts b/packages/integrations/cloudflare/src/server.directory.ts index d31e2189fde6..e7463b84ccb5 100644 --- a/packages/integrations/cloudflare/src/server.directory.ts +++ b/packages/integrations/cloudflare/src/server.directory.ts @@ -17,7 +17,7 @@ export function createExports(manifest: SSRManifest) { const { origin, pathname } = new URL(request.url); // static assets if (manifest.assets.has(pathname)) { - const assetRequest = new Request(`${origin}/static${pathname}`, request); + const assetRequest = new Request(`${origin}/static/${app.removeBase(pathname)}`, request); return next(assetRequest); } From d3100b608bb3ca360ae797f510fe1a39bd05a767 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Mon, 7 Nov 2022 12:25:20 -0800 Subject: [PATCH 066/500] [ci] release (#5296) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 15 +++++++++++++++ packages/integrations/cloudflare/package.json | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index cf16af10bc03..f625f5e68a61 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,20 @@ # @astrojs/cloudflare +## 4.0.0 + +### Major Changes + +- [#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 + + This allows adapters to correctly handle `base` configuration. Internally Astro now matches routes when the URL includes the `base`. + + 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. + +### Patch Changes + +- 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)]: + - astro@1.6.4 + ## 3.1.2 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 5a8142fffee4..027f48fd6dfe 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare workers or cloudflare pages", - "version": "3.1.2", + "version": "4.0.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -37,7 +37,7 @@ "esbuild": "^0.14.42" }, "peerDependencies": { - "astro": "^1.6.3" + "astro": "^1.6.4" }, "devDependencies": { "astro": "workspace:*", From 6415035b9dee7d197cc3de3effab79e23723d068 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Tue, 8 Nov 2022 21:54:49 +0800 Subject: [PATCH 067/500] Support environment variables in Cloudflare and Netlify Edge functions (#5301) Co-authored-by: Sarah Rainsberger --- packages/integrations/cloudflare/README.md | 18 ++++++++++-------- .../cloudflare/src/server.advanced.ts | 7 +++++-- .../cloudflare/src/server.directory.ts | 7 +++++-- packages/integrations/cloudflare/src/shim.ts | 4 ---- packages/integrations/cloudflare/src/util.ts | 16 ++++++++++++++++ .../cloudflare/test/basics.test.js | 1 + .../test/fixtures/basics/astro.config.mjs | 3 +++ .../test/fixtures/basics/src/pages/index.astro | 1 + .../integrations/cloudflare/test/wrangler.toml | 4 ++++ 9 files changed, 45 insertions(+), 16 deletions(-) delete mode 100644 packages/integrations/cloudflare/src/shim.ts create mode 100644 packages/integrations/cloudflare/src/util.ts create mode 100644 packages/integrations/cloudflare/test/wrangler.toml diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 21891c05358f..0a8012b1cfbb 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -92,16 +92,18 @@ To do this: ## Environment Variables -As Cloudflare Pages Functions [provides environment variables differently](https://developers.cloudflare.com/pages/platform/functions/#adding-environment-variables-locally), private environment variables needs to be set through [`vite.define`](https://vitejs.dev/config/shared-options.html#define) to work in builds. +As Cloudflare Pages Functions [provides environment variables per request](https://developers.cloudflare.com/pages/platform/functions/#adding-environment-variables-locally), you can only access private environment variables when a request has happened. Usually, this means moving environment variable access inside a function. ```js -// astro.config.mjs -export default { - vite: { - define: { - 'process.env.MY_SECRET': JSON.stringify(process.env.MY_SECRET), - }, - }, +// pages/[id].json.js + +export function get({ params }) { + // Access environment variables per request inside a function + const serverUrl = import.meta.env.SERVER_URL; + const result = await fetch(serverUrl + "/user/" + params.id); + return { + body: await result.text(), + }; } ``` diff --git a/packages/integrations/cloudflare/src/server.advanced.ts b/packages/integrations/cloudflare/src/server.advanced.ts index ac040c9b2dcc..cb83dd9942bb 100644 --- a/packages/integrations/cloudflare/src/server.advanced.ts +++ b/packages/integrations/cloudflare/src/server.advanced.ts @@ -1,7 +1,8 @@ -import './shim.js'; - import type { SSRManifest } from 'astro'; import { App } from 'astro/app'; +import { getProcessEnvProxy } from './util.js'; + +process.env = getProcessEnvProxy(); type Env = { ASSETS: { fetch: (req: Request) => Promise }; @@ -12,6 +13,8 @@ export function createExports(manifest: SSRManifest) { const app = new App(manifest, false); const fetch = async (request: Request, env: Env, context: any) => { + process.env = env as any; + const { origin, pathname } = new URL(request.url); // static assets diff --git a/packages/integrations/cloudflare/src/server.directory.ts b/packages/integrations/cloudflare/src/server.directory.ts index e7463b84ccb5..321f37e18303 100644 --- a/packages/integrations/cloudflare/src/server.directory.ts +++ b/packages/integrations/cloudflare/src/server.directory.ts @@ -1,7 +1,8 @@ -import './shim.js'; - import type { SSRManifest } from 'astro'; import { App } from 'astro/app'; +import { getProcessEnvProxy } from './util.js'; + +process.env = getProcessEnvProxy(); export function createExports(manifest: SSRManifest) { const app = new App(manifest, false); @@ -14,6 +15,8 @@ export function createExports(manifest: SSRManifest) { request: Request; next: (request: Request) => void; } & Record) => { + process.env = runtimeEnv.env as any; + const { origin, pathname } = new URL(request.url); // static assets if (manifest.assets.has(pathname)) { diff --git a/packages/integrations/cloudflare/src/shim.ts b/packages/integrations/cloudflare/src/shim.ts deleted file mode 100644 index 1a4a6ee9be4c..000000000000 --- a/packages/integrations/cloudflare/src/shim.ts +++ /dev/null @@ -1,4 +0,0 @@ -(globalThis as any).process = { - argv: [], - env: {}, -}; diff --git a/packages/integrations/cloudflare/src/util.ts b/packages/integrations/cloudflare/src/util.ts new file mode 100644 index 000000000000..a44780863f91 --- /dev/null +++ b/packages/integrations/cloudflare/src/util.ts @@ -0,0 +1,16 @@ +export function getProcessEnvProxy() { + return new Proxy( + {}, + { + get: (target, prop) => { + console.warn( + // NOTE: \0 prevents Vite replacement + `Unable to access \`import.meta\0.env.${prop.toString()}\` on initialization ` + + `as the Cloudflare platform only provides the environment variables per request. ` + + `Please move the environment variable access inside a function ` + + `that's only called after a request has been received.` + ); + }, + } + ); +} diff --git a/packages/integrations/cloudflare/test/basics.test.js b/packages/integrations/cloudflare/test/basics.test.js index 7127a3f68430..a6229bbb249f 100644 --- a/packages/integrations/cloudflare/test/basics.test.js +++ b/packages/integrations/cloudflare/test/basics.test.js @@ -24,6 +24,7 @@ describe.skip('Basic app', () => { let html = await res.text(); let $ = cheerio.load(html); expect($('h1').text()).to.equal('Testing'); + expect($('#env').text()).to.equal('secret'); } finally { stop(); } diff --git a/packages/integrations/cloudflare/test/fixtures/basics/astro.config.mjs b/packages/integrations/cloudflare/test/fixtures/basics/astro.config.mjs index bf47a0a330b4..105247b1bded 100644 --- a/packages/integrations/cloudflare/test/fixtures/basics/astro.config.mjs +++ b/packages/integrations/cloudflare/test/fixtures/basics/astro.config.mjs @@ -1,6 +1,9 @@ import { defineConfig } from 'astro/config'; import cloudflare from '@astrojs/cloudflare'; +// test env var +process.env.SECRET_STUFF = 'secret' + export default defineConfig({ adapter: cloudflare(), output: 'server', diff --git a/packages/integrations/cloudflare/test/fixtures/basics/src/pages/index.astro b/packages/integrations/cloudflare/test/fixtures/basics/src/pages/index.astro index 9c077e2a381b..8d372399c923 100644 --- a/packages/integrations/cloudflare/test/fixtures/basics/src/pages/index.astro +++ b/packages/integrations/cloudflare/test/fixtures/basics/src/pages/index.astro @@ -4,5 +4,6 @@

Testing

+
{import.meta.env.SECRET_STUFF}
diff --git a/packages/integrations/cloudflare/test/wrangler.toml b/packages/integrations/cloudflare/test/wrangler.toml new file mode 100644 index 000000000000..6e2d864b0c4e --- /dev/null +++ b/packages/integrations/cloudflare/test/wrangler.toml @@ -0,0 +1,4 @@ +# for tests only + +[vars] +SECRET_STUFF = "secret" From d5f9ca6e4e9dd404848a24da7b4b0a5e222b29f7 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Tue, 8 Nov 2022 10:00:53 -0800 Subject: [PATCH 068/500] [ci] release (#5325) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 9 +++++++++ packages/integrations/cloudflare/package.json | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index f625f5e68a61..05d2c5c06cbc 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,14 @@ # @astrojs/cloudflare +## 4.0.1 + +### Patch Changes + +- [#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 + +- Updated dependencies [[`88c1bbe3a`](https://github.com/withastro/astro/commit/88c1bbe3a71f85e92f42f13d0f310c6b2a264ade), [`a79a37cad`](https://github.com/withastro/astro/commit/a79a37cad549b21f91599ff86899e456d9dcc7df)]: + - astro@1.6.5 + ## 4.0.0 ### Major Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 027f48fd6dfe..66c05bba1006 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare workers or cloudflare pages", - "version": "4.0.0", + "version": "4.0.1", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -37,7 +37,7 @@ "esbuild": "^0.14.42" }, "peerDependencies": { - "astro": "^1.6.4" + "astro": "^1.6.5" }, "devDependencies": { "astro": "workspace:*", From ddf5ea5fd3e01504a399561be4ae8c54c38268ad Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Thu, 10 Nov 2022 13:01:45 -0800 Subject: [PATCH 069/500] [ci] release (#5329) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 66c05bba1006..c97963ed32d2 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -37,7 +37,7 @@ "esbuild": "^0.14.42" }, "peerDependencies": { - "astro": "^1.6.5" + "astro": "^1.6.6" }, "devDependencies": { "astro": "workspace:*", From dcb09d99d73bdbb22419c9cfb0762a5e49d90c64 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Thu, 10 Nov 2022 16:09:24 -0800 Subject: [PATCH 070/500] [ci] release (#5359) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index c97963ed32d2..1463d0e542d4 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -37,7 +37,7 @@ "esbuild": "^0.14.42" }, "peerDependencies": { - "astro": "^1.6.6" + "astro": "^1.6.7" }, "devDependencies": { "astro": "workspace:*", From 12052b564318c4ed642a8c1dba17e0ee3606dea9 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Mon, 14 Nov 2022 10:31:31 -0800 Subject: [PATCH 071/500] [ci] release (#5365) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 1463d0e542d4..4662675121b7 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -37,7 +37,7 @@ "esbuild": "^0.14.42" }, "peerDependencies": { - "astro": "^1.6.7" + "astro": "^1.6.8" }, "devDependencies": { "astro": "workspace:*", From 2fc2539a2b48b03d8004131c3a20c55c2f47ae6f Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Wed, 16 Nov 2022 07:07:56 -0800 Subject: [PATCH 072/500] [ci] release (#5399) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 4662675121b7..3874bd54409c 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -37,7 +37,7 @@ "esbuild": "^0.14.42" }, "peerDependencies": { - "astro": "^1.6.8" + "astro": "^1.6.9" }, "devDependencies": { "astro": "workspace:*", From c4965da4fce99006b1cb296df0a83d32165fea68 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Thu, 17 Nov 2022 07:52:42 -0800 Subject: [PATCH 073/500] [ci] release (#5419) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 3874bd54409c..82110c7ef5c0 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -37,7 +37,7 @@ "esbuild": "^0.14.42" }, "peerDependencies": { - "astro": "^1.6.9" + "astro": "^1.6.10" }, "devDependencies": { "astro": "workspace:*", From a7ee9f4c8f2fc96218d412dffd483981fb9a4b2b Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 21 Nov 2022 14:31:21 +0100 Subject: [PATCH 074/500] Use Cloudflare Pages to serve static assets and support `_headers`, `_redirects` and `_routes.json` (#5347) Co-authored-by: AirBorne04 Co-authored-by: Chris Swithinbank --- packages/integrations/cloudflare/README.md | 10 +- packages/integrations/cloudflare/package.json | 3 +- packages/integrations/cloudflare/src/index.ts | 112 ++++++++++++++++-- .../cloudflare/src/server.advanced.ts | 7 +- .../cloudflare/src/server.directory.ts | 7 +- 5 files changed, 119 insertions(+), 20 deletions(-) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 0a8012b1cfbb..3acec5512ada 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -66,7 +66,7 @@ In order for preview to work you must install `wrangler` $ pnpm install wrangler --save-dev ``` -It's then possible to update the preview script in your `package.json` to `"preview": "wrangler pages dev ./dist"`.This will allow you run your entire application locally with [Wrangler](https://github.com/cloudflare/wrangler2), which supports secrets, environment variables, KV namespaces, Durable Objects and [all other supported Cloudflare bindings](https://developers.cloudflare.com/pages/platform/functions/#adding-bindings). +It's then possible to update the preview script in your `package.json` to `"preview": "wrangler pages dev ./dist"`. This will allow you run your entire application locally with [Wrangler](https://github.com/cloudflare/wrangler2), which supports secrets, environment variables, KV namespaces, Durable Objects and [all other supported Cloudflare bindings](https://developers.cloudflare.com/pages/platform/functions/#adding-bindings). ## Access to the Cloudflare runtime @@ -107,6 +107,14 @@ export function get({ params }) { } ``` +## Headers, Redirects and function invocation routes + +Cloudflare has support for adding custom [headers](https://developers.cloudflare.com/pages/platform/headers/), configuring static [redirects](https://developers.cloudflare.com/pages/platform/redirects/) and defining which routes should [invoke functions](https://developers.cloudflare.com/pages/platform/functions/routing/#function-invocation-routes). Cloudflare looks for `_headers`, `_redirects`, and `_routes.json` files in your build output directory to configure these features. This means they should be placed in your Astro project’s `public/` directory. + +### Custom `_routes.json` + +By default, `@astrojs/cloudflare` will generate a `_routes.json` file that lists all files from your `dist/` folder and redirects from the `_redirects` file in the `exclude` array. This will enable Cloudflare to serve files and process static redirects without a function invocation. Creating a custom `_routes.json` will override this automatic optimization and, if not configured manually, cause function invocations that will count against the request limits of your Cloudflare plan. + ## Troubleshooting For help, check out the `#support` channel on [Discord](https://astro.build/chat). Our friendly Support Squad members are here to help! diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 82110c7ef5c0..81db5b1ce08d 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -34,7 +34,8 @@ "test": "mocha --exit --timeout 30000 test/" }, "dependencies": { - "esbuild": "^0.14.42" + "esbuild": "^0.14.42", + "tiny-glob": "^0.2.9" }, "peerDependencies": { "astro": "^1.6.10" diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 44112e8be15c..805eccb9c69e 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -1,6 +1,8 @@ import type { AstroAdapter, AstroConfig, AstroIntegration } from 'astro'; import esbuild from 'esbuild'; import * as fs from 'fs'; +import * as os from 'os'; +import glob from 'tiny-glob'; import { fileURLToPath } from 'url'; type Options = { @@ -32,6 +34,8 @@ const SHIM = `globalThis.process = { env: {}, };`; +const SERVER_BUILD_FOLDER = '/$server_build/'; + export default function createIntegration(args?: Options): AstroIntegration { let _config: AstroConfig; let _buildConfig: BuildConfig; @@ -45,8 +49,8 @@ export default function createIntegration(args?: Options): AstroIntegration { needsBuildConfig = !config.build.client; updateConfig({ build: { - client: new URL('./static/', config.outDir), - server: new URL('./', config.outDir), + client: new URL(`.${config.base}`, config.outDir), + server: new URL(`.${SERVER_BUILD_FOLDER}`, config.outDir), serverEntry: '_worker.js', }, }); @@ -62,6 +66,11 @@ export default function createIntegration(args?: Options): AstroIntegration { `); } + + if (config.base === SERVER_BUILD_FOLDER) { + throw new Error(` + [@astrojs/cloudflare] \`base: "${SERVER_BUILD_FOLDER}"\` is not allowed. Please change your \`base\` config to something else.`); + } }, 'astro:build:setup': ({ vite, target }) => { if (target === 'server') { @@ -84,19 +93,20 @@ export default function createIntegration(args?: Options): AstroIntegration { 'astro:build:start': ({ buildConfig }) => { // Backwards compat if (needsBuildConfig) { - buildConfig.client = new URL('./static/', _config.outDir); - buildConfig.server = new URL('./', _config.outDir); + buildConfig.client = new URL(`.${_config.base}`, _config.outDir); + buildConfig.server = new URL(`.${SERVER_BUILD_FOLDER}`, _config.outDir); buildConfig.serverEntry = '_worker.js'; } }, 'astro:build:done': async () => { - const entryUrl = new URL(_buildConfig.serverEntry, _buildConfig.server); - const pkg = fileURLToPath(entryUrl); + const entryPath = fileURLToPath(new URL(_buildConfig.serverEntry, _buildConfig.server)), + entryUrl = new URL(_buildConfig.serverEntry, _config.outDir), + buildPath = fileURLToPath(entryUrl); await esbuild.build({ target: 'es2020', platform: 'browser', - entryPoints: [pkg], - outfile: pkg, + entryPoints: [entryPath], + outfile: buildPath, allowOverwrite: true, format: 'esm', bundle: true, @@ -107,8 +117,90 @@ export default function createIntegration(args?: Options): AstroIntegration { }); // throw the server folder in the bin - const chunksUrl = new URL('./chunks', _buildConfig.server); - await fs.promises.rm(chunksUrl, { recursive: true, force: true }); + const serverUrl = new URL(_buildConfig.server); + await fs.promises.rm(serverUrl, { recursive: true, force: true }); + + // move cloudflare specific files to the root + const cloudflareSpecialFiles = ['_headers', '_redirects', '_routes.json']; + if (_config.base !== '/') { + for (const file of cloudflareSpecialFiles) { + try { + await fs.promises.rename( + new URL(file, _buildConfig.client), + new URL(file, _config.outDir) + ); + } catch (e) { + // ignore + } + } + } + + const routesExists = await fs.promises + .stat(new URL('./_routes.json', _config.outDir)) + .then((stat) => stat.isFile()) + .catch(() => false); + + // this creates a _routes.json, in case there is none present to enable + // cloudflare to handle static files and support _redirects configuration + // (without calling the function) + if (!routesExists) { + const staticPathList: Array = ( + await glob(`${fileURLToPath(_buildConfig.client)}/**/*`, { + cwd: fileURLToPath(_config.outDir), + filesOnly: true, + }) + ) + .filter((file: string) => cloudflareSpecialFiles.indexOf(file) < 0) + .map((file: string) => `/${file}`); + + const redirectsExists = await fs.promises + .stat(new URL('./_redirects', _config.outDir)) + .then((stat) => stat.isFile()) + .catch(() => false); + + // convert all redirect source paths into a list of routes + // and add them to the static path + if (redirectsExists) { + const redirects = ( + await fs.promises.readFile(new URL('./_redirects', _config.outDir), 'utf-8') + ) + .split(os.EOL) + .map((line) => { + const parts = line.split(' '); + if (parts.length < 2) { + return null; + } else { + // convert /products/:id to /products/* + return ( + parts[0] + .replace(/\/:.*?(?=\/|$)/g, '/*') + // remove query params as they are not supported by cloudflare + .replace(/\?.*$/, '') + ); + } + }) + .filter( + (line, index, arr) => line !== null && arr.indexOf(line) === index + ) as string[]; + + if (redirects.length > 0) { + staticPathList.push(...redirects); + } + } + + await fs.promises.writeFile( + new URL('./_routes.json', _config.outDir), + JSON.stringify( + { + version: 1, + include: ['/*'], + exclude: staticPathList, + }, + null, + 2 + ) + ); + } if (isModeDirectory) { const functionsUrl = new URL(`file://${process.cwd()}/functions/`); diff --git a/packages/integrations/cloudflare/src/server.advanced.ts b/packages/integrations/cloudflare/src/server.advanced.ts index cb83dd9942bb..0d765d0bba18 100644 --- a/packages/integrations/cloudflare/src/server.advanced.ts +++ b/packages/integrations/cloudflare/src/server.advanced.ts @@ -15,12 +15,11 @@ export function createExports(manifest: SSRManifest) { const fetch = async (request: Request, env: Env, context: any) => { process.env = env as any; - const { origin, pathname } = new URL(request.url); + const { pathname } = new URL(request.url); - // static assets + // static assets fallback, in case default _routes.json is not used if (manifest.assets.has(pathname)) { - const assetRequest = new Request(`${origin}/static/${app.removeBase(pathname)}`, request); - return env.ASSETS.fetch(assetRequest); + return env.ASSETS.fetch(request); } let routeData = app.match(request, { matchNotFound: true }); diff --git a/packages/integrations/cloudflare/src/server.directory.ts b/packages/integrations/cloudflare/src/server.directory.ts index 321f37e18303..69d008b0faa0 100644 --- a/packages/integrations/cloudflare/src/server.directory.ts +++ b/packages/integrations/cloudflare/src/server.directory.ts @@ -17,11 +17,10 @@ export function createExports(manifest: SSRManifest) { } & Record) => { process.env = runtimeEnv.env as any; - const { origin, pathname } = new URL(request.url); - // static assets + const { pathname } = new URL(request.url); + // static assets fallback, in case default _routes.json is not used if (manifest.assets.has(pathname)) { - const assetRequest = new Request(`${origin}/static/${app.removeBase(pathname)}`, request); - return next(assetRequest); + return next(request); } let routeData = app.match(request, { matchNotFound: true }); From 508ec402a1590d9bf44c26f90da4d225a2e9f5e9 Mon Sep 17 00:00:00 2001 From: bluwy Date: Mon, 21 Nov 2022 13:33:45 +0000 Subject: [PATCH 075/500] [ci] format --- packages/integrations/cloudflare/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 805eccb9c69e..d39f0f8759f8 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -158,8 +158,8 @@ export default function createIntegration(args?: Options): AstroIntegration { .then((stat) => stat.isFile()) .catch(() => false); - // convert all redirect source paths into a list of routes - // and add them to the static path + // convert all redirect source paths into a list of routes + // and add them to the static path if (redirectsExists) { const redirects = ( await fs.promises.readFile(new URL('./_redirects', _config.outDir), 'utf-8') From 751026a5757b01b0f00255d8325e5ed7ceb233be Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Tue, 22 Nov 2022 15:56:55 +0100 Subject: [PATCH 076/500] =?UTF-8?q?Integration=20READMEs=20code=20block=20?= =?UTF-8?q?sweep=20=F0=9F=A7=B9=20(#5455)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/integrations/cloudflare/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 3acec5512ada..93d9a951d31e 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -25,7 +25,8 @@ npm install @astrojs/cloudflare 2. Add the following to your `astro.config.mjs` file: -```js title="astro.config.mjs" ins={2, 5-6} +```js ins={3, 6-7} +// astro.config.mjs import { defineConfig } from 'astro/config'; import cloudflare from '@astrojs/cloudflare'; From c88688877408502066c197df447d101a1a6f1690 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Thu, 24 Nov 2022 06:54:52 -0800 Subject: [PATCH 077/500] [ci] release (#5432) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 12 ++++++++++++ packages/integrations/cloudflare/package.json | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 05d2c5c06cbc..c71e087f7a88 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,17 @@ # @astrojs/cloudflare +## 4.1.0 + +### Minor Changes + +- [#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. + Also supports the use of `_routes.json`, `_redirects` and `_headers` files when placed into the `public` folder. + +### Patch Changes + +- 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)]: + - astro@1.6.11 + ## 4.0.1 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 81db5b1ce08d..3dae7d30ed63 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare workers or cloudflare pages", - "version": "4.0.1", + "version": "4.1.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "^1.6.10" + "astro": "^1.6.11" }, "devDependencies": { "astro": "workspace:*", From 153d6bf6b9555db494bdb7603f80bfc523033231 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Wed, 30 Nov 2022 08:10:06 -0800 Subject: [PATCH 078/500] [ci] release (#5485) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 3dae7d30ed63..47be9e5b0716 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "^1.6.11" + "astro": "^1.6.12" }, "devDependencies": { "astro": "workspace:*", From f745b905de9af38e7324e98d9dcbc55c6d42f5d3 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Tue, 6 Dec 2022 02:20:35 -0800 Subject: [PATCH 079/500] [ci] release (#5507) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 47be9e5b0716..f7062926b7db 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "^1.6.12" + "astro": "^1.6.13" }, "devDependencies": { "astro": "workspace:*", From 3fe01f906384b6c031e3117e463d2df4f71f5b4b Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Tue, 6 Dec 2022 22:11:59 +0800 Subject: [PATCH 080/500] Update esbuild dependency (#5534) --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index f7062926b7db..2f45c547ca40 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -34,7 +34,7 @@ "test": "mocha --exit --timeout 30000 test/" }, "dependencies": { - "esbuild": "^0.14.42", + "esbuild": "^0.15.18", "tiny-glob": "^0.2.9" }, "peerDependencies": { From a97e3e58727d065e7db023da97ca6cd02946410b Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Thu, 8 Dec 2022 06:12:10 -0800 Subject: [PATCH 081/500] [ci] release (#5544) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 9 +++++++++ packages/integrations/cloudflare/package.json | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index c71e087f7a88..f17fef36e793 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,14 @@ # @astrojs/cloudflare +## 4.1.1 + +### Patch Changes + +- [#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 + +- 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)]: + - astro@1.6.14 + ## 4.1.0 ### Minor Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 2f45c547ca40..578eda3bd969 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare workers or cloudflare pages", - "version": "4.1.0", + "version": "4.1.1", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "^1.6.13" + "astro": "^1.6.14" }, "devDependencies": { "astro": "workspace:*", From b293276ccbb95c87205addde86f66f229c8cd111 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Mon, 12 Dec 2022 07:22:39 -0800 Subject: [PATCH 082/500] [ci] release (#5561) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 578eda3bd969..3601f790fa00 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "^1.6.14" + "astro": "^1.6.15" }, "devDependencies": { "astro": "workspace:*", From b3f9b8cc1b4d3501b87698f4f53101ff1b57996c Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Fri, 16 Dec 2022 12:54:19 -0800 Subject: [PATCH 083/500] [ci] release (#5607) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 7 +++++++ packages/integrations/cloudflare/package.json | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index f17fef36e793..33dae5e65cc8 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,12 @@ # @astrojs/cloudflare +## 5.0.0 + +### Patch Changes + +- 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)]: + - astro@1.7.0 + ## 4.1.1 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 3601f790fa00..aa760516ba5d 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare workers or cloudflare pages", - "version": "4.1.1", + "version": "5.0.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "^1.6.15" + "astro": "^1.7.0" }, "devDependencies": { "astro": "workspace:*", From 3a624162d5c86c23332cc9026b45cc4215db809a Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Fri, 16 Dec 2022 17:12:04 -0800 Subject: [PATCH 084/500] [ci] release (#5618) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index aa760516ba5d..b2bb3f11aa8a 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "^1.7.0" + "astro": "^1.7.1" }, "devDependencies": { "astro": "workspace:*", From 1e61981645d89a3f343fdaea494af8f2e36fe2d3 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Mon, 19 Dec 2022 07:26:29 -0800 Subject: [PATCH 085/500] [ci] release (#5642) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index b2bb3f11aa8a..e2823a363fcf 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "^1.7.1" + "astro": "^1.7.2" }, "devDependencies": { "astro": "workspace:*", From 49f827061ed6341999ec17982e521a38e8fe0ef2 Mon Sep 17 00:00:00 2001 From: Sarah Rainsberger Date: Thu, 29 Dec 2022 13:30:34 -0400 Subject: [PATCH 086/500] [docs] reflects updates to cloudflare: streams, env variables (#5694) --- packages/integrations/cloudflare/README.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 93d9a951d31e..723b5662c41f 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -81,19 +81,9 @@ getRuntime(Astro.request); Depending on your adapter mode (advanced = worker, directory = pages), the runtime object will look a little different due to differences in the Cloudflare API. -## Streams - -Some integrations such as [React](https://github.com/withastro/astro/tree/main/packages/integrations/react) rely on web streams. Currently Cloudflare Pages Functions require enabling a flag to support Streams. - -To do this: -- go to the Cloudflare Pages project -- click on Settings in the top bar, then Functions in the sidebar -- scroll down to Compatibility Flags, click Configure Production Compatibility Flags, and add `streams_enable_constructors` -- do this for both the Production Compatibility Flags and Preview Compatibility Flags - ## Environment Variables -As Cloudflare Pages Functions [provides environment variables per request](https://developers.cloudflare.com/pages/platform/functions/#adding-environment-variables-locally), you can only access private environment variables when a request has happened. Usually, this means moving environment variable access inside a function. +See Cloudflare's documentation for [working with environment variables](https://developers.cloudflare.com/pages/platform/functions/bindings/#environment-variables). ```js // pages/[id].json.js From b43950e992f8771bc27e3353a3bba7d1173ad19b Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Wed, 4 Jan 2023 03:06:07 +0800 Subject: [PATCH 087/500] Remove deprecated APIs (#5707) * Remove deprecated Astro globals * Remove deprecated hook param * Fix test * Add changeset * Add TODO --- packages/integrations/cloudflare/src/index.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index d39f0f8759f8..1df284fbbb19 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -39,14 +39,12 @@ const SERVER_BUILD_FOLDER = '/$server_build/'; export default function createIntegration(args?: Options): AstroIntegration { let _config: AstroConfig; let _buildConfig: BuildConfig; - let needsBuildConfig = false; const isModeDirectory = args?.mode === 'directory'; return { name: '@astrojs/cloudflare', hooks: { 'astro:config:setup': ({ config, updateConfig }) => { - needsBuildConfig = !config.build.client; updateConfig({ build: { client: new URL(`.${config.base}`, config.outDir), @@ -90,14 +88,6 @@ export default function createIntegration(args?: Options): AstroIntegration { vite.ssr.target = vite.ssr.target || 'webworker'; } }, - 'astro:build:start': ({ buildConfig }) => { - // Backwards compat - if (needsBuildConfig) { - buildConfig.client = new URL(`.${_config.base}`, _config.outDir); - buildConfig.server = new URL(`.${SERVER_BUILD_FOLDER}`, _config.outDir); - buildConfig.serverEntry = '_worker.js'; - } - }, 'astro:build:done': async () => { const entryPath = fileURLToPath(new URL(_buildConfig.serverEntry, _buildConfig.server)), entryUrl = new URL(_buildConfig.serverEntry, _config.outDir), From 94ddaab336601ef0d095119f8868e6184ba5a0f8 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Tue, 3 Jan 2023 14:23:30 -0800 Subject: [PATCH 088/500] [ci] release (beta) (#5732) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 11 +++++++++++ packages/integrations/cloudflare/package.json | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 33dae5e65cc8..38aa97350afc 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,16 @@ # @astrojs/cloudflare +## 6.0.0-beta.0 + +### Major Changes + +- [#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 + +### Patch Changes + +- 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)]: + - astro@2.0.0-beta.0 + ## 5.0.0 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index e2823a363fcf..b6b900b99330 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare workers or cloudflare pages", - "version": "5.0.0", + "version": "6.0.0-beta.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "^1.7.2" + "astro": "^2.0.0-beta.0" }, "devDependencies": { "astro": "workspace:*", From 9a4f83db4b5574e1a32f620980b3a89f1558ad0f Mon Sep 17 00:00:00 2001 From: Lorenzo Lewis Date: Wed, 4 Jan 2023 10:27:17 +0000 Subject: [PATCH 089/500] Fix whitespace in type comment (#5691) Co-authored-by: Nate Moore Co-authored-by: Chris Swithinbank From f5b5c8525c6257b20beb32a942aac219bc4fcc2f Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Mon, 9 Jan 2023 10:58:38 -0500 Subject: [PATCH 090/500] Add Astro as a peerDependency (#5806) * Add Astro as a peerDependency * Add changeset * Update .changeset/thin-seahorses-worry.md Co-authored-by: Bjorn Lu Co-authored-by: Bjorn Lu --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index b6b900b99330..28a2b9a0cc75 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "^2.0.0-beta.0" + "astro": "workspace:^2.0.0-beta.0" }, "devDependencies": { "astro": "workspace:*", From 053341e8936bb6ac0e5467f71796975783600c92 Mon Sep 17 00:00:00 2001 From: "Fred K. Bot" <108291165+fredkbot@users.noreply.github.com> Date: Thu, 12 Jan 2023 08:40:35 -0800 Subject: [PATCH 091/500] [ci] release (beta) (#5792) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 13 +++++++++++++ packages/integrations/cloudflare/package.json | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 38aa97350afc..352519b80660 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,18 @@ # @astrojs/cloudflare +## 6.0.0-beta.1 + +### Major Changes + +- [#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 + + 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. + +### Patch Changes + +- 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)]: + - astro@2.0.0-beta.2 + ## 6.0.0-beta.0 ### Major Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 28a2b9a0cc75..7eef2b66b1a8 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare workers or cloudflare pages", - "version": "6.0.0-beta.0", + "version": "6.0.0-beta.1", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.0-beta.0" + "astro": "workspace:^2.0.0-beta.2" }, "devDependencies": { "astro": "workspace:*", From eef77d979c2e3b3fbea9adc19a0f0d846f730570 Mon Sep 17 00:00:00 2001 From: "Hoston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 19 Jan 2023 08:00:03 -0800 Subject: [PATCH 092/500] [ci] release (beta) (#5856) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 7eef2b66b1a8..ecdc8c43e844 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.0-beta.2" + "astro": "workspace:^2.0.0-beta.3" }, "devDependencies": { "astro": "workspace:*", From 8d77cd969746ef1e7807c0cf5e81d9ad17c276fd Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Mon, 23 Jan 2023 13:11:39 -0800 Subject: [PATCH 093/500] [ci] release (beta) (#5911) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index ecdc8c43e844..a3e0034385d2 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.0-beta.3" + "astro": "workspace:^2.0.0-beta.4" }, "devDependencies": { "astro": "workspace:*", From 400c510541da2649155b57866757fd4ec4831c65 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Tue, 24 Jan 2023 08:38:06 -0800 Subject: [PATCH 094/500] [ci] release (#5948) * [ci] release * Update changelogs (#5955) * [ci] release * Wrap astro 2.0 beta logs in `
` * Add link to docs upgrade guide * First pass cleaning up 2.0 release notes * mdx changes from Sarah * combine 5584 and 5842 in deno, image, netlify * markdown/remark incl (5684 & 5769) to match mdx * Tweak markdown/remark formatting * Format astro-prism * Format astro-rss * Format create-astro * Format cloudflare * Format lit * Format partytown * Format node * Format preact * Format react * Format solid * Format svelte * Format tailwind * Format vercel * Format vue * Format telemetry * Format webapi * Format scripts * Reinstate h3s for headings Co-authored-by: Ben Holmes * Reformat mdx * astro & markdown/remark: Combine #5679 & #5684 changelogs Co-authored-by: github-actions[bot] Co-authored-by: Chris Swithinbank Co-authored-by: Sarah Rainsberger Co-authored-by: Ben Holmes Co-authored-by: github-actions[bot] Co-authored-by: Matthew Phillips Co-authored-by: Chris Swithinbank Co-authored-by: Sarah Rainsberger Co-authored-by: Ben Holmes --- packages/integrations/cloudflare/CHANGELOG.md | 29 +++++++++++++++++-- packages/integrations/cloudflare/package.json | 4 +-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 352519b80660..4d0198224df4 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,20 +1,43 @@ # @astrojs/cloudflare +## 6.0.0 + +### Major Changes + +- [#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 + +- [#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 + + 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. + +### Patch Changes + +- 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)]: + - astro@2.0.0 + ## 6.0.0-beta.1 +
+See changes in 6.0.0-beta.1 + ### Major Changes -- [#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 +- [#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 - 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. + 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. ### Patch Changes - 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)]: - astro@2.0.0-beta.2 +
+ ## 6.0.0-beta.0 +
+See changes in 6.0.0-beta.0 + ### Major Changes - [#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 +47,8 @@ - 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)]: - astro@2.0.0-beta.0 +
+ ## 5.0.0 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index a3e0034385d2..b3ce9ffe2386 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare workers or cloudflare pages", - "version": "6.0.0-beta.1", + "version": "6.0.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.0-beta.4" + "astro": "workspace:^2.0.0" }, "devDependencies": { "astro": "workspace:*", From f977634ed99fe51919a382f4b2277387f2100e7e Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Tue, 24 Jan 2023 18:19:27 -0800 Subject: [PATCH 095/500] [ci] release (#5963) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index b3ce9ffe2386..fccd867471cc 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.0" + "astro": "workspace:^2.0.1" }, "devDependencies": { "astro": "workspace:*", From 6e02cbc94eb237dbbd87883417eca68a1d852159 Mon Sep 17 00:00:00 2001 From: Angus Date: Fri, 27 Jan 2023 00:44:09 +1100 Subject: [PATCH 096/500] Re-enable streaming on Cloudflare Pages (#5914) * Support streaming on Cloudflare Pages * Create tidy-ties-repeat.md Co-authored-by: Nate Moore --- packages/integrations/cloudflare/src/server.advanced.ts | 2 +- packages/integrations/cloudflare/src/server.directory.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/src/server.advanced.ts b/packages/integrations/cloudflare/src/server.advanced.ts index 0d765d0bba18..b57a480f945e 100644 --- a/packages/integrations/cloudflare/src/server.advanced.ts +++ b/packages/integrations/cloudflare/src/server.advanced.ts @@ -10,7 +10,7 @@ type Env = { }; export function createExports(manifest: SSRManifest) { - const app = new App(manifest, false); + const app = new App(manifest); const fetch = async (request: Request, env: Env, context: any) => { process.env = env as any; diff --git a/packages/integrations/cloudflare/src/server.directory.ts b/packages/integrations/cloudflare/src/server.directory.ts index 69d008b0faa0..8f1b3b8ab4ae 100644 --- a/packages/integrations/cloudflare/src/server.directory.ts +++ b/packages/integrations/cloudflare/src/server.directory.ts @@ -5,7 +5,7 @@ import { getProcessEnvProxy } from './util.js'; process.env = getProcessEnvProxy(); export function createExports(manifest: SSRManifest) { - const app = new App(manifest, false); + const app = new App(manifest); const onRequest = async ({ request, From 955440483fb32460500a41457fd6c011685ada4f Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 26 Jan 2023 12:43:39 -0500 Subject: [PATCH 097/500] Support for prerendering in the Cloudflare integration (#5993) * Cloudflare prerender branch * Add prerendered routes to Cloudflare routes.json * Adding changeset * Prevent process proxy from running during prerender phase --- packages/integrations/cloudflare/src/index.ts | 16 ++++++++++++++-- .../cloudflare/src/server.advanced.ts | 6 ++++-- .../cloudflare/src/server.directory.ts | 6 ++++-- packages/integrations/cloudflare/src/util.ts | 2 ++ .../test/fixtures/prerender/astro.config.mjs | 7 +++++++ .../test/fixtures/prerender/package.json | 9 +++++++++ .../fixtures/prerender/src/pages/index.astro | 8 ++++++++ .../fixtures/prerender/src/pages/one.astro | 11 +++++++++++ .../cloudflare/test/prerender.test.js | 19 +++++++++++++++++++ 9 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 packages/integrations/cloudflare/test/fixtures/prerender/astro.config.mjs create mode 100644 packages/integrations/cloudflare/test/fixtures/prerender/package.json create mode 100644 packages/integrations/cloudflare/test/fixtures/prerender/src/pages/index.astro create mode 100644 packages/integrations/cloudflare/test/fixtures/prerender/src/pages/one.astro create mode 100644 packages/integrations/cloudflare/test/prerender.test.js diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 1df284fbbb19..3a077c4d6188 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -49,7 +49,7 @@ export default function createIntegration(args?: Options): AstroIntegration { build: { client: new URL(`.${config.base}`, config.outDir), server: new URL(`.${SERVER_BUILD_FOLDER}`, config.outDir), - serverEntry: '_worker.js', + serverEntry: '_worker.mjs', }, }); }, @@ -88,10 +88,11 @@ export default function createIntegration(args?: Options): AstroIntegration { vite.ssr.target = vite.ssr.target || 'webworker'; } }, - 'astro:build:done': async () => { + 'astro:build:done': async ({ pages }) => { const entryPath = fileURLToPath(new URL(_buildConfig.serverEntry, _buildConfig.server)), entryUrl = new URL(_buildConfig.serverEntry, _config.outDir), buildPath = fileURLToPath(entryUrl); + await esbuild.build({ target: 'es2020', platform: 'browser', @@ -106,6 +107,9 @@ export default function createIntegration(args?: Options): AstroIntegration { }, }); + // Rename to worker.js + await fs.promises.rename(buildPath, buildPath.replace(/\.mjs$/, '.js')); + // throw the server folder in the bin const serverUrl = new URL(_buildConfig.server); await fs.promises.rm(serverUrl, { recursive: true, force: true }); @@ -143,6 +147,10 @@ export default function createIntegration(args?: Options): AstroIntegration { .filter((file: string) => cloudflareSpecialFiles.indexOf(file) < 0) .map((file: string) => `/${file}`); + for(let page of pages) { + staticPathList.push(prependForwardSlash(page.pathname)); + } + const redirectsExists = await fs.promises .stat(new URL('./_redirects', _config.outDir)) .then((stat) => stat.isFile()) @@ -202,3 +210,7 @@ export default function createIntegration(args?: Options): AstroIntegration { }, }; } + +function prependForwardSlash(path: string) { + return path[0] === '/' ? path : '/' + path; +} diff --git a/packages/integrations/cloudflare/src/server.advanced.ts b/packages/integrations/cloudflare/src/server.advanced.ts index b57a480f945e..3d6b4fbcd20b 100644 --- a/packages/integrations/cloudflare/src/server.advanced.ts +++ b/packages/integrations/cloudflare/src/server.advanced.ts @@ -1,8 +1,10 @@ import type { SSRManifest } from 'astro'; import { App } from 'astro/app'; -import { getProcessEnvProxy } from './util.js'; +import { getProcessEnvProxy, isNode } from './util.js'; -process.env = getProcessEnvProxy(); +if(!isNode) { + process.env = getProcessEnvProxy(); +} type Env = { ASSETS: { fetch: (req: Request) => Promise }; diff --git a/packages/integrations/cloudflare/src/server.directory.ts b/packages/integrations/cloudflare/src/server.directory.ts index 8f1b3b8ab4ae..17a35f15a0f6 100644 --- a/packages/integrations/cloudflare/src/server.directory.ts +++ b/packages/integrations/cloudflare/src/server.directory.ts @@ -1,8 +1,10 @@ import type { SSRManifest } from 'astro'; import { App } from 'astro/app'; -import { getProcessEnvProxy } from './util.js'; +import { getProcessEnvProxy, isNode } from './util.js'; -process.env = getProcessEnvProxy(); +if(!isNode) { + process.env = getProcessEnvProxy(); +} export function createExports(manifest: SSRManifest) { const app = new App(manifest); diff --git a/packages/integrations/cloudflare/src/util.ts b/packages/integrations/cloudflare/src/util.ts index a44780863f91..96927e57a9a3 100644 --- a/packages/integrations/cloudflare/src/util.ts +++ b/packages/integrations/cloudflare/src/util.ts @@ -1,3 +1,5 @@ +export const isNode = typeof process === 'object' && Object.prototype.toString.call(process) === '[object process]'; + export function getProcessEnvProxy() { return new Proxy( {}, diff --git a/packages/integrations/cloudflare/test/fixtures/prerender/astro.config.mjs b/packages/integrations/cloudflare/test/fixtures/prerender/astro.config.mjs new file mode 100644 index 000000000000..bf47a0a330b4 --- /dev/null +++ b/packages/integrations/cloudflare/test/fixtures/prerender/astro.config.mjs @@ -0,0 +1,7 @@ +import { defineConfig } from 'astro/config'; +import cloudflare from '@astrojs/cloudflare'; + +export default defineConfig({ + adapter: cloudflare(), + output: 'server', +}); diff --git a/packages/integrations/cloudflare/test/fixtures/prerender/package.json b/packages/integrations/cloudflare/test/fixtures/prerender/package.json new file mode 100644 index 000000000000..3b2c5fef5d5c --- /dev/null +++ b/packages/integrations/cloudflare/test/fixtures/prerender/package.json @@ -0,0 +1,9 @@ +{ + "name": "@test/astro-cloudflare-prerender", + "version": "0.0.0", + "private": true, + "dependencies": { + "@astrojs/cloudflare": "workspace:*", + "astro": "workspace:*" + } +} diff --git a/packages/integrations/cloudflare/test/fixtures/prerender/src/pages/index.astro b/packages/integrations/cloudflare/test/fixtures/prerender/src/pages/index.astro new file mode 100644 index 000000000000..dfd71c3de6db --- /dev/null +++ b/packages/integrations/cloudflare/test/fixtures/prerender/src/pages/index.astro @@ -0,0 +1,8 @@ + + + Testing + + +

Testing

+ + diff --git a/packages/integrations/cloudflare/test/fixtures/prerender/src/pages/one.astro b/packages/integrations/cloudflare/test/fixtures/prerender/src/pages/one.astro new file mode 100644 index 000000000000..30386a625ab6 --- /dev/null +++ b/packages/integrations/cloudflare/test/fixtures/prerender/src/pages/one.astro @@ -0,0 +1,11 @@ +--- +export const prerender = true; +--- + + + Testing + + +

Testing

+ + diff --git a/packages/integrations/cloudflare/test/prerender.test.js b/packages/integrations/cloudflare/test/prerender.test.js new file mode 100644 index 000000000000..a3ce50d08c96 --- /dev/null +++ b/packages/integrations/cloudflare/test/prerender.test.js @@ -0,0 +1,19 @@ +import { loadFixture } from './test-utils.js'; +import { expect } from 'chai'; + +describe('Prerendering', () => { + /** @type {import('./test-utils').Fixture} */ + let fixture; + + before(async () => { + fixture = await loadFixture({ + root: './fixtures/prerender/', + }); + await fixture.build(); + }); + + it('includes prerendered routes in the routes.json config', async () => { + const routes = JSON.parse(await fixture.readFile('/_routes.json')); + expect(routes.exclude).to.include('/one/'); + }); +}); From 2ae4936a9a6f09e949281e37762bae5efc376142 Mon Sep 17 00:00:00 2001 From: matthewp Date: Thu, 26 Jan 2023 17:45:39 +0000 Subject: [PATCH 098/500] [ci] format --- packages/integrations/cloudflare/src/index.ts | 2 +- packages/integrations/cloudflare/src/server.advanced.ts | 2 +- packages/integrations/cloudflare/src/server.directory.ts | 2 +- packages/integrations/cloudflare/src/util.ts | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 3a077c4d6188..a859e3009c61 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -147,7 +147,7 @@ export default function createIntegration(args?: Options): AstroIntegration { .filter((file: string) => cloudflareSpecialFiles.indexOf(file) < 0) .map((file: string) => `/${file}`); - for(let page of pages) { + for (let page of pages) { staticPathList.push(prependForwardSlash(page.pathname)); } diff --git a/packages/integrations/cloudflare/src/server.advanced.ts b/packages/integrations/cloudflare/src/server.advanced.ts index 3d6b4fbcd20b..669e95ebca6a 100644 --- a/packages/integrations/cloudflare/src/server.advanced.ts +++ b/packages/integrations/cloudflare/src/server.advanced.ts @@ -2,7 +2,7 @@ import type { SSRManifest } from 'astro'; import { App } from 'astro/app'; import { getProcessEnvProxy, isNode } from './util.js'; -if(!isNode) { +if (!isNode) { process.env = getProcessEnvProxy(); } diff --git a/packages/integrations/cloudflare/src/server.directory.ts b/packages/integrations/cloudflare/src/server.directory.ts index 17a35f15a0f6..2a0e06e5c2a7 100644 --- a/packages/integrations/cloudflare/src/server.directory.ts +++ b/packages/integrations/cloudflare/src/server.directory.ts @@ -2,7 +2,7 @@ import type { SSRManifest } from 'astro'; import { App } from 'astro/app'; import { getProcessEnvProxy, isNode } from './util.js'; -if(!isNode) { +if (!isNode) { process.env = getProcessEnvProxy(); } diff --git a/packages/integrations/cloudflare/src/util.ts b/packages/integrations/cloudflare/src/util.ts index 96927e57a9a3..120cb73343fa 100644 --- a/packages/integrations/cloudflare/src/util.ts +++ b/packages/integrations/cloudflare/src/util.ts @@ -1,4 +1,5 @@ -export const isNode = typeof process === 'object' && Object.prototype.toString.call(process) === '[object process]'; +export const isNode = + typeof process === 'object' && Object.prototype.toString.call(process) === '[object process]'; export function getProcessEnvProxy() { return new Proxy( From bd253c2ae150bb398e80ff262d798b3c159b8a43 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 26 Jan 2023 10:53:32 -0800 Subject: [PATCH 099/500] [ci] release (#5984) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 15 +++++++++++++++ packages/integrations/cloudflare/package.json | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 4d0198224df4..425c7bcfb675 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,20 @@ # @astrojs/cloudflare +## 6.1.0 + +### Minor Changes + +- [#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. + +### Patch Changes + +- [#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 + + 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. + +- 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)]: + - astro@2.0.2 + ## 6.0.0 ### Major Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index fccd867471cc..eebd89d5b072 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare workers or cloudflare pages", - "version": "6.0.0", + "version": "6.1.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.1" + "astro": "workspace:^2.0.2" }, "devDependencies": { "astro": "workspace:*", From 4eb4ef2b6391f99d27324483551996136f6de4a6 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Mon, 30 Jan 2023 09:38:31 -0800 Subject: [PATCH 100/500] [ci] release (#5995) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index eebd89d5b072..bbc88041fe1c 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.2" + "astro": "workspace:^2.0.3" }, "devDependencies": { "astro": "workspace:*", From 16ddf556b5932bcce9f6500d72d0202e93772ef5 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Mon, 30 Jan 2023 14:50:44 -0500 Subject: [PATCH 101/500] Fix Cloudflare directory mode regression (#6046) * Fix Cloudflare directory mode regression * Adding a changeset --- packages/integrations/cloudflare/src/index.ts | 14 +++++++------ .../cloudflare/test/directory.test.js | 20 +++++++++++++++++++ 2 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 packages/integrations/cloudflare/test/directory.test.js diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index a859e3009c61..3433cf46d70e 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -3,7 +3,7 @@ import esbuild from 'esbuild'; import * as fs from 'fs'; import * as os from 'os'; import glob from 'tiny-glob'; -import { fileURLToPath } from 'url'; +import { fileURLToPath, pathToFileURL } from 'url'; type Options = { mode: 'directory' | 'advanced'; @@ -89,9 +89,11 @@ export default function createIntegration(args?: Options): AstroIntegration { } }, 'astro:build:done': async ({ pages }) => { - const entryPath = fileURLToPath(new URL(_buildConfig.serverEntry, _buildConfig.server)), - entryUrl = new URL(_buildConfig.serverEntry, _config.outDir), - buildPath = fileURLToPath(entryUrl); + const entryPath = fileURLToPath(new URL(_buildConfig.serverEntry, _buildConfig.server)); + const entryUrl = new URL(_buildConfig.serverEntry, _config.outDir); + const buildPath = fileURLToPath(entryUrl); + // A URL for the final build path after renaming + const finalBuildUrl = pathToFileURL(buildPath.replace(/\.mjs$/, '.js')); await esbuild.build({ target: 'es2020', @@ -108,7 +110,7 @@ export default function createIntegration(args?: Options): AstroIntegration { }); // Rename to worker.js - await fs.promises.rename(buildPath, buildPath.replace(/\.mjs$/, '.js')); + await fs.promises.rename(buildPath, finalBuildUrl); // throw the server folder in the bin const serverUrl = new URL(_buildConfig.server); @@ -204,7 +206,7 @@ export default function createIntegration(args?: Options): AstroIntegration { const functionsUrl = new URL(`file://${process.cwd()}/functions/`); await fs.promises.mkdir(functionsUrl, { recursive: true }); const directoryUrl = new URL('[[path]].js', functionsUrl); - await fs.promises.rename(entryUrl, directoryUrl); + await fs.promises.rename(finalBuildUrl, directoryUrl); } }, }, diff --git a/packages/integrations/cloudflare/test/directory.test.js b/packages/integrations/cloudflare/test/directory.test.js new file mode 100644 index 000000000000..771f8a347d10 --- /dev/null +++ b/packages/integrations/cloudflare/test/directory.test.js @@ -0,0 +1,20 @@ +import { loadFixture, runCLI } from './test-utils.js'; +import { expect } from 'chai'; +import * as cheerio from 'cheerio'; +import cloudflare from '../dist/index.js'; + +describe('mode: "directory"', () => { + /** @type {import('./test-utils').Fixture} */ + let fixture; + + before(async () => { + fixture = await loadFixture({ + root: './fixtures/basics/', + adapter: cloudflare({ mode: 'directory' }) + }); + }); + + it('Builds', async () => { + await fixture.build(); + }); +}); From 598b7b3078b86e63792e866af2ebe0470cf1017f Mon Sep 17 00:00:00 2001 From: matthewp Date: Mon, 30 Jan 2023 19:52:54 +0000 Subject: [PATCH 102/500] [ci] format --- packages/integrations/cloudflare/test/directory.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/test/directory.test.js b/packages/integrations/cloudflare/test/directory.test.js index 771f8a347d10..7c299f526685 100644 --- a/packages/integrations/cloudflare/test/directory.test.js +++ b/packages/integrations/cloudflare/test/directory.test.js @@ -10,7 +10,7 @@ describe('mode: "directory"', () => { before(async () => { fixture = await loadFixture({ root: './fixtures/basics/', - adapter: cloudflare({ mode: 'directory' }) + adapter: cloudflare({ mode: 'directory' }), }); }); From 9032b95386c27d9eba7670b9b3e3ab213572cdbc Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Mon, 30 Jan 2023 12:28:32 -0800 Subject: [PATCH 103/500] [ci] release (#6041) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 9 +++++++++ packages/integrations/cloudflare/package.json | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 425c7bcfb675..762c8707b919 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,14 @@ # @astrojs/cloudflare +## 6.1.1 + +### Patch Changes + +- [#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 + +- Updated dependencies [[`41e97158b`](https://github.com/withastro/astro/commit/41e97158ba90d23d346b6e3ff6c7c14b5ecbe903), [`e779c6242`](https://github.com/withastro/astro/commit/e779c6242418d1d4102e683ca5b851b764c89688)]: + - astro@2.0.4 + ## 6.1.0 ### Minor Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index bbc88041fe1c..ca9e34dfb300 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare workers or cloudflare pages", - "version": "6.1.0", + "version": "6.1.1", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.3" + "astro": "workspace:^2.0.4" }, "devDependencies": { "astro": "workspace:*", From e87f4341ea8af2db150ad7969f9e10b9dcbe9a78 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Wed, 1 Feb 2023 05:58:35 -0800 Subject: [PATCH 104/500] [ci] release (#6048) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index ca9e34dfb300..a2e8ad1da8ed 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.4" + "astro": "workspace:^2.0.5" }, "devDependencies": { "astro": "workspace:*", From adb072ad58b841c2b7c4b55c9f90b0846b0decc7 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 2 Feb 2023 12:38:04 -0800 Subject: [PATCH 105/500] [ci] release (#6094) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index a2e8ad1da8ed..8f90141ac490 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.5" + "astro": "workspace:^2.0.6" }, "devDependencies": { "astro": "workspace:*", From efa892d54b35514f841b351d699d237562e4a5f3 Mon Sep 17 00:00:00 2001 From: Nacho Vazquez Date: Fri, 3 Feb 2023 12:19:44 -0300 Subject: [PATCH 106/500] fix: use the root of the project as the functions location (#6075) * fix: use the root of the project as the functions location * test: add test to check where the functions folder is added --- packages/integrations/cloudflare/src/index.ts | 2 +- .../integrations/cloudflare/test/directory.test.js | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 3433cf46d70e..7ba1cc63148a 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -203,7 +203,7 @@ export default function createIntegration(args?: Options): AstroIntegration { } if (isModeDirectory) { - const functionsUrl = new URL(`file://${process.cwd()}/functions/`); + const functionsUrl = new URL('functions', _config.root); await fs.promises.mkdir(functionsUrl, { recursive: true }); const directoryUrl = new URL('[[path]].js', functionsUrl); await fs.promises.rename(finalBuildUrl, directoryUrl); diff --git a/packages/integrations/cloudflare/test/directory.test.js b/packages/integrations/cloudflare/test/directory.test.js index 7c299f526685..e5b5205745cf 100644 --- a/packages/integrations/cloudflare/test/directory.test.js +++ b/packages/integrations/cloudflare/test/directory.test.js @@ -1,20 +1,21 @@ -import { loadFixture, runCLI } from './test-utils.js'; +import { loadFixture } from './test-utils.js'; import { expect } from 'chai'; -import * as cheerio from 'cheerio'; import cloudflare from '../dist/index.js'; +/** @type {import('./test-utils').Fixture} */ describe('mode: "directory"', () => { - /** @type {import('./test-utils').Fixture} */ let fixture; before(async () => { fixture = await loadFixture({ root: './fixtures/basics/', + output: 'server', adapter: cloudflare({ mode: 'directory' }), }); + await fixture.build(); }); - it('Builds', async () => { - await fixture.build(); + it('generates functions folder inside the project root', async () => { + expect(await fixture.pathExists('../functions')).to.be.true; }); }); From 870ddc9593ba13f854238b2bb6074927cd6da78d Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Tue, 7 Feb 2023 10:45:08 -0800 Subject: [PATCH 107/500] [ci] release (#6116) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 9 +++++++++ packages/integrations/cloudflare/package.json | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 762c8707b919..cc481557c021 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,14 @@ # @astrojs/cloudflare +## 6.1.2 + +### Patch Changes + +- [#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 + +- 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)]: + - astro@2.0.7 + ## 6.1.1 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 8f90141ac490..4d8c41f6be1d 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare workers or cloudflare pages", - "version": "6.1.1", + "version": "6.1.2", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.6" + "astro": "workspace:^2.0.7" }, "devDependencies": { "astro": "workspace:*", From b506b5ca22de76b04ffd91e3761fb89a638a89e8 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Tue, 7 Feb 2023 14:08:12 -0800 Subject: [PATCH 108/500] [ci] release (#6169) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 4d8c41f6be1d..408280bc6acb 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.7" + "astro": "workspace:^2.0.8" }, "devDependencies": { "astro": "workspace:*", From 2d4f9a76f7157250f61f0e3ef881047714ea16fe Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Wed, 8 Feb 2023 11:11:29 -0800 Subject: [PATCH 109/500] [ci] release (#6178) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 408280bc6acb..a8cf3d3ba889 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.8" + "astro": "workspace:^2.0.9" }, "devDependencies": { "astro": "workspace:*", From fa5d2937a0e5c845cf8c011deaa5191020a4d5fc Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 9 Feb 2023 11:27:56 -0800 Subject: [PATCH 110/500] [ci] release (#6184) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index a8cf3d3ba889..8f24ed6062de 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.9" + "astro": "workspace:^2.0.10" }, "devDependencies": { "astro": "workspace:*", From b1e7fa5fce6dd58b1f4f22c819a76cb59cf92484 Mon Sep 17 00:00:00 2001 From: Marvin Frachet Date: Mon, 13 Feb 2023 02:19:38 +0100 Subject: [PATCH 111/500] Fix 6206: Cloudflare function path resolving one step above (#6208) * Fix 6206: Cloudflare function path resolving one step above --- packages/integrations/cloudflare/src/index.ts | 3 ++- packages/integrations/cloudflare/test/directory.test.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 7ba1cc63148a..0343e6e81874 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -203,8 +203,9 @@ export default function createIntegration(args?: Options): AstroIntegration { } if (isModeDirectory) { - const functionsUrl = new URL('functions', _config.root); + const functionsUrl = new URL('functions/', _config.root); await fs.promises.mkdir(functionsUrl, { recursive: true }); + const directoryUrl = new URL('[[path]].js', functionsUrl); await fs.promises.rename(finalBuildUrl, directoryUrl); } diff --git a/packages/integrations/cloudflare/test/directory.test.js b/packages/integrations/cloudflare/test/directory.test.js index e5b5205745cf..67693310a7e0 100644 --- a/packages/integrations/cloudflare/test/directory.test.js +++ b/packages/integrations/cloudflare/test/directory.test.js @@ -17,5 +17,6 @@ describe('mode: "directory"', () => { it('generates functions folder inside the project root', async () => { expect(await fixture.pathExists('../functions')).to.be.true; + expect(await fixture.pathExists('../functions/[[path]].js')).to.be.true; }); }); From 5b47125cc21ee1ab5a2e22e6d5573feaee6f07c2 Mon Sep 17 00:00:00 2001 From: Sarah Rainsberger Date: Mon, 13 Feb 2023 09:57:28 -0400 Subject: [PATCH 112/500] [docs] README typo fixes (#6233) * [docs] README typo fixes * adaptor -> adapter Co-authored-by: Chris Swithinbank * one more adapter --------- Co-authored-by: Chris Swithinbank --- packages/integrations/cloudflare/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 723b5662c41f..207952185097 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -47,9 +47,9 @@ default `"advanced"` Cloudflare Pages has 2 different modes for deploying functions, `advanced` mode which picks up the `_worker.js` in `dist`, or a directory mode where pages will compile the worker out of a functions folder in the project root. -For most projects the adaptor default of `advanced` will be sufficient; the `dist` folder will contain your compiled project. Switching to directory mode allows you to use [pages plugins](https://developers.cloudflare.com/pages/platform/functions/plugins/) such as [Sentry](https://developers.cloudflare.com/pages/platform/functions/plugins/sentry/) or write custom code to enable logging. +For most projects the adapter default of `advanced` will be sufficient; the `dist` folder will contain your compiled project. Switching to directory mode allows you to use [pages plugins](https://developers.cloudflare.com/pages/platform/functions/plugins/) such as [Sentry](https://developers.cloudflare.com/pages/platform/functions/plugins/sentry/) or write custom code to enable logging. -In directory mode the adaptor will compile the client side part of you app the same way, but moves the worker script into a `functions` folder in the project root. The adaptor will only ever place a `[[path]].js` in that folder, allowing you to add additional plugins and pages middleware which can be checked into version control. Cloudflare documentation contains more information about [writing custom functions](https://developers.cloudflare.com/pages/platform/functions/). +In directory mode the adapter will compile the client side part of your app the same way, but moves the worker script into a `functions` folder in the project root. The adapter will only ever place a `[[path]].js` in that folder, allowing you to add additional plugins and pages middleware which can be checked into version control. Cloudflare documentation contains more information about [writing custom functions](https://developers.cloudflare.com/pages/platform/functions/). ```ts // directory mode @@ -67,7 +67,7 @@ In order for preview to work you must install `wrangler` $ pnpm install wrangler --save-dev ``` -It's then possible to update the preview script in your `package.json` to `"preview": "wrangler pages dev ./dist"`. This will allow you run your entire application locally with [Wrangler](https://github.com/cloudflare/wrangler2), which supports secrets, environment variables, KV namespaces, Durable Objects and [all other supported Cloudflare bindings](https://developers.cloudflare.com/pages/platform/functions/#adding-bindings). +It's then possible to update the preview script in your `package.json` to `"preview": "wrangler pages dev ./dist"`. This will allow you to run your entire application locally with [Wrangler](https://github.com/cloudflare/wrangler2), which supports secrets, environment variables, KV namespaces, Durable Objects and [all other supported Cloudflare bindings](https://developers.cloudflare.com/pages/platform/functions/#adding-bindings). ## Access to the Cloudflare runtime From 1fa2bceebb8f3f06679c5a9da51c879f0810c118 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Mon, 13 Feb 2023 12:26:13 -0800 Subject: [PATCH 113/500] [ci] release (#6200) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 9 +++++++++ packages/integrations/cloudflare/package.json | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index cc481557c021..0bc61c6344a7 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,14 @@ # @astrojs/cloudflare +## 6.1.3 + +### Patch Changes + +- [#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 + +- 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)]: + - astro@2.0.11 + ## 6.1.2 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 8f24ed6062de..d85d5079838a 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare workers or cloudflare pages", - "version": "6.1.2", + "version": "6.1.3", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.10" + "astro": "workspace:^2.0.11" }, "devDependencies": { "astro": "workspace:*", From 203f96a809ea8c8c55a5eaa52e6042e8d22c9698 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Wed, 15 Feb 2023 05:05:27 -0800 Subject: [PATCH 114/500] [ci] release (#6239) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index d85d5079838a..e99af39debec 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.11" + "astro": "workspace:^2.0.12" }, "devDependencies": { "astro": "workspace:*", From fa0fb8f1f4b50ab29dbf5caf32d0395bf989dd7f Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 16 Feb 2023 11:36:33 -0800 Subject: [PATCH 115/500] [ci] release (#6261) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index e99af39debec..46afb0b55ff8 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.12" + "astro": "workspace:^2.0.13" }, "devDependencies": { "astro": "workspace:*", From 8dc1c02f606212f904042692087a4f29d3ac58a4 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Fri, 17 Feb 2023 10:44:15 -0800 Subject: [PATCH 116/500] [ci] release (#6279) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 46afb0b55ff8..7c4d63e8fbae 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.13" + "astro": "workspace:^2.0.14" }, "devDependencies": { "astro": "workspace:*", From fd97bee751c484a56455eaffb07ca265c8ba47d3 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 23 Feb 2023 12:50:11 -0800 Subject: [PATCH 117/500] [ci] release (#6287) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 7c4d63e8fbae..c57871d0cd00 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.14" + "astro": "workspace:^2.0.15" }, "devDependencies": { "astro": "workspace:*", From e66dc74ff71b9190f40d7de1212a2255920acfc1 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Mon, 27 Feb 2023 05:55:42 -0800 Subject: [PATCH 118/500] [ci] release (#6359) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index c57871d0cd00..a01f3019254a 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.15" + "astro": "workspace:^2.0.16" }, "devDependencies": { "astro": "workspace:*", From 93a39420c25460ab8693c3cb14ffc96401558c34 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 2 Mar 2023 12:32:38 -0800 Subject: [PATCH 119/500] [ci] release (#6377) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index a01f3019254a..3843ab82a39a 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.16" + "astro": "workspace:^2.0.17" }, "devDependencies": { "astro": "workspace:*", From 4adfc82d976d141ff77eaf83bc11a1ac887dbf79 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Mon, 6 Mar 2023 08:30:38 -0800 Subject: [PATCH 120/500] [ci] release (#6414) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 3843ab82a39a..04d4f6ab3b7d 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.17" + "astro": "workspace:^2.0.18" }, "devDependencies": { "astro": "workspace:*", From f253db36d67a37cdbf2a58900b760e694ea49313 Mon Sep 17 00:00:00 2001 From: Erika <3019731+Princesseuh@users.noreply.github.com> Date: Mon, 6 Mar 2023 19:57:16 +0100 Subject: [PATCH 121/500] Update compilation target for Node 16 (#6213) * config(esbuild): Update esbuild target to node16 * config(package): Update root package.json node engine * config(tsconfig): Update all the tsconfigs module and targets * chore: changeset * chore: remove unneeded file --- packages/integrations/cloudflare/tsconfig.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/tsconfig.json b/packages/integrations/cloudflare/tsconfig.json index 44baf375c882..64d4ef454384 100644 --- a/packages/integrations/cloudflare/tsconfig.json +++ b/packages/integrations/cloudflare/tsconfig.json @@ -3,8 +3,8 @@ "include": ["src"], "compilerOptions": { "allowJs": true, - "module": "ES2020", + "module": "ES2022", "outDir": "./dist", - "target": "ES2020" + "target": "ES2021" } } From 510dcfd79b22de7e0a77445c22ae4a516d69d63d Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Tue, 7 Mar 2023 11:49:19 -0800 Subject: [PATCH 122/500] [ci] release (#6432) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 11 +++++++++++ packages/integrations/cloudflare/package.json | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 0bc61c6344a7..09b0facf785b 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,16 @@ # @astrojs/cloudflare +## 6.2.0 + +### Minor Changes + +- [#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 + +### Patch Changes + +- 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)]: + - astro@2.1.0 + ## 6.1.3 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 04d4f6ab3b7d..d94a5fb29def 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to cloudflare workers or cloudflare pages", - "version": "6.1.3", + "version": "6.2.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.0.18" + "astro": "workspace:^2.1.0" }, "devDependencies": { "astro": "workspace:*", From 67b42c9b62b90dda811bc84381dee41e3cad4111 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Wed, 8 Mar 2023 13:09:20 -0800 Subject: [PATCH 123/500] [ci] release (#6456) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index d94a5fb29def..30a9b56e80c8 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.1.0" + "astro": "workspace:^2.1.1" }, "devDependencies": { "astro": "workspace:*", From d531821e343b7772cf8a5de06fa41f266d5b17d3 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Wed, 8 Mar 2023 14:39:06 -0800 Subject: [PATCH 124/500] [ci] release (#6468) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 30a9b56e80c8..a36b84408bfa 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.1.1" + "astro": "workspace:^2.1.2" }, "devDependencies": { "astro": "workspace:*", From 9c266d69d1e8cc2b2d6af27c2ef558e633936c04 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Mon, 13 Mar 2023 10:05:54 -0400 Subject: [PATCH 125/500] Remove false-positive warnings from Cloudflare's build (#6531) --- packages/integrations/cloudflare/src/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 0343e6e81874..f0e252989b72 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -107,6 +107,9 @@ export default function createIntegration(args?: Options): AstroIntegration { banner: { js: SHIM, }, + logOverride: { + 'ignored-bare-import': 'silent' + }, }); // Rename to worker.js From 868d6b7328ad240c20ae2872c145d710071dc218 Mon Sep 17 00:00:00 2001 From: matthewp Date: Mon, 13 Mar 2023 14:08:22 +0000 Subject: [PATCH 126/500] [ci] format --- packages/integrations/cloudflare/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index f0e252989b72..a72e0db46bdb 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -108,7 +108,7 @@ export default function createIntegration(args?: Options): AstroIntegration { js: SHIM, }, logOverride: { - 'ignored-bare-import': 'silent' + 'ignored-bare-import': 'silent', }, }); From 4e2abd8fe04ea8005febc9d7f23f4585dee052df Mon Sep 17 00:00:00 2001 From: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> Date: Mon, 13 Mar 2023 11:25:47 -0300 Subject: [PATCH 127/500] Consistency improvements to several package descriptions (#6494) * Add small improvements to package descriptions * Add changeset --------- Co-authored-by: Nate Moore --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index a36b84408bfa..c3f6b34b7c2a 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/cloudflare", - "description": "Deploy your site to cloudflare workers or cloudflare pages", + "description": "Deploy your site to Cloudflare Workers/Pages", "version": "6.2.0", "type": "module", "types": "./dist/index.d.ts", From 8dcc32392e138e759af92115cfd91ae12feb14c5 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Mon, 13 Mar 2023 09:58:21 -0500 Subject: [PATCH 128/500] fix: rebase _routes.json for Cloudflare when config.base set (#6473) --- packages/integrations/cloudflare/src/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index a72e0db46bdb..f87b701e9117 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -153,7 +153,12 @@ export default function createIntegration(args?: Options): AstroIntegration { .map((file: string) => `/${file}`); for (let page of pages) { - staticPathList.push(prependForwardSlash(page.pathname)); + let pagePath = prependForwardSlash(page.pathname); + if (_config.base !== '/') { + const base = _config.base.endsWith('/') ? _config.base.substring(0, -1) : _config.base; + pagePath = `${base}${pagePath}`; + } + staticPathList.push(pagePath); } const redirectsExists = await fs.promises From 86c19abf04de5a5f5a2d06116886f586df834088 Mon Sep 17 00:00:00 2001 From: bluwy Date: Mon, 13 Mar 2023 15:00:16 +0000 Subject: [PATCH 129/500] [ci] format --- packages/integrations/cloudflare/src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index f87b701e9117..2f182d6043a0 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -155,7 +155,9 @@ export default function createIntegration(args?: Options): AstroIntegration { for (let page of pages) { let pagePath = prependForwardSlash(page.pathname); if (_config.base !== '/') { - const base = _config.base.endsWith('/') ? _config.base.substring(0, -1) : _config.base; + const base = _config.base.endsWith('/') + ? _config.base.substring(0, -1) + : _config.base; pagePath = `${base}${pagePath}`; } staticPathList.push(pagePath); From 20862d49c33f592132479199ec5bc41d24ac24b3 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Mon, 13 Mar 2023 13:05:43 -0700 Subject: [PATCH 130/500] [ci] release (#6476) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 15 +++++++++++++++ packages/integrations/cloudflare/package.json | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 09b0facf785b..c712799e27e6 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,20 @@ # @astrojs/cloudflare +## 6.2.1 + +### Patch Changes + +- [#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. + + 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. + +- [#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 + +- [#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 + +- 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)]: + - astro@2.1.3 + ## 6.2.0 ### Minor Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index c3f6b34b7c2a..be49fe3a8659 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to Cloudflare Workers/Pages", - "version": "6.2.0", + "version": "6.2.1", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.1.2" + "astro": "workspace:^2.1.3" }, "devDependencies": { "astro": "workspace:*", From 7a45eba4a19e16dfac2bb9339f54e4ff1a7b90b0 Mon Sep 17 00:00:00 2001 From: Richard Simpson Date: Thu, 16 Mar 2023 09:39:54 -0500 Subject: [PATCH 131/500] fix(cloudflare): base strip logic (#6550) --- packages/integrations/cloudflare/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 2f182d6043a0..6cdfdd96cbbd 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -156,7 +156,7 @@ export default function createIntegration(args?: Options): AstroIntegration { let pagePath = prependForwardSlash(page.pathname); if (_config.base !== '/') { const base = _config.base.endsWith('/') - ? _config.base.substring(0, -1) + ? _config.base.slice(0, -1) : _config.base; pagePath = `${base}${pagePath}`; } From 83f97c0913119161d0e101049c211c323648931f Mon Sep 17 00:00:00 2001 From: bluwy Date: Thu, 16 Mar 2023 14:42:36 +0000 Subject: [PATCH 132/500] [ci] format --- packages/integrations/cloudflare/src/index.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 6cdfdd96cbbd..f5c4fc370105 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -155,9 +155,7 @@ export default function createIntegration(args?: Options): AstroIntegration { for (let page of pages) { let pagePath = prependForwardSlash(page.pathname); if (_config.base !== '/') { - const base = _config.base.endsWith('/') - ? _config.base.slice(0, -1) - : _config.base; + const base = _config.base.endsWith('/') ? _config.base.slice(0, -1) : _config.base; pagePath = `${base}${pagePath}`; } staticPathList.push(pagePath); From b2ed08a3441bc033916491d5d92b76cb37b63fb9 Mon Sep 17 00:00:00 2001 From: Erika <3019731+Princesseuh@users.noreply.github.com> Date: Mon, 20 Mar 2023 17:02:07 +0100 Subject: [PATCH 133/500] feat(all): Migrate to TypeScript 5.0 (#6579) --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index be49fe3a8659..a76091561c68 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -34,7 +34,7 @@ "test": "mocha --exit --timeout 30000 test/" }, "dependencies": { - "esbuild": "^0.15.18", + "esbuild": "^0.17.12", "tiny-glob": "^0.2.9" }, "peerDependencies": { From e7546a54e5d2b3a8d9aa3fd11ca7b58492d7486c Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Tue, 21 Mar 2023 05:03:46 -0700 Subject: [PATCH 134/500] [ci] release (#6541) * [ci] release * nit: typo in #6594 changeset --------- Co-authored-by: github-actions[bot] Co-authored-by: Ben Holmes --- packages/integrations/cloudflare/CHANGELOG.md | 9 +++++++++ packages/integrations/cloudflare/package.json | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index c712799e27e6..950b83aa801c 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,14 @@ # @astrojs/cloudflare +## 6.2.2 + +### Patch Changes + +- [#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 + +- 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)]: + - astro@2.1.4 + ## 6.2.1 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index a76091561c68..a632cad421b4 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to Cloudflare Workers/Pages", - "version": "6.2.1", + "version": "6.2.2", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.1.3" + "astro": "workspace:^2.1.4" }, "devDependencies": { "astro": "workspace:*", From febed9590f557cb8d07f5245f35fc2880d946599 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Wed, 22 Mar 2023 05:53:15 -0700 Subject: [PATCH 135/500] [ci] release (#6612) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index a632cad421b4..c8eb4a93c645 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.1.4" + "astro": "workspace:^2.1.5" }, "devDependencies": { "astro": "workspace:*", From ea1d7d519c38cbd1ac1fbc3e5aeb072af148aa7c Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 23 Mar 2023 22:49:12 -0700 Subject: [PATCH 136/500] [ci] release (#6634) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index c8eb4a93c645..33f5c6579d42 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.1.5" + "astro": "workspace:^2.1.6" }, "devDependencies": { "astro": "workspace:*", From c707b5d8a3e86c4103655bf1a51481026dfed132 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Fri, 24 Mar 2023 10:17:01 -0700 Subject: [PATCH 137/500] [ci] release (#6646) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 33f5c6579d42..e97ba7140262 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.1.6" + "astro": "workspace:^2.1.7" }, "devDependencies": { "astro": "workspace:*", From f221679380241b3e448fb6396b2796de33a204f1 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Tue, 28 Mar 2023 10:17:46 -0700 Subject: [PATCH 138/500] [ci] release (#6652) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index e97ba7140262..c746b1bbbc94 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.1.7" + "astro": "workspace:^2.1.8" }, "devDependencies": { "astro": "workspace:*", From 1231d44c7d6b818776405b0449fe4ebd8af6a435 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Fri, 31 Mar 2023 07:32:28 -0700 Subject: [PATCH 139/500] [ci] release (#6694) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index c746b1bbbc94..4bd0b1c16ab9 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.1.8" + "astro": "workspace:^2.1.9" }, "devDependencies": { "astro": "workspace:*", From 75bf234c1ada4b73155ec57854b963bd16687b1c Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Wed, 5 Apr 2023 10:38:45 -0700 Subject: [PATCH 140/500] [ci] release (#6720) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 4bd0b1c16ab9..d6a7e8c57ede 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.1.9" + "astro": "workspace:^2.2.0" }, "devDependencies": { "astro": "workspace:*", From a95dd5958b8a5c99913d6e92a49638d9194d5477 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Fri, 7 Apr 2023 14:25:00 -0700 Subject: [PATCH 141/500] [ci] release (#6769) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index d6a7e8c57ede..68ba75ddb906 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.2.0" + "astro": "workspace:^2.2.1" }, "devDependencies": { "astro": "workspace:*", From 55124fcc95990d84f9460a914dc1df88b082bf43 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Tue, 11 Apr 2023 10:10:00 -0700 Subject: [PATCH 142/500] [ci] release (#6809) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 68ba75ddb906..f606ab5ddc4c 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.2.1" + "astro": "workspace:^2.2.2" }, "devDependencies": { "astro": "workspace:*", From f155ec6ef3287aaa6cc4ef0af09a73f69fab9b79 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Wed, 12 Apr 2023 05:51:55 -0700 Subject: [PATCH 143/500] [ci] release (#6818) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index f606ab5ddc4c..9f5e4de05398 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.2.2" + "astro": "workspace:^2.2.3" }, "devDependencies": { "astro": "workspace:*", From d31204410c681abd3b8daa9236ad9a6d1f560979 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 13 Apr 2023 11:41:56 -0700 Subject: [PATCH 144/500] [ci] release (#6835) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 9f5e4de05398..a96df103bf49 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.2.3" + "astro": "workspace:^2.3.0" }, "devDependencies": { "astro": "workspace:*", From e63cee6273a767dc3cf1ef98be1a54fa5e47f3a1 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Tue, 25 Apr 2023 07:48:36 -0700 Subject: [PATCH 145/500] [ci] release (#6863) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index a96df103bf49..e926f313fc20 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.3.0" + "astro": "workspace:^2.3.1" }, "devDependencies": { "astro": "workspace:*", From e0bd33860e333a9f92e6cf25e207525079bad561 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 27 Apr 2023 10:11:05 +0200 Subject: [PATCH 146/500] esbuild respects `vite.build.minify` option (#6222) * esbuild respects `vite.build.minify` option * Docs update --------- Co-authored-by: AirBorne04 <> Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> --- packages/integrations/cloudflare/README.md | 18 ++++++++++++++++++ packages/integrations/cloudflare/src/index.ts | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 207952185097..2e61063dbde6 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -108,10 +108,28 @@ By default, `@astrojs/cloudflare` will generate a `_routes.json` file that lists ## Troubleshooting + For help, check out the `#support` channel on [Discord](https://astro.build/chat). Our friendly Support Squad members are here to help! You can also check our [Astro Integration Documentation][astro-integration] for more on integrations. +### Meaningful error messages + +Currently, errors during running your application in Wrangler are not very useful, due to the minification of your code. For better debugging, you can add `vite.build.minify = false` setting to your `astro.config.js` + +``` +export default defineConfig({ + adapter: cloudflare(), + output: 'server', + + vite: { + build: { + minify: false + } + } +}); +``` + ## Contributing This package is maintained by Astro's Core team. You're welcome to submit an issue or PR! diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index f5c4fc370105..bbe8c65c74fe 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -95,7 +95,7 @@ export default function createIntegration(args?: Options): AstroIntegration { // A URL for the final build path after renaming const finalBuildUrl = pathToFileURL(buildPath.replace(/\.mjs$/, '.js')); - await esbuild.build({ + await esbuild.build({ target: 'es2020', platform: 'browser', entryPoints: [entryPath], @@ -103,7 +103,7 @@ export default function createIntegration(args?: Options): AstroIntegration { allowOverwrite: true, format: 'esm', bundle: true, - minify: true, + minify: _config.vite?.build?.minify !== false, banner: { js: SHIM, }, From 3a6846e3e053f666e74e350060f7428a157baf5f Mon Sep 17 00:00:00 2001 From: AirBorne04 Date: Thu, 27 Apr 2023 08:13:11 +0000 Subject: [PATCH 147/500] [ci] format --- packages/integrations/cloudflare/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index bbe8c65c74fe..dd3ed7005dc0 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -95,7 +95,7 @@ export default function createIntegration(args?: Options): AstroIntegration { // A URL for the final build path after renaming const finalBuildUrl = pathToFileURL(buildPath.replace(/\.mjs$/, '.js')); - await esbuild.build({ + await esbuild.build({ target: 'es2020', platform: 'browser', entryPoints: [entryPath], From 65e76dd64cacb490168e17e7eb702e9b391ff684 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 27 Apr 2023 07:12:14 -0700 Subject: [PATCH 148/500] [ci] release (#6914) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 9 +++++++++ packages/integrations/cloudflare/package.json | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index 950b83aa801c..a34f6bff3b04 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,14 @@ # @astrojs/cloudflare +## 6.2.3 + +### Patch Changes + +- [#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 + +- Updated dependencies [[`b89042553`](https://github.com/withastro/astro/commit/b89042553ec45d5f6bc71747e0f3470ba969e679)]: + - astro@2.3.2 + ## 6.2.2 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index e926f313fc20..59a7a984cc29 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to Cloudflare Workers/Pages", - "version": "6.2.2", + "version": "6.2.3", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.3.1" + "astro": "workspace:^2.3.2" }, "devDependencies": { "astro": "workspace:*", From c1b6b00d9458cf683cee8f7a78c00907449ca4cc Mon Sep 17 00:00:00 2001 From: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> Date: Fri, 28 Apr 2023 03:37:26 -0300 Subject: [PATCH 149/500] Add missing code language in Cloudflare README (#6925) --- packages/integrations/cloudflare/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 2e61063dbde6..c6ca85c5649c 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -117,7 +117,7 @@ You can also check our [Astro Integration Documentation][astro-integration] for Currently, errors during running your application in Wrangler are not very useful, due to the minification of your code. For better debugging, you can add `vite.build.minify = false` setting to your `astro.config.js` -``` +```js export default defineConfig({ adapter: cloudflare(), output: 'server', From 36a77295c280b0c45d5bd6622b9d70e5aba125a8 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Mon, 1 May 2023 07:58:03 -0700 Subject: [PATCH 150/500] [ci] release (#6924) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/CHANGELOG.md | 9 +++++++++ packages/integrations/cloudflare/package.json | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index a34f6bff3b04..32e477035a61 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,14 @@ # @astrojs/cloudflare +## 6.2.4 + +### Patch Changes + +- [#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 + +- 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)]: + - astro@2.3.3 + ## 6.2.3 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 59a7a984cc29..65ce497cd4f8 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to Cloudflare Workers/Pages", - "version": "6.2.3", + "version": "6.2.4", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.3.2" + "astro": "workspace:^2.3.3" }, "devDependencies": { "astro": "workspace:*", From 843becd592008dd90a9285d9b4583424c6050e0b Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Tue, 2 May 2023 12:13:10 -0700 Subject: [PATCH 151/500] [ci] release (#6954) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 65ce497cd4f8..7f0dbb514fd7 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.3.3" + "astro": "workspace:^2.3.4" }, "devDependencies": { "astro": "workspace:*", From 8939493697663fe4eabaf1e9c7e7f72fe065ff79 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 4 May 2023 09:49:17 -0700 Subject: [PATCH 152/500] [ci] release (#6977) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 7f0dbb514fd7..bfd2e19e51b4 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.3.4" + "astro": "workspace:^2.4.0" }, "devDependencies": { "astro": "workspace:*", From c8f0552412fc6ccd22cd580055a8f5b63f3e82f0 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 4 May 2023 13:19:01 -0700 Subject: [PATCH 153/500] [ci] release (#6996) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index bfd2e19e51b4..5933b1399f6f 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.4.0" + "astro": "workspace:^2.4.1" }, "devDependencies": { "astro": "workspace:*", From 2442838958c65aa0642af24579761fcaac7babdd Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Fri, 5 May 2023 10:23:18 -0700 Subject: [PATCH 154/500] [ci] release (#7005) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 5933b1399f6f..a5018bac0b8c 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.4.1" + "astro": "workspace:^2.4.2" }, "devDependencies": { "astro": "workspace:*", From 3b0143dfff397b99e7943124bd87cf10b77de0ec Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Mon, 8 May 2023 10:17:09 -0700 Subject: [PATCH 155/500] [ci] release (#7037) Co-authored-by: github-actions[bot] --- packages/integrations/cloudflare/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index a5018bac0b8c..d08d21e09e0e 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -38,7 +38,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.4.2" + "astro": "workspace:^2.4.3" }, "devDependencies": { "astro": "workspace:*", From e28653cb9aa0ffdd6260f31fdc709a84f4acaa41 Mon Sep 17 00:00:00 2001 From: Reuben Tier <64310361+TheOtterlord@users.noreply.github.com> Date: Mon, 8 May 2023 21:12:41 +0100 Subject: [PATCH 156/500] Fix generation for routes defined using getStaticPaths (#7029) * Fix static site dynamic routes for sitemap integration * Add changeset * Update pnpm-lock * Remove console.log --- .../fixtures/basics/functions/[[path]].js | 277 ++++++++++++++++++ 1 file changed, 277 insertions(+) create mode 100644 packages/integrations/cloudflare/test/fixtures/basics/functions/[[path]].js diff --git a/packages/integrations/cloudflare/test/fixtures/basics/functions/[[path]].js b/packages/integrations/cloudflare/test/fixtures/basics/functions/[[path]].js new file mode 100644 index 000000000000..4145f7c9b330 --- /dev/null +++ b/packages/integrations/cloudflare/test/fixtures/basics/functions/[[path]].js @@ -0,0 +1,277 @@ +globalThis.process = { + argv: [], + env: {}, +}; +var En=Object.create;var lt=Object.defineProperty;var jn=Object.getOwnPropertyDescriptor;var $n=Object.getOwnPropertyNames;var Cn=Object.getPrototypeOf,Fn=Object.prototype.hasOwnProperty;var Rn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Pn=(e,t,a,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $n(t))!Fn.call(e,o)&&o!==a&<(e,o,{get:()=>t[o],enumerable:!(i=jn(t,o))||i.enumerable});return e};var ct=(e,t,a)=>(a=e!=null?En(Cn(e)):{},Pn(t||!e||!e.__esModule?lt(a,"default",{value:e,enumerable:!0}):a,e));var je=(e,t,a)=>{if(!t.has(e))throw TypeError("Cannot "+a)};var u=(e,t,a)=>(je(e,t,"read from private field"),a?a.call(e):t.get(e)),k=(e,t,a)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,a)},j=(e,t,a,i)=>(je(e,t,"write to private field"),i?i.call(e,a):t.set(e,a),a);var M=(e,t,a)=>(je(e,t,"access private method"),a);var Ce=Rn($e=>{"use strict";$e.parse=zn;$e.serialize=On;var Nn=decodeURIComponent,Tn=encodeURIComponent,me=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function zn(e,t){if(typeof e!="string")throw new TypeError("argument str must be a string");for(var a={},i=t||{},o=e.split(";"),r=i.decode||Nn,n=0;n`\`Astro.clientAddress\` is not available in the \`${e}\` adapter. File an issue with the adapter to add support.`},StaticClientAddressNotAvailable:{title:"`Astro.clientAddress` is not available in static mode.",code:3003,message:"`Astro.clientAddress` is only available when using `output: 'server'`. Update your Astro config if you need SSR features.",hint:"See https://docs.astro.build/en/guides/server-side-rendering/#enabling-ssr-in-your-project for more information on how to enable SSR."},NoMatchingStaticPathFound:{title:"No static path found for requested path.",code:3004,message:e=>`A \`getStaticPaths()\` route pattern was matched, but no matching static path was found for requested path \`${e}\`.`,hint:e=>`Possible dynamic routes being matched: ${e.join(", ")}.`},OnlyResponseCanBeReturned:{title:"Invalid type returned by Astro page.",code:3005,message:(e,t)=>`Route \`${e||""}\` returned a \`${t}\`. Only a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) can be returned from Astro files.`,hint:"See https://docs.astro.build/en/guides/server-side-rendering/#response for more information."},MissingMediaQueryDirective:{title:"Missing value for `client:media` directive.",code:3006,message:'Media query not provided for `client:media` directive. A media query similar to `client:media="(max-width: 600px)"` must be provided'},NoMatchingRenderer:{title:"No matching renderer found.",code:3007,message:(e,t,a,i)=>`Unable to render \`${e}\`. + +${i>0?`There ${a?"are.":"is."} ${i} renderer${a?"s.":""} configured in your \`astro.config.mjs\` file, +but ${a?"none were.":"it was not."} able to server-side render \`${e}\`.`:`No valid renderer was found ${t?`for the \`.${t}\` file extension.`:"for this file extension."}`}`,hint:e=>`Did you mean to enable the ${e} integration? + +See https://docs.astro.build/en/core-concepts/framework-components/ for more information on how to install and configure integrations.`},NoClientEntrypoint:{title:"No client entrypoint specified in renderer.",code:3008,message:(e,t,a)=>`\`${e}\` component has a \`client:${t}\` directive, but no client entrypoint was provided by \`${a}\`.`,hint:"See https://docs.astro.build/en/reference/integrations-reference/#addrenderer-option for more information on how to configure your renderer."},NoClientOnlyHint:{title:"Missing hint on client:only directive.",code:3009,message:e=>`Unable to render \`${e}\`. When using the \`client:only\` hydration strategy, Astro needs a hint to use the correct renderer.`,hint:e=>`Did you mean to pass \`client:only="${e}"\`? See https://docs.astro.build/en/reference/directives-reference/#clientonly for more information on client:only`},InvalidGetStaticPathParam:{title:"Invalid value returned by a `getStaticPaths` path.",code:3010,message:e=>`Invalid params given to \`getStaticPaths\` path. Expected an \`object\`, got \`${e}\``,hint:"See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."},InvalidGetStaticPathsReturn:{title:"Invalid value returned by getStaticPaths.",code:3011,message:e=>`Invalid type returned by \`getStaticPaths\`. Expected an \`array\`, got \`${e}\``,hint:"See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."},GetStaticPathsRemovedRSSHelper:{title:"getStaticPaths RSS helper is not available anymore.",code:3012,message:"The RSS helper has been removed from `getStaticPaths`. Try the new @astrojs/rss package instead.",hint:"See https://docs.astro.build/en/guides/rss/ for more information."},GetStaticPathsExpectedParams:{title:"Missing params property on `getStaticPaths` route.",code:3013,message:"Missing or empty required `params` property on `getStaticPaths` route.",hint:"See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."},GetStaticPathsInvalidRouteParam:{title:"Invalid value for `getStaticPaths` route parameter.",code:3014,message:(e,t,a)=>`Invalid getStaticPaths route parameter for \`${e}\`. Expected undefined, a string or a number, received \`${a}\` (\`${t}\`)`,hint:"See https://docs.astro.build/en/reference/api-reference/#getstaticpaths for more information on getStaticPaths."},GetStaticPathsRequired:{title:"`getStaticPaths()` function required for dynamic routes.",code:3015,message:"`getStaticPaths()` function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.",hint:'See https://docs.astro.build/en/core-concepts/routing/#dynamic-routes for more information on dynamic routes.\n\nAlternatively, set `output: "server"` in your Astro config file to switch to a non-static server build. This error can also occur if using `export const prerender = true;`.\nSee https://docs.astro.build/en/guides/server-side-rendering/ for more information on non-static rendering.'},ReservedSlotName:{title:"Invalid slot name.",code:3016,message:e=>`Unable to create a slot named \`${e}\`. \`${e}\` is a reserved slot name. Please update the name of this slot.`},NoAdapterInstalled:{title:"Cannot use Server-side Rendering without an adapter.",code:3017,message:"Cannot use `output: 'server'` without an adapter. Please install and configure the appropriate server adapter for your final deployment.",hint:"See https://docs.astro.build/en/guides/server-side-rendering/ for more information."},NoMatchingImport:{title:"No import found for component.",code:3018,message:e=>`Could not render \`${e}\`. No matching import has been found for \`${e}\`.`,hint:"Please make sure the component is properly imported."},InvalidPrerenderExport:{title:"Invalid prerender export.",code:3019,message:(e,t)=>{let a="A `prerender` export has been detected, but its value cannot be statically analyzed.";return e!=="const"&&(a+=` +Expected \`const\` declaration but got \`${e}\`.`),t!=="true"&&(a+=` +Expected \`true\` value but got \`${t}\`.`),a},hint:"Mutable values declared at runtime are not supported. Please make sure to use exactly `export const prerender = true`."},InvalidComponentArgs:{title:"Invalid component arguments.",code:3020,message:e=>`Invalid arguments passed to${e?` <${e}>`:""} component.`,hint:"Astro components cannot be rendered directly via function call, such as `Component()` or `{items.map(Component)}`."},PageNumberParamNotFound:{title:"Page number param not found.",code:3021,message:e=>`[paginate()] page number param \`${e}\` not found in your filepath.`,hint:"Rename your file to `[page].astro` or `[...page].astro`."},ImageMissingAlt:{title:"Missing alt property.",code:3022,message:"The alt property is required.",hint:"The `alt` property is important for the purpose of accessibility, without it users using screen readers or other assistive technologies won't be able to understand what your image is supposed to represent. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-alt for more information."},InvalidImageService:{title:"Error while loading image service.",code:3023,message:"There was an error loading the configured image service. Please see the stack trace for more information."},MissingImageDimension:{title:"Missing image dimensions",code:3024,message:(e,t)=>`Missing ${e==="both"?"width and height attributes":`${e} attribute`} for ${t}. When using remote images, both dimensions are always required in order to avoid CLS.`,hint:"If your image is inside your `src` folder, you probably meant to import it instead. See [the Imports guide for more information](https://docs.astro.build/en/guides/imports/#other-assets)."},UnsupportedImageFormat:{title:"Unsupported image format",code:3025,message:(e,t,a)=>`Received unsupported format \`${e}\` from \`${t}\`. Currently only ${a.join(", ")} are supported for optimization.`,hint:"If you do not need optimization, using an `img` tag directly instead of the `Image` component might be what you're looking for."},PrerenderDynamicEndpointPathCollide:{title:"Prerendered dynamic endpoint has path collision.",code:3026,message:e=>`Could not render \`${e}\` with an \`undefined\` param as the generated path will collide during prerendering. Prevent passing \`undefined\` as \`params\` for the endpoint's \`getStaticPaths()\` function, or add an additional extension to the endpoint's filename.`,hint:e=>`Rename \`${e}\` to \`${e.replace(/\.(js|ts)/,t=>".json"+t)}\``},ExpectedImage:{title:"Expected src to be an image.",code:3027,message:e=>`Expected \`src\` property to be either an ESM imported image or a string with the path of a remote image. Received \`${e}\`.`,hint:"This error can often happen because of a wrong path. Make sure the path to your image is correct."},ExpectedImageOptions:{title:"Expected image options.",code:3028,message:e=>`Expected getImage() parameter to be an object. Received \`${e}\`.`},MarkdownImageNotFound:{title:"Image not found.",code:3029,message:(e,t)=>`Could not find requested image \`${e}\`${t?` at \`${t}\`.`:"."}`,hint:"This is often caused by a typo in the image path. Please make sure the file exists, and is spelled correctly."},ResponseSentError:{title:"Unable to set response",code:3030,message:"The response has already been sent to the browser and cannot be altered."},MiddlewareNoDataOrNextCalled:{title:"The middleware didn't return a response or call `next`",code:3031,message:"The middleware needs to either return a `Response` object or call the `next` function."},MiddlewareNotAResponse:{title:"The middleware returned something that is not a `Response` object",code:3032,message:"Any data returned from middleware must be a valid `Response` object."},LocalsNotAnObject:{title:"Value assigned to `locals` is not accepted",code:3033,message:"`locals` can only be assigned to an object. Other values like numbers, strings, etc. are not accepted.",hint:"If you tried to remove some information from the `locals` object, try to use `delete` or set the property to `undefined`."},LocalsNotSerializable:{title:"`Astro.locals` is not serializable",code:3034,message:e=>`The information stored in \`Astro.locals\` for the path "${e}" is not serializable. +Make sure you store only serializable data.`},UnknownViteError:{title:"Unknown Vite Error.",code:4e3},FailedToLoadModuleSSR:{title:"Could not import file.",code:4001,message:e=>`Could not import \`${e}\`.`,hint:"This is often caused by a typo in the import path. Please make sure the file exists."},InvalidGlob:{title:"Invalid glob pattern.",code:4002,message:e=>`Invalid glob pattern: \`${e}\`. Glob patterns must start with './', '../' or '/'.`,hint:"See https://docs.astro.build/en/guides/imports/#glob-patterns for more information on supported glob patterns."},UnknownCSSError:{title:"Unknown CSS Error.",code:5e3},CSSSyntaxError:{title:"CSS Syntax Error.",code:5001},UnknownMarkdownError:{title:"Unknown Markdown Error.",code:6e3},MarkdownFrontmatterParseError:{title:"Failed to parse Markdown frontmatter.",code:6001},InvalidFrontmatterInjectionError:{title:"Invalid frontmatter injection.",code:6003,message:'A remark or rehype plugin attempted to inject invalid frontmatter. Ensure "astro.frontmatter" is set to a valid JSON object that is not `null` or `undefined`.',hint:"See the frontmatter injection docs https://docs.astro.build/en/guides/markdown-content/#modifying-frontmatter-programmatically for more information."},MdxIntegrationMissingError:{title:"MDX integration missing.",code:6004,message:e=>`Unable to render ${e}. Ensure that the \`@astrojs/mdx\` integration is installed.`,hint:"See the MDX integration docs for installation and usage instructions: https://docs.astro.build/en/guides/integrations-guide/mdx/"},UnknownConfigError:{title:"Unknown configuration error.",code:7e3},ConfigNotFound:{title:"Specified configuration file not found.",code:7001,message:e=>`Unable to resolve \`--config "${e}"\`. Does the file exist?`},ConfigLegacyKey:{title:"Legacy configuration detected.",code:7002,message:e=>`Legacy configuration detected: \`${e}\`.`,hint:`Please update your configuration to the new format. +See https://astro.build/config for more information.`},UnknownCLIError:{title:"Unknown CLI Error.",code:8e3},GenerateContentTypesError:{title:"Failed to generate content types.",code:8001,message:e=>`\`astro sync\` command failed to generate content collection types: ${e}`,hint:"Check your `src/content/config.*` file for typos."},UnknownContentCollectionError:{title:"Unknown Content Collection Error.",code:9e3},InvalidContentEntryFrontmatterError:{title:"Content entry frontmatter does not match schema.",code:9001,message:(e,t,a)=>[`**${String(e)} \u2192 ${String(t)}** frontmatter does not match collection schema.`,...a.errors.map(i=>i.message)].join(` +`),hint:"See https://docs.astro.build/en/guides/content-collections/ for more information on content schemas."},InvalidContentEntrySlugError:{title:"Invalid content entry slug.",code:9002,message:(e,t)=>`${String(e)} \u2192 ${String(t)} has an invalid slug. \`slug\` must be a string.`,hint:"See https://docs.astro.build/en/guides/content-collections/ for more on the `slug` field."},ContentSchemaContainsSlugError:{title:"Content Schema should not contain `slug`.",code:9003,message:e=>`A content collection schema should not contain \`slug\` since it is reserved for slug generation. Remove this from your ${e} collection schema.`,hint:"See https://docs.astro.build/en/guides/content-collections/ for more on the `slug` field."},UnknownError:{title:"Unknown Error.",code:99999}};function Hn(e){return e.replace(/\r\n|\r(?!\n)|\n/g,` +`)}function qn(e){let t=Object.entries(f).find(a=>a[1].code===e);if(t)return{name:t[0],data:t[1]}}function Bn(e,t){if(!t||t.line===void 0||t.column===void 0)return"";let a=Hn(e).split(` +`).map(n=>n.replace(/\t/g," ")),i=[];for(let n=-2;n<=2;n++)a[t.line+n]&&i.push(t.line+n);let o=0;for(let n of i){let s=`> ${n}`;s.length>o&&(o=s.length)}let r="";for(let n of i){let s=n===t.line-1;r+=s?"> ":" ",r+=`${n+1} | ${a[n]} +`,s&&(r+=`${Array.from({length:o}).join(" ")} | ${Array.from({length:t.column}).join(" ")}^ +`)}return r}var v=class extends Error{constructor(t,...a){var i;super(...a),this.type="AstroError";let{code:o,name:r,title:n,message:s,stack:p,location:d,hint:l,frame:c}=t;this.errorCode=o,r&&r!=="Error"?this.name=r:this.name=((i=qn(this.errorCode))==null?void 0:i.name)??"UnknownError",this.title=n,s&&(this.message=s),this.stack=p||this.stack,this.loc=d,this.hint=l,this.frame=c}setErrorCode(t){this.errorCode=t}setLocation(t){this.loc=t}setName(t){this.name=t}setMessage(t){this.message=t}setHint(t){this.hint=t}setFrame(t,a){this.frame=Bn(t,a)}static is(t){return t.type==="AstroError"}},Vn=new Date(0),dt="deleted",Jn=Symbol.for("astro.responseSent"),ee=class{constructor(t){this.value=t}json(){if(this.value===void 0)throw new Error("Cannot convert undefined to an object.");return JSON.parse(this.value)}number(){return Number(this.value)}boolean(){return this.value==="false"||this.value==="0"?!1:!!this.value}},J,I,R,ie,De,oe,_e,ve,Mt,ue=class{constructor(t){k(this,ie);k(this,oe);k(this,ve);k(this,J,void 0);k(this,I,void 0);k(this,R,void 0);j(this,J,t),j(this,I,null),j(this,R,null)}delete(t,a){let i={expires:Vn};a?.domain&&(i.domain=a.domain),a?.path&&(i.path=a.path),M(this,oe,_e).call(this).set(t,[dt,(0,ae.serialize)(t,dt,i),!1])}get(t){if(u(this,R)!==null&&u(this,R).has(t)){let[o,,r]=u(this,R).get(t);return r?new ee(o):new ee(void 0)}let i=M(this,ie,De).call(this)[t];return new ee(i)}has(t){if(u(this,R)!==null&&u(this,R).has(t)){let[,,i]=u(this,R).get(t);return i}return!!M(this,ie,De).call(this)[t]}set(t,a,i){let o;if(typeof a=="string")o=a;else{let n=a.toString();n===Object.prototype.toString.call(a)?o=JSON.stringify(a):o=n}let r={};if(i&&Object.assign(r,i),M(this,oe,_e).call(this).set(t,[o,(0,ae.serialize)(t,o,r),!0]),u(this,J)[Jn])throw new v({...f.ResponseSentError})}*headers(){if(u(this,R)!=null)for(let[,t]of u(this,R))yield t[1]}};J=new WeakMap,I=new WeakMap,R=new WeakMap,ie=new WeakSet,De=function(){return u(this,I)||M(this,ve,Mt).call(this),u(this,I)||j(this,I,{}),u(this,I)},oe=new WeakSet,_e=function(){return u(this,R)||j(this,R,new Map),u(this,R)},ve=new WeakSet,Mt=function(){let t=u(this,J).headers.get("cookie");t&&j(this,I,(0,ae.parse)(t))};var It=Symbol.for("astro.cookies");function Qe(e,t){Reflect.set(e,It,t)}function Gn(e){let t=Reflect.get(e,It);if(t!=null)return t}function*Wn(e){let t=Gn(e);if(!t)return[];for(let a of t.headers())yield a;return[]}function Kn(e){return!(e.length!==3||!e[0]||typeof e[0]!="object")}function Dt(e,t){var a;let i=((a=t?.split("/").pop())==null?void 0:a.replace(".astro",""))??"",o=(...r)=>{if(!Kn(r))throw new v({...f.InvalidComponentArgs,message:f.InvalidComponentArgs.message(i)});return e(...r)};return Object.defineProperty(o,"name",{value:i,writable:!1}),o.isAstroComponentFactory=!0,o.moduleId=t,o}function Xn(e){let t=Dt(e.factory,e.moduleId);return t.propagation=e.propagation,t}function _t(e,t){return typeof e=="function"?Dt(e,t):Xn(e)}var Ut="2.4.2";function Yn(){return(t,a)=>{let i=[...Object.values(t)];if(i.length===0)throw new Error(`Astro.glob(${JSON.stringify(a())}) - no matches found.`);return Promise.all(i.map(o=>o()))}}function Lt(e){return{site:e?new URL(e):void 0,generator:`Astro v${Ut}`,glob:Yn()}}function Qn(e,t){if(e[t])return e[t];if(t==="delete"&&e.del)return e.del;if(e.all)return e.all}async function Zn(e,t,a){var i;let{request:o,params:r,locals:n}=t,s=(i=o.method)==null?void 0:i.toLowerCase(),p=Qn(e,s);if(!a&&a===!1&&s&&s!=="get"&&console.warn(` +${s} requests are not available when building a static site. Update your config to output: 'server' to handle ${s} requests.`),!p||typeof p!="function")return new Response(null,{status:404,headers:{"X-Astro-Response":"Not-Found"}});p.length>1&&console.warn(` +API routes with 2 arguments have been deprecated. Instead they take a single argument in the form of: + +export function get({ params, request }) { + //... +} + +Update your code to remove this warning.`);let d=new Proxy(t,{get(l,c){return c in l?Reflect.get(l,c):c in r?(console.warn(` +API routes no longer pass params as the first argument. Instead an object containing a params property is provided in the form of: + +export function get({ params }) { + // ... +} + +Update your code to remove this warning.`),Reflect.get(r,c)):void 0}});return p.call(e,d,o)}var{replace:ea}="",ta=/[&<>'"]/g,na={"&":"&","<":"<",">":">","'":"'",'"':"""},aa=e=>na[e],ia=e=>ea.call(e,ta,aa);function Ht(e){let t={};return a(e),Object.keys(t).join(" ");function a(i){i&&typeof i.forEach=="function"?i.forEach(a):i===Object(i)?Object.keys(i).forEach(o=>{i[o]&&a(o)}):(i=i===!1||i==null?"":String(i).trim(),i&&i.split(/\s+/).forEach(o=>{t[o]=!0}))}}function Ze(e){return!!e&&typeof e=="object"&&typeof e.then=="function"}async function*mt(e){let t=e.getReader();try{for(;;){let{done:a,value:i}=await t.read();if(a)return;yield i}}finally{t.releaseLock()}}var te=ia,V=class extends String{get[Symbol.toStringTag](){return"HTMLString"}},y=e=>e instanceof V?e:typeof e=="string"?new V(e):e;function et(e){return Object.prototype.toString.call(e)==="[object HTMLString]"}var Se="astro:jsx",ut=Symbol("empty"),ft=e=>e;function ne(e){return e&&typeof e=="object"&&e[Se]}function oa(e){if(typeof e.type=="string")return e;let t={};if(ne(e.props.children)){let a=e.props.children;if(!ne(a)||!("slot"in a.props))return;let i=ft(a.props.slot);t[i]=[a],t[i].$$slot=!0,delete a.props.slot,delete e.props.children}Array.isArray(e.props.children)&&(e.props.children=e.props.children.map(a=>{if(!ne(a)||!("slot"in a.props))return a;let i=ft(a.props.slot);return Array.isArray(t[i])?t[i].push(a):(t[i]=[a],t[i].$$slot=!0),delete a.props.slot,ut}).filter(a=>a!==ut)),Object.assign(e.props,t)}function qt(e){return typeof e=="string"?y(e):Array.isArray(e)?e.map(t=>qt(t)):e}function ra(e){if("set:html"in e.props||"set:text"in e.props){if("set:html"in e.props){let t=qt(e.props["set:html"]);delete e.props["set:html"],Object.assign(e.props,{children:t});return}if("set:text"in e.props){let t=e.props["set:text"];delete e.props["set:text"],Object.assign(e.props,{children:t});return}}}function sa(e,t){let a={[qe]:"astro:jsx",[Se]:!0,type:e,props:t??{}};return ra(a),oa(a),a}var pa=`(self.Astro = self.Astro || {}).idle = (getHydrateCallback) => { + const cb = async () => { + let hydrate = await getHydrateCallback(); + await hydrate(); + }; + if ("requestIdleCallback" in window) { + window.requestIdleCallback(cb); + } else { + setTimeout(cb, 200); + } +}; +window.dispatchEvent(new Event("astro:idle"));`,la=`(self.Astro = self.Astro || {}).load = (getHydrateCallback) => { + (async () => { + let hydrate = await getHydrateCallback(); + await hydrate(); + })(); +}; +window.dispatchEvent(new Event("astro:load"));`,ca=`(self.Astro = self.Astro || {}).media = (getHydrateCallback, options) => { + const cb = async () => { + let hydrate = await getHydrateCallback(); + await hydrate(); + }; + if (options.value) { + const mql = matchMedia(options.value); + if (mql.matches) { + cb(); + } else { + mql.addEventListener("change", cb, { once: true }); + } + } +}; +window.dispatchEvent(new Event("astro:media"));`,da=`(self.Astro = self.Astro || {}).only = (getHydrateCallback) => { + (async () => { + let hydrate = await getHydrateCallback(); + await hydrate(); + })(); +}; +window.dispatchEvent(new Event("astro:only"));`,ma=`(self.Astro = self.Astro || {}).visible = (getHydrateCallback, _opts, root) => { + const cb = async () => { + let hydrate = await getHydrateCallback(); + await hydrate(); + }; + let io = new IntersectionObserver((entries) => { + for (const entry of entries) { + if (!entry.isIntersecting) + continue; + io.disconnect(); + cb(); + break; + } + }); + for (let i = 0; i < root.children.length; i++) { + const child = root.children[i]; + io.observe(child); + } +}; +window.dispatchEvent(new Event("astro:visible"));`,ua=`var _a; +{ + const propTypes = { + 0: (value) => value, + 1: (value) => JSON.parse(value, reviver), + 2: (value) => new RegExp(value), + 3: (value) => new Date(value), + 4: (value) => new Map(JSON.parse(value, reviver)), + 5: (value) => new Set(JSON.parse(value, reviver)), + 6: (value) => BigInt(value), + 7: (value) => new URL(value), + 8: (value) => new Uint8Array(JSON.parse(value)), + 9: (value) => new Uint16Array(JSON.parse(value)), + 10: (value) => new Uint32Array(JSON.parse(value)) + }; + const reviver = (propKey, raw) => { + if (propKey === "" || !Array.isArray(raw)) + return raw; + const [type, value] = raw; + return type in propTypes ? propTypes[type](value) : void 0; + }; + if (!customElements.get("astro-island")) { + customElements.define( + "astro-island", + (_a = class extends HTMLElement { + constructor() { + super(...arguments); + this.hydrate = () => { + if (!this.hydrator || this.parentElement && this.parentElement.closest("astro-island[ssr]")) { + return; + } + const slotted = this.querySelectorAll("astro-slot"); + const slots = {}; + const templates = this.querySelectorAll("template[data-astro-template]"); + for (const template of templates) { + const closest = template.closest(this.tagName); + if (!closest || !closest.isSameNode(this)) + continue; + slots[template.getAttribute("data-astro-template") || "default"] = template.innerHTML; + template.remove(); + } + for (const slot of slotted) { + const closest = slot.closest(this.tagName); + if (!closest || !closest.isSameNode(this)) + continue; + slots[slot.getAttribute("name") || "default"] = slot.innerHTML; + } + const props = this.hasAttribute("props") ? JSON.parse(this.getAttribute("props"), reviver) : {}; + this.hydrator(this)(this.Component, props, slots, { + client: this.getAttribute("client") + }); + this.removeAttribute("ssr"); + window.removeEventListener("astro:hydrate", this.hydrate); + window.dispatchEvent(new CustomEvent("astro:hydrate")); + }; + } + connectedCallback() { + if (!this.hasAttribute("await-children") || this.firstChild) { + this.childrenConnectedCallback(); + } else { + new MutationObserver((_, mo) => { + mo.disconnect(); + this.childrenConnectedCallback(); + }).observe(this, { childList: true }); + } + } + async childrenConnectedCallback() { + window.addEventListener("astro:hydrate", this.hydrate); + let beforeHydrationUrl = this.getAttribute("before-hydration-url"); + if (beforeHydrationUrl) { + await import(beforeHydrationUrl); + } + this.start(); + } + start() { + const opts = JSON.parse(this.getAttribute("opts")); + const directive = this.getAttribute("client"); + if (Astro[directive] === void 0) { + window.addEventListener(\`astro:\${directive}\`, () => this.start(), { once: true }); + return; + } + Astro[directive]( + async () => { + const rendererUrl = this.getAttribute("renderer-url"); + const [componentModule, { default: hydrator }] = await Promise.all([ + import(this.getAttribute("component-url")), + rendererUrl ? import(rendererUrl) : () => () => { + } + ]); + const componentExport = this.getAttribute("component-export") || "default"; + if (!componentExport.includes(".")) { + this.Component = componentModule[componentExport]; + } else { + this.Component = componentModule; + for (const part of componentExport.split(".")) { + this.Component = this.Component[part]; + } + } + this.hydrator = hydrator; + return this.hydrate; + }, + opts, + this + ); + } + attributeChangedCallback() { + if (this.hydrator) + this.hydrate(); + } + }, _a.observedAttributes = ["props"], _a) + ); + } +}`;function fa(e){return e._metadata.hasHydrationScript?!1:e._metadata.hasHydrationScript=!0}var xt={idle:pa,load:la,only:da,media:ca,visible:ma};function xa(e,t){return e._metadata.hasDirectives.has(t)?!1:(e._metadata.hasDirectives.add(t),!0)}function ht(e){if(!(e in xt))throw new Error(`Unknown directive: ${e}`);return xt[e]}function ha(e,t){switch(e){case"both":return`