From bde49f186e4d620ce0c926353db38215e33dceef Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Fri, 15 Nov 2024 20:50:01 +0800 Subject: [PATCH 01/27] Publish missing file for svelte integration (#12442) --- .changeset/wild-houses-learn.md | 5 +++++ packages/integrations/svelte/package.json | 7 ++----- 2 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 .changeset/wild-houses-learn.md diff --git a/.changeset/wild-houses-learn.md b/.changeset/wild-houses-learn.md new file mode 100644 index 0000000000..6f86fe6c7d --- /dev/null +++ b/.changeset/wild-houses-learn.md @@ -0,0 +1,5 @@ +--- +'@astrojs/svelte': patch +--- + +Publishes missing file diff --git a/packages/integrations/svelte/package.json b/packages/integrations/svelte/package.json index 017e9e2ea8..60e8f8704d 100644 --- a/packages/integrations/svelte/package.json +++ b/packages/integrations/svelte/package.json @@ -24,15 +24,12 @@ "./editor": "./dist/editor.cjs", "./*": "./*", "./client.js": "./client.svelte.js", - "./server.js": { - "default": "./server.js", - "types": "./server.d.ts" - }, + "./server.js": "./server.js", "./package.json": "./package.json" }, "files": [ "dist", - "client.js", + "client.svelte.js", "server.js", "server.d.ts" ], From 8e135b6f036a37c5df7884209e767e298262bad7 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Fri, 15 Nov 2024 04:59:51 -0800 Subject: [PATCH 02/27] [ci] release (#12443) Co-authored-by: github-actions[bot] --- .changeset/wild-houses-learn.md | 5 ----- examples/framework-multiple/package.json | 2 +- examples/framework-svelte/package.json | 2 +- examples/ssr/package.json | 2 +- packages/integrations/svelte/CHANGELOG.md | 6 ++++++ packages/integrations/svelte/package.json | 2 +- pnpm-lock.yaml | 6 +++--- 7 files changed, 13 insertions(+), 12 deletions(-) delete mode 100644 .changeset/wild-houses-learn.md diff --git a/.changeset/wild-houses-learn.md b/.changeset/wild-houses-learn.md deleted file mode 100644 index 6f86fe6c7d..0000000000 --- a/.changeset/wild-houses-learn.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/svelte': patch ---- - -Publishes missing file diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index e9c92a4a89..d8b86a81dc 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -14,7 +14,7 @@ "@astrojs/preact": "^3.5.3", "@astrojs/react": "^3.6.2", "@astrojs/solid-js": "^4.4.3", - "@astrojs/svelte": "^6.0.0", + "@astrojs/svelte": "^6.0.1", "@astrojs/vue": "^4.5.2", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index 87530dfc52..2a06f5d65c 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -11,7 +11,7 @@ "astro": "astro" }, "dependencies": { - "@astrojs/svelte": "^6.0.0", + "@astrojs/svelte": "^6.0.1", "astro": "^4.16.13", "svelte": "^5.1.16" } diff --git a/examples/ssr/package.json b/examples/ssr/package.json index f3fd53b2a5..88802eada3 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@astrojs/node": "^8.3.4", - "@astrojs/svelte": "^6.0.0", + "@astrojs/svelte": "^6.0.1", "astro": "^4.16.13", "svelte": "^5.1.16" } diff --git a/packages/integrations/svelte/CHANGELOG.md b/packages/integrations/svelte/CHANGELOG.md index 4199a0dd69..81985044c4 100644 --- a/packages/integrations/svelte/CHANGELOG.md +++ b/packages/integrations/svelte/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/svelte +## 6.0.1 + +### Patch Changes + +- [#12442](https://github.com/withastro/astro/pull/12442) [`bde49f1`](https://github.com/withastro/astro/commit/bde49f186e4d620ce0c926353db38215e33dceef) Thanks [@bluwy](https://github.com/bluwy)! - Publishes missing file + ## 6.0.0 ### Major Changes diff --git a/packages/integrations/svelte/package.json b/packages/integrations/svelte/package.json index 60e8f8704d..4a32ec3d4d 100644 --- a/packages/integrations/svelte/package.json +++ b/packages/integrations/svelte/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/svelte", - "version": "6.0.0", + "version": "6.0.1", "description": "Use Svelte components within Astro", "type": "module", "types": "./dist/index.d.ts", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 84f5b46758..bf17ca08c1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -230,7 +230,7 @@ importers: specifier: ^4.4.3 version: link:../../packages/integrations/solid '@astrojs/svelte': - specifier: ^6.0.0 + specifier: ^6.0.1 version: link:../../packages/integrations/svelte '@astrojs/vue': specifier: ^4.5.2 @@ -314,7 +314,7 @@ importers: examples/framework-svelte: dependencies: '@astrojs/svelte': - specifier: ^6.0.0 + specifier: ^6.0.1 version: link:../../packages/integrations/svelte astro: specifier: ^4.16.13 @@ -368,7 +368,7 @@ importers: specifier: ^8.3.4 version: 8.3.4(astro@packages+astro) '@astrojs/svelte': - specifier: ^6.0.0 + specifier: ^6.0.1 version: link:../../packages/integrations/svelte astro: specifier: ^4.16.13 From cec4af8fe59ff895c0ca82aab8b6ed6a81ad1f4d Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Fri, 15 Nov 2024 23:43:34 +0800 Subject: [PATCH 03/27] Add publint checks (#12445) --- .github/workflows/ci.yml | 5 +- package.json | 4 +- packages/astro-prism/package.json | 2 +- packages/astro-rss/package.json | 2 +- packages/astro/package.json | 2 +- packages/create-astro/package.json | 2 +- packages/db/package.json | 2 +- packages/integrations/alpinejs/package.json | 2 +- packages/integrations/cloudflare/package.json | 1 + packages/integrations/lit/package.json | 7 +- packages/integrations/markdoc/package.json | 2 +- packages/integrations/mdx/package.json | 2 +- packages/integrations/netlify/package.json | 1 + packages/integrations/node/package.json | 1 + packages/integrations/partytown/package.json | 2 +- packages/integrations/preact/package.json | 2 +- packages/integrations/react/package.json | 12 +- packages/integrations/sitemap/package.json | 2 +- packages/integrations/solid/package.json | 2 +- packages/integrations/svelte/package.json | 2 +- packages/integrations/tailwind/package.json | 2 +- packages/integrations/vercel/package.json | 1 + packages/integrations/vue/package.json | 7 +- packages/integrations/web-vitals/package.json | 2 +- packages/internal-helpers/package.json | 2 +- packages/markdown/remark/package.json | 2 +- packages/studio/package.json | 2 +- packages/telemetry/package.json | 2 +- packages/underscore-redirects/package.json | 2 +- packages/upgrade/package.json | 2 +- pnpm-lock.yaml | 108 ++++++++++++++++++ 31 files changed, 147 insertions(+), 42 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a494b3179..cde351c7c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -95,9 +95,12 @@ jobs: - name: Build Packages run: pnpm run build - - name: Lint + - name: Lint source code run: pnpm run lint:ci + - name: Lint publish code + run: pnpm run publint + test: name: "Test: ${{ matrix.os }} (node@${{ matrix.NODE_VERSION }})" runs-on: ${{ matrix.os }} diff --git a/package.json b/package.json index 861fcb21c1..91d7ee962a 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "private": true, "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git" + "url": "git+https://github.com/withastro/astro.git" }, "scripts": { "release": "pnpm run build && changeset publish", @@ -37,6 +37,7 @@ "lint": "biome lint && eslint . --report-unused-disable-directives", "lint:ci": "biome ci --formatter-enabled=false --organize-imports-enabled=false --reporter=github && eslint . --report-unused-disable-directives", "lint:fix": "biome lint --write --unsafe", + "publint": "pnpm -r --filter=astro --filter=create-astro --filter=\"@astrojs/*\" --no-bail exec publint", "version": "changeset version && node ./scripts/deps/update-example-versions.js && pnpm install --no-frozen-lockfile && pnpm run format", "preinstall": "npx only-allow pnpm" }, @@ -65,6 +66,7 @@ "only-allow": "^1.2.1", "prettier": "^3.3.3", "prettier-plugin-astro": "^0.14.1", + "publint": "^0.2.12", "turbo": "^2.2.3", "typescript": "~5.6.3", "typescript-eslint": "^8.13.0" diff --git a/packages/astro-prism/package.json b/packages/astro-prism/package.json index 82c0c33605..f3ba16f4e8 100644 --- a/packages/astro-prism/package.json +++ b/packages/astro-prism/package.json @@ -8,7 +8,7 @@ "bugs": "https://github.com/withastro/astro/issues", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/astro-prism" }, "homepage": "https://docs.astro.build/en/reference/api-reference/#prism-", diff --git a/packages/astro-rss/package.json b/packages/astro-rss/package.json index 8de405fd7c..627b4dd6ca 100644 --- a/packages/astro-rss/package.json +++ b/packages/astro-rss/package.json @@ -8,7 +8,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/astro-rss" }, "bugs": "https://github.com/withastro/astro/issues", diff --git a/packages/astro/package.json b/packages/astro/package.json index 70b89aa19a..fb0440afa9 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -7,7 +7,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/astro" }, "bugs": "https://github.com/withastro/astro/issues", diff --git a/packages/create-astro/package.json b/packages/create-astro/package.json index 30889d515a..1601e4f7cb 100644 --- a/packages/create-astro/package.json +++ b/packages/create-astro/package.json @@ -6,7 +6,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/create-astro" }, "bugs": "https://github.com/withastro/astro/issues", diff --git a/packages/db/package.json b/packages/db/package.json index d40b36842f..82990e6406 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -5,7 +5,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/db" }, "bugs": "https://github.com/withastro/astro/issues", diff --git a/packages/integrations/alpinejs/package.json b/packages/integrations/alpinejs/package.json index 3196438760..15365c38d4 100644 --- a/packages/integrations/alpinejs/package.json +++ b/packages/integrations/alpinejs/package.json @@ -8,7 +8,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/integrations/alpinejs" }, "keywords": [ diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 9e6bf7f836..05e18bc647 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -2,6 +2,7 @@ "name": "@astrojs/cloudflare", "version": "0.0.0", "private": true, + "type": "module", "keywords": [], "dont_remove": "This is a placeholder for the sake of the docs smoke test" } diff --git a/packages/integrations/lit/package.json b/packages/integrations/lit/package.json index 27650a1f73..1153bdc943 100644 --- a/packages/integrations/lit/package.json +++ b/packages/integrations/lit/package.json @@ -8,7 +8,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/integrations/lit" }, "keywords": [ @@ -21,10 +21,7 @@ "homepage": "https://docs.astro.build/en/guides/integrations-guide/lit/", "exports": { ".": "./dist/index.js", - "./server.js": { - "default": "./server.js", - "types": "./server.d.ts" - }, + "./server.js": "./server.js", "./client-shim.js": "./client-shim.js", "./dist/client.js": "./dist/client.js", "./hydration-support.js": "./hydration-support.js", diff --git a/packages/integrations/markdoc/package.json b/packages/integrations/markdoc/package.json index 757bc063a5..cd8fb06379 100644 --- a/packages/integrations/markdoc/package.json +++ b/packages/integrations/markdoc/package.json @@ -8,7 +8,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/integrations/markdoc" }, "keywords": [ diff --git a/packages/integrations/mdx/package.json b/packages/integrations/mdx/package.json index cac6e8f4ce..90b0877420 100644 --- a/packages/integrations/mdx/package.json +++ b/packages/integrations/mdx/package.json @@ -8,7 +8,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/integrations/mdx" }, "keywords": [ diff --git a/packages/integrations/netlify/package.json b/packages/integrations/netlify/package.json index 2d9ce88d39..4b54bb6c09 100644 --- a/packages/integrations/netlify/package.json +++ b/packages/integrations/netlify/package.json @@ -2,6 +2,7 @@ "name": "@astrojs/netlify", "version": "0.0.0", "private": true, + "type": "module", "keywords": [], "dont_remove": "This is a placeholder for the sake of the docs smoke test" } diff --git a/packages/integrations/node/package.json b/packages/integrations/node/package.json index 656c453933..134ba5d86a 100644 --- a/packages/integrations/node/package.json +++ b/packages/integrations/node/package.json @@ -2,6 +2,7 @@ "name": "@astrojs/node", "version": "0.0.0", "private": true, + "type": "module", "keywords": [], "dont_remove": "This is a placeholder for the sake of the docs smoke test" } diff --git a/packages/integrations/partytown/package.json b/packages/integrations/partytown/package.json index e8fd6e5e6b..0a171c1c0e 100644 --- a/packages/integrations/partytown/package.json +++ b/packages/integrations/partytown/package.json @@ -8,7 +8,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/integrations/partytown" }, "keywords": [ diff --git a/packages/integrations/preact/package.json b/packages/integrations/preact/package.json index e88470166e..c239259561 100644 --- a/packages/integrations/preact/package.json +++ b/packages/integrations/preact/package.json @@ -8,7 +8,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/integrations/preact" }, "keywords": [ diff --git a/packages/integrations/react/package.json b/packages/integrations/react/package.json index 2fadb89acf..9bb7a4e193 100644 --- a/packages/integrations/react/package.json +++ b/packages/integrations/react/package.json @@ -8,7 +8,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/integrations/react" }, "keywords": [ @@ -24,14 +24,8 @@ "./actions": "./dist/actions.js", "./client.js": "./client.js", "./client-v17.js": "./client-v17.js", - "./server.js": { - "default": "./server.js", - "types": "./server.d.ts" - }, - "./server-v17.js": { - "default": "./server-v17.js", - "types": "./server-v17.d.ts" - }, + "./server.js": "./server.js", + "./server-v17.js": "./server-v17.js", "./package.json": "./package.json", "./jsx-runtime": "./jsx-runtime.js" }, diff --git a/packages/integrations/sitemap/package.json b/packages/integrations/sitemap/package.json index 7e4bfb3a67..ec4c02b824 100644 --- a/packages/integrations/sitemap/package.json +++ b/packages/integrations/sitemap/package.json @@ -8,7 +8,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/integrations/sitemap" }, "keywords": [ diff --git a/packages/integrations/solid/package.json b/packages/integrations/solid/package.json index 103d7dae07..d786893628 100644 --- a/packages/integrations/solid/package.json +++ b/packages/integrations/solid/package.json @@ -8,7 +8,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/integrations/solid" }, "keywords": [ diff --git a/packages/integrations/svelte/package.json b/packages/integrations/svelte/package.json index 4a32ec3d4d..2a25510b2f 100644 --- a/packages/integrations/svelte/package.json +++ b/packages/integrations/svelte/package.json @@ -8,7 +8,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/integrations/svelte" }, "keywords": [ diff --git a/packages/integrations/tailwind/package.json b/packages/integrations/tailwind/package.json index 245d7d3381..e43a2657e1 100644 --- a/packages/integrations/tailwind/package.json +++ b/packages/integrations/tailwind/package.json @@ -8,7 +8,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/integrations/tailwind" }, "keywords": [ diff --git a/packages/integrations/vercel/package.json b/packages/integrations/vercel/package.json index 7fef2f9b89..57beba344a 100644 --- a/packages/integrations/vercel/package.json +++ b/packages/integrations/vercel/package.json @@ -2,6 +2,7 @@ "name": "@astrojs/vercel", "version": "0.0.0", "private": true, + "type": "module", "keywords": [], "dont_remove": "This is a placeholder for the sake of the docs smoke test" } diff --git a/packages/integrations/vue/package.json b/packages/integrations/vue/package.json index 1b191ffcfe..325d8781f4 100644 --- a/packages/integrations/vue/package.json +++ b/packages/integrations/vue/package.json @@ -8,7 +8,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/integrations/vue" }, "keywords": [ @@ -24,10 +24,7 @@ "./editor": "./dist/editor.cjs", "./*": "./*", "./client.js": "./client.js", - "./server.js": { - "default": "./server.js", - "types": "./server.d.ts" - }, + "./server.js": "./server.js", "./package.json": "./package.json" }, "files": [ diff --git a/packages/integrations/web-vitals/package.json b/packages/integrations/web-vitals/package.json index 486ab8d393..3aa0616fc1 100644 --- a/packages/integrations/web-vitals/package.json +++ b/packages/integrations/web-vitals/package.json @@ -7,7 +7,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/integrations/web-vitals" }, "keywords": [ diff --git a/packages/internal-helpers/package.json b/packages/internal-helpers/package.json index bbf4938b0c..9f5ebfbb06 100644 --- a/packages/internal-helpers/package.json +++ b/packages/internal-helpers/package.json @@ -7,7 +7,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/internal-helpers" }, "bugs": "https://github.com/withastro/astro/issues", diff --git a/packages/markdown/remark/package.json b/packages/markdown/remark/package.json index d765513b3e..9285aa4895 100644 --- a/packages/markdown/remark/package.json +++ b/packages/markdown/remark/package.json @@ -6,7 +6,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/markdown/remark" }, "bugs": "https://github.com/withastro/astro/issues", diff --git a/packages/studio/package.json b/packages/studio/package.json index 4c85f3484f..5b06775f53 100644 --- a/packages/studio/package.json +++ b/packages/studio/package.json @@ -5,7 +5,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/studio" }, "bugs": "https://github.com/withastro/astro/issues", diff --git a/packages/telemetry/package.json b/packages/telemetry/package.json index 69aac31bc5..5111f168c0 100644 --- a/packages/telemetry/package.json +++ b/packages/telemetry/package.json @@ -7,7 +7,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/telemetry" }, "bugs": "https://github.com/withastro/astro/issues", diff --git a/packages/underscore-redirects/package.json b/packages/underscore-redirects/package.json index 38de31d4bf..f8eeb15e2a 100644 --- a/packages/underscore-redirects/package.json +++ b/packages/underscore-redirects/package.json @@ -7,7 +7,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/underscore-redirects" }, "bugs": "https://github.com/withastro/astro/issues", diff --git a/packages/upgrade/package.json b/packages/upgrade/package.json index 38655068b3..872f6e7295 100644 --- a/packages/upgrade/package.json +++ b/packages/upgrade/package.json @@ -6,7 +6,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/withastro/astro.git", + "url": "git+https://github.com/withastro/astro.git", "directory": "packages/upgrade" }, "bugs": "https://github.com/withastro/astro/issues", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bf17ca08c1..3066c19961 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -48,6 +48,9 @@ importers: prettier-plugin-astro: specifier: ^0.14.1 version: 0.14.1 + publint: + specifier: ^0.2.12 + version: 0.2.12 turbo: specifier: ^2.2.3 version: 2.2.3 @@ -8328,6 +8331,9 @@ packages: resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==} engines: {node: '>= 8'} + fs.realpath@1.0.0: + resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} + fsevents@2.3.2: resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} @@ -8372,6 +8378,11 @@ packages: resolution: {integrity: sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==} hasBin: true + glob@8.1.0: + resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==} + engines: {node: '>=12'} + deprecated: Glob versions prior to v9 are no longer supported + globals@11.12.0: resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} engines: {node: '>=4'} @@ -8536,6 +8547,10 @@ packages: ieee754@1.2.1: resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} + ignore-walk@5.0.1: + resolution: {integrity: sha512-yemi4pMf51WKT7khInJqAvsIGzoqYXblnsz0ql8tM+yi1EKYTY1evX4NAbJrLL/Aanr2HyZeluqU+Oi7MGHokw==} + engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} + ignore@5.3.2: resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} engines: {node: '>= 4'} @@ -8554,6 +8569,10 @@ packages: resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} engines: {node: '>=0.8.19'} + inflight@1.0.6: + resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} + deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. + inherits@2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} @@ -9132,6 +9151,10 @@ packages: minimatch@3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} + minimatch@5.1.6: + resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} + engines: {node: '>=10'} + minimatch@9.0.5: resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==} engines: {node: '>=16 || 14 >=14.17'} @@ -9267,6 +9290,19 @@ packages: resolution: {integrity: sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==} engines: {node: '>=0.10.0'} + npm-bundled@2.0.1: + resolution: {integrity: sha512-gZLxXdjEzE/+mOstGDqR6b0EkhJ+kM6fxM6vUuckuctuVPh80Q6pw/rSZj9s4Gex9GxWtIicO1pc8DB9KZWudw==} + engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} + + npm-normalize-package-bin@2.0.0: + resolution: {integrity: sha512-awzfKUO7v0FscrSpRoogyNm0sajikhBWpU0QMrW09AMi9n1PoKU6WaIqUzuJSQnpciZZmJ/jMZ2Egfmb/9LiWQ==} + engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} + + npm-packlist@5.1.3: + resolution: {integrity: sha512-263/0NGrn32YFYi4J533qzrQ/krmmrWwhKkzwTuM4f/07ug51odoaNjUexxO4vxlzURHcmYMH1QjvHjsNDKLVg==} + engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} + hasBin: true + npm-run-path@5.3.0: resolution: {integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -9290,6 +9326,9 @@ packages: resolution: {integrity: sha512-y1HRYy8s/RlcBvDUwKXSmkODMdx4KSuIvloCnQYJ2LdBBC1asY4HtfhXwe3UWknLakATZDnbzht2Ijw3M1EqFg==} engines: {node: '>=9.4.0 || ^8.9.4'} + once@1.4.0: + resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} + onetime@5.1.2: resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==} engines: {node: '>=6'} @@ -9467,6 +9506,9 @@ packages: picocolors@1.1.0: resolution: {integrity: sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==} + picocolors@1.1.1: + resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + picomatch@2.3.1: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} @@ -9772,6 +9814,11 @@ packages: psl@1.9.0: resolution: {integrity: sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==} + publint@0.2.12: + resolution: {integrity: sha512-YNeUtCVeM4j9nDiTT2OPczmlyzOkIXNtdDZnSuajAxS/nZ6j3t7Vs9SUB4euQNddiltIwu7Tdd3s+hr08fAsMw==} + engines: {node: '>=16'} + hasBin: true + punycode@2.3.1: resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} engines: {node: '>=6'} @@ -10005,6 +10052,10 @@ packages: s.color@0.0.15: resolution: {integrity: sha512-AUNrbEUHeKY8XsYr/DYpl+qk5+aM+DChopnWOPEzn8YKzOhv4l2zH6LzZms3tOZP3wwdOyc0RmTciyi46HLIuA==} + sade@1.8.1: + resolution: {integrity: sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==} + engines: {node: '>=6'} + safe-buffer@5.2.1: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} @@ -10932,6 +10983,9 @@ packages: resolution: {integrity: sha512-G8ura3S+3Z2G+mkgNRq8dqaFZAuxfsxpBB8OCTGRTCtp+l/v9nbFNmCUP1BZMts3G1142MsZfn6eeUKrr4PD1Q==} engines: {node: '>=18'} + wrappy@1.0.2: + resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} + ws@8.18.0: resolution: {integrity: sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==} engines: {node: '>=10.0.0'} @@ -13948,6 +14002,8 @@ snapshots: dependencies: minipass: 3.3.6 + fs.realpath@1.0.0: {} + fsevents@2.3.2: optional: true @@ -13983,6 +14039,14 @@ snapshots: package-json-from-dist: 1.0.0 path-scurry: 1.11.1 + glob@8.1.0: + dependencies: + fs.realpath: 1.0.0 + inflight: 1.0.6 + inherits: 2.0.4 + minimatch: 5.1.6 + once: 1.4.0 + globals@11.12.0: {} globals@14.0.0: {} @@ -14272,6 +14336,10 @@ snapshots: ieee754@1.2.1: {} + ignore-walk@5.0.1: + dependencies: + minimatch: 5.1.6 + ignore@5.3.2: {} immutable@4.3.7: {} @@ -14285,6 +14353,11 @@ snapshots: imurmurhash@0.1.4: {} + inflight@1.0.6: + dependencies: + once: 1.4.0 + wrappy: 1.0.2 + inherits@2.0.4: {} inline-style-parser@0.1.1: {} @@ -15133,6 +15206,10 @@ snapshots: dependencies: brace-expansion: 1.1.11 + minimatch@5.1.6: + dependencies: + brace-expansion: 2.0.1 + minimatch@9.0.5: dependencies: brace-expansion: 2.0.1 @@ -15238,6 +15315,19 @@ snapshots: normalize-range@0.1.2: {} + npm-bundled@2.0.1: + dependencies: + npm-normalize-package-bin: 2.0.0 + + npm-normalize-package-bin@2.0.0: {} + + npm-packlist@5.1.3: + dependencies: + glob: 8.1.0 + ignore-walk: 5.0.1 + npm-bundled: 2.0.1 + npm-normalize-package-bin: 2.0.0 + npm-run-path@5.3.0: dependencies: path-key: 4.0.0 @@ -15256,6 +15346,10 @@ snapshots: on-net-listen@1.1.2: {} + once@1.4.0: + dependencies: + wrappy: 1.0.2 + onetime@5.1.2: dependencies: mimic-fn: 2.1.0 @@ -15436,6 +15530,8 @@ snapshots: picocolors@1.1.0: {} + picocolors@1.1.1: {} + picomatch@2.3.1: {} picomatch@4.0.2: {} @@ -15762,6 +15858,12 @@ snapshots: psl@1.9.0: {} + publint@0.2.12: + dependencies: + npm-packlist: 5.1.3 + picocolors: 1.1.1 + sade: 1.8.1 + punycode@2.3.1: {} querystringify@2.2.0: {} @@ -16113,6 +16215,10 @@ snapshots: s.color@0.0.15: {} + sade@1.8.1: + dependencies: + mri: 1.2.0 + safe-buffer@5.2.1: {} safer-buffer@2.1.2: {} @@ -17125,6 +17231,8 @@ snapshots: string-width: 7.2.0 strip-ansi: 7.1.0 + wrappy@1.0.2: {} + ws@8.18.0: {} xml-name-validator@5.0.0: {} From 25baa4ed0c5f55fa85c2c7e2c15848937ed1dc9b Mon Sep 17 00:00:00 2001 From: oliverlynch <59594611+oliverlynch@users.noreply.github.com> Date: Sat, 16 Nov 2024 01:25:42 +0800 Subject: [PATCH 04/27] Ensure final asset directory exists before writing cached files (#12418) Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com> --- .changeset/thick-shrimps-hammer.md | 5 +++++ packages/astro/src/assets/build/generate.ts | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/thick-shrimps-hammer.md diff --git a/.changeset/thick-shrimps-hammer.md b/.changeset/thick-shrimps-hammer.md new file mode 100644 index 0000000000..b46b9ad6c2 --- /dev/null +++ b/.changeset/thick-shrimps-hammer.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix cached image redownloading if it is the first asset diff --git a/packages/astro/src/assets/build/generate.ts b/packages/astro/src/assets/build/generate.ts index 645a0acdcb..da76cafa38 100644 --- a/packages/astro/src/assets/build/generate.ts +++ b/packages/astro/src/assets/build/generate.ts @@ -153,6 +153,9 @@ export async function generateImagesForPath( const isLocalImage = isESMImportedImage(options.src); const finalFileURL = new URL('.' + filepath, env.clientRoot); + const finalFolderURL = new URL('./', finalFileURL); + await fs.promises.mkdir(finalFolderURL, { recursive: true }); + // For remote images, instead of saving the image directly, we save a JSON file with the image data and expiration date from the server const cacheFile = basename(filepath) + (isLocalImage ? '' : '.json'); const cachedFileURL = new URL(cacheFile, env.assetsCacheDir); @@ -194,9 +197,6 @@ export async function generateImagesForPath( // If the cache file doesn't exist, just move on, and we'll generate it } - const finalFolderURL = new URL('./', finalFileURL); - await fs.promises.mkdir(finalFolderURL, { recursive: true }); - // The original filepath or URL from the image transform const originalImagePath = isLocalImage ? (options.src as ImageMetadata).src From 6a243bf3c449adbd6fa846a8b8bcd0c5c0f9dfa4 Mon Sep 17 00:00:00 2001 From: Marijn Kneppers Date: Mon, 18 Nov 2024 11:48:54 +0100 Subject: [PATCH 05/27] Update links to linting and formatting files in the style guide (#12468) --- STYLE_GUIDE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/STYLE_GUIDE.md b/STYLE_GUIDE.md index 52501fa383..0c7239cfc1 100644 --- a/STYLE_GUIDE.md +++ b/STYLE_GUIDE.md @@ -16,8 +16,8 @@ Anything enforced by linting and formatting is considered a **style rule.** It i These style rules are maintained in configuration files, and therefore not documented in this document. Read any of the following configuration files to learn more about the style rules that we strictly enforced across the codebase: -- [ESLint](https://github.com/withastro/astro/blob/main/.eslintrc.cjs) (Linting) -- [Prettier](https://github.com/withastro/astro/blob/main/.prettierrc.json) (Formatting) +- [ESLint](https://github.com/withastro/astro/blob/main/eslint.config.js) (Linting) +- [Prettier](https://github.com/withastro/astro/blob/main/prettier.config.js) (Formatting) Alternatively, don't worry too much about style rules and trust that our tools will catch these issues for you and offer inline suggestions as you work. From 733d6c1601a8a95409c9707071ecf0b4cda3778a Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Mon, 18 Nov 2024 10:59:19 +0000 Subject: [PATCH 06/27] ci: remove owner check to enable external PR jobs (#12466) --- .github/workflows/continuous_benchmark.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/continuous_benchmark.yml b/.github/workflows/continuous_benchmark.yml index 10abc7bcd2..150c286261 100644 --- a/.github/workflows/continuous_benchmark.yml +++ b/.github/workflows/continuous_benchmark.yml @@ -18,7 +18,6 @@ env: jobs: codspeed: - if: ${{ github.repository_owner == 'withastro' }} runs-on: ubuntu-latest permissions: contents: read From cc03d907c1fe6af4758afac34b318403bd75867a Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Mon, 18 Nov 2024 11:33:58 +0000 Subject: [PATCH 07/27] ci: filter paths of when running the benchmark action (#12470) --- .github/workflows/continuous_benchmark.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/continuous_benchmark.yml b/.github/workflows/continuous_benchmark.yml index 150c286261..00a7e0c5b1 100644 --- a/.github/workflows/continuous_benchmark.yml +++ b/.github/workflows/continuous_benchmark.yml @@ -5,15 +5,20 @@ on: pull_request: branches: - main + paths: + - 'packages/astro/src/**/*.ts' + - 'benchmark/**' push: branches: - main + paths: + - 'packages/astro/src/**/*.ts' + - 'benchmark/**' env: TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} TURBO_TEAM: ${{ secrets.TURBO_TEAM }} FORCE_COLOR: true - CODSPEED_TOKEN: ${{ secrets.CODSPEED_TOKEN }} CODSPEED: true jobs: @@ -46,4 +51,5 @@ jobs: timeout-minutes: 30 with: run: pnpm benchmark codspeed + token: ${{ secrets.CODSPEED_TOKEN }} From 3bde4aa751c8bdf4f23edc86455b22061480583a Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Mon, 18 Nov 2024 13:34:43 +0000 Subject: [PATCH 08/27] chore: use Biome VCS ignore file (#12465) --- .github/scripts/announce.mjs | 64 ++++++++++---------- .github/scripts/bundle-size.mjs | 52 +++++++++++------ .github/scripts/utils.mjs | 78 ++++++++++++------------- biome.jsonc | 20 +++---- scripts/deps/update-example-versions.js | 2 +- 5 files changed, 110 insertions(+), 106 deletions(-) diff --git a/.github/scripts/announce.mjs b/.github/scripts/announce.mjs index 346e0f112b..27a3c71010 100755 --- a/.github/scripts/announce.mjs +++ b/.github/scripts/announce.mjs @@ -18,34 +18,34 @@ const descriptors = [ 'updates', ]; const verbs = [ - "just went out!", - "just launched!", - "now available!", - "in the wild!", - "now live!", - "hit the registry!", - "to share!", - "for you!", - "for y’all! 🤠", - "comin’ your way!", - "comin’ atcha!", - "comin’ in hot!", - "freshly minted on the blockchain! (jk)", - "[is] out (now with 100% more reticulated splines!)", - "(as seen on TV!)", - "just dropped!", - "– artisanally hand-crafted just for you.", - "– oh happy day!", - "– enjoy!", - "now out. Be the first on your block to download!", - "made with love 💕", - "[is] out! Our best [version] yet!", - "[is] here. DOWNLOAD! DOWNLOAD! DOWNLOAD!", - "... HUZZAH!", - "[has] landed!", - "landed! The internet just got a little more fun.", - "– from our family to yours.", - "– go forth and build!" + 'just went out!', + 'just launched!', + 'now available!', + 'in the wild!', + 'now live!', + 'hit the registry!', + 'to share!', + 'for you!', + 'for y’all! 🤠', + 'comin’ your way!', + 'comin’ atcha!', + 'comin’ in hot!', + 'freshly minted on the blockchain! (jk)', + '[is] out (now with 100% more reticulated splines!)', + '(as seen on TV!)', + 'just dropped!', + '– artisanally hand-crafted just for you.', + '– oh happy day!', + '– enjoy!', + 'now out. Be the first on your block to download!', + 'made with love 💕', + '[is] out! Our best [version] yet!', + '[is] here. DOWNLOAD! DOWNLOAD! DOWNLOAD!', + '... HUZZAH!', + '[has] landed!', + 'landed! The internet just got a little more fun.', + '– from our family to yours.', + '– go forth and build!', ]; const extraVerbs = [ 'new', @@ -72,7 +72,7 @@ const plurals = new Map([ function pluralize(text) { return text.replace(/(\[([^\]]+)\])/gm, (_, _full, match) => - plurals.has(match) ? plurals.get(match) : `${match}s` + plurals.has(match) ? plurals.get(match) : `${match}s`, ); } @@ -91,7 +91,7 @@ async function generatePackageMap() { const pkgFile = fileURLToPath(new URL(pkg, packageRoot)); const content = await readFile(pkgFile).then((res) => JSON.parse(res.toString())); packageMap.set(content.name, `./packages/${pkg.replace('/package.json', '')}`); - }) + }), ); } @@ -110,7 +110,7 @@ async function generateMessage() { version, url: new URL(`${p}/CHANGELOG.md#${version.replace(/\./g, '')}`, baseUrl).toString(), }; - }) + }), ); const emoji = item(emojis); @@ -122,7 +122,7 @@ async function generateMessage() { if (packages.length === 1) { const { name, version, url } = packages[0]; message += `${emoji} \`${name}@${version}\` ${singularlize( - verb + verb, )}\nRead the [release notes →](<${url}>)\n`; } else { message += `${emoji} Some ${descriptor} ${pluralize(verb)}\n\n`; diff --git a/.github/scripts/bundle-size.mjs b/.github/scripts/bundle-size.mjs index 690d6e9284..b5ef31b480 100644 --- a/.github/scripts/bundle-size.mjs +++ b/.github/scripts/bundle-size.mjs @@ -4,15 +4,15 @@ import { existsSync } from 'node:fs'; const CLIENT_RUNTIME_PATH = 'packages/astro/src/runtime/client/'; function formatBytes(bytes, decimals = 2) { - if (bytes === 0) return '0 B'; + if (bytes === 0) return '0 B'; - const k = 1024; - const dm = decimals < 0 ? 0 : decimals; - const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; + const k = 1024; + const dm = decimals < 0 ? 0 : decimals; + const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; - const i = Math.floor(Math.log(bytes) / Math.log(k)); + const i = Math.floor(Math.log(bytes) / Math.log(k)); - return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; + return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; } export default async function checkBundleSize({ github, context }) { @@ -24,7 +24,7 @@ export default async function checkBundleSize({ github, context }) { pull_number: PR_NUM, }); const clientRuntimeFiles = files.filter((file) => { - return file.filename.startsWith(CLIENT_RUNTIME_PATH) && file.status !== 'removed' + return file.filename.startsWith(CLIENT_RUNTIME_PATH) && file.status !== 'removed'; }); if (clientRuntimeFiles.length === 0) return; @@ -35,17 +35,24 @@ export default async function checkBundleSize({ github, context }) { const output = await bundle(clientRuntimeFiles); for (let [filename, { oldSize, newSize, sourceFile }] of Object.entries(output)) { - filename = ['idle', 'load', 'media', 'only', 'visible'].includes(filename) ? `client:${filename}` : filename; - const prefix = (newSize - oldSize) === 0 ? '' : (newSize - oldSize) > 0 ? '+ ' : '- '; + filename = ['idle', 'load', 'media', 'only', 'visible'].includes(filename) + ? `client:${filename}` + : filename; + const prefix = newSize - oldSize === 0 ? '' : newSize - oldSize > 0 ? '+ ' : '- '; const change = `${prefix}${formatBytes(newSize - oldSize)}`; - table.push(`| [\`${filename}\`](https://github.com/${context.repo.owner}/${context.repo.repo}/tree/${context.payload.pull_request.head.ref}/${sourceFile}) | ${formatBytes(oldSize)} | ${formatBytes(newSize)} | ${change} |`); + table.push( + `| [\`${filename}\`](https://github.com/${context.repo.owner}/${context.repo.repo}/tree/${context.payload.pull_request.head.ref}/${sourceFile}) | ${formatBytes(oldSize)} | ${formatBytes(newSize)} | ${change} |`, + ); } const { data: comments } = await github.rest.issues.listComments({ ...context.repo, - issue_number: PR_NUM - }) - const comment = comments.find(comment => comment.user.login === 'github-actions[bot]' && comment.body.includes('Bundle Size Check')); + issue_number: PR_NUM, + }); + const comment = comments.find( + (comment) => + comment.user.login === 'github-actions[bot]' && comment.body.includes('Bundle Size Check'), + ); const method = comment ? 'updateComment' : 'createComment'; const payload = comment ? { comment_id: comment.id } : { issue_number: PR_NUM }; await github.rest.issues[method]({ @@ -60,9 +67,11 @@ ${table.join('\n')}`, } async function bundle(files) { - const { metafile } = await build({ - entryPoints: [...files.map(({ filename }) => filename), ...files.map(({ filename }) => `main/${filename}`).filter(f => existsSync(f))], + entryPoints: [ + ...files.map(({ filename }) => filename), + ...files.map(({ filename }) => `main/${filename}`).filter((f) => existsSync(f)), + ], bundle: true, minify: true, sourcemap: false, @@ -70,17 +79,24 @@ async function bundle(files) { outdir: 'out', external: ['astro:*', 'aria-query', 'axobject-query'], metafile: true, - }) + }); return Object.entries(metafile.outputs).reduce((acc, [filename, info]) => { filename = filename.slice('out/'.length); if (filename.startsWith('main/')) { filename = filename.slice('main/'.length).replace(CLIENT_RUNTIME_PATH, '').replace('.js', ''); const oldSize = info.bytes; - return Object.assign(acc, { [filename]: Object.assign(acc[filename] ?? { oldSize: 0, newSize: 0 }, { oldSize }) }); + return Object.assign(acc, { + [filename]: Object.assign(acc[filename] ?? { oldSize: 0, newSize: 0 }, { oldSize }), + }); } filename = filename.replace(CLIENT_RUNTIME_PATH, '').replace('.js', ''); const newSize = info.bytes; - return Object.assign(acc, { [filename]: Object.assign(acc[filename] ?? { oldSize: 0, newSize: 0 }, { newSize, sourceFile: Object.keys(info.inputs).find(src => src.endsWith('.ts')) }) }); + return Object.assign(acc, { + [filename]: Object.assign(acc[filename] ?? { oldSize: 0, newSize: 0 }, { + newSize, + sourceFile: Object.keys(info.inputs).find((src) => src.endsWith('.ts')), + }), + }); }, {}); } diff --git a/.github/scripts/utils.mjs b/.github/scripts/utils.mjs index da5befc2c2..9aaa383d81 100644 --- a/.github/scripts/utils.mjs +++ b/.github/scripts/utils.mjs @@ -1,59 +1,53 @@ -import * as fs from 'node:fs' -import * as os from 'node:os' -import * as crypto from 'node:crypto' +import * as fs from 'node:fs'; +import * as os from 'node:os'; +import * as crypto from 'node:crypto'; /** Based on https://github.com/actions/toolkit/blob/4e3b068ce116d28cb840033c02f912100b4592b0/packages/core/src/file-command.ts */ export function setOutput(key, value) { - const filePath = process.env['GITHUB_OUTPUT'] || '' - if (filePath) { - return issueFileCommand('OUTPUT', prepareKeyValueMessage(key, value)) - } - process.stdout.write(os.EOL) + const filePath = process.env['GITHUB_OUTPUT'] || ''; + if (filePath) { + return issueFileCommand('OUTPUT', prepareKeyValueMessage(key, value)); + } + process.stdout.write(os.EOL); } function issueFileCommand(command, message) { - const filePath = process.env[`GITHUB_${command}`] - if (!filePath) { - throw new Error( - `Unable to find environment variable for file command ${command}` - ) - } - if (!fs.existsSync(filePath)) { - throw new Error(`Missing file at path: ${filePath}`) - } + const filePath = process.env[`GITHUB_${command}`]; + if (!filePath) { + throw new Error(`Unable to find environment variable for file command ${command}`); + } + if (!fs.existsSync(filePath)) { + throw new Error(`Missing file at path: ${filePath}`); + } - fs.appendFileSync(filePath, `${toCommandValue(message)}${os.EOL}`, { - encoding: 'utf8' - }) + fs.appendFileSync(filePath, `${toCommandValue(message)}${os.EOL}`, { + encoding: 'utf8', + }); } function prepareKeyValueMessage(key, value) { - const delimiter = `gh-delimiter-${crypto.randomUUID()}` - const convertedValue = toCommandValue(value) + const delimiter = `gh-delimiter-${crypto.randomUUID()}`; + const convertedValue = toCommandValue(value); - // These should realistically never happen, but just in case someone finds a - // way to exploit uuid generation let's not allow keys or values that contain - // the delimiter. - if (key.includes(delimiter)) { - throw new Error( - `Unexpected input: name should not contain the delimiter "${delimiter}"` - ) - } + // These should realistically never happen, but just in case someone finds a + // way to exploit uuid generation let's not allow keys or values that contain + // the delimiter. + if (key.includes(delimiter)) { + throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); + } - if (convertedValue.includes(delimiter)) { - throw new Error( - `Unexpected input: value should not contain the delimiter "${delimiter}"` - ) - } + if (convertedValue.includes(delimiter)) { + throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); + } - return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}` + return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; } function toCommandValue(input) { - if (input === null || input === undefined) { - return '' - } else if (typeof input === 'string' || input instanceof String) { - return input - } - return JSON.stringify(input) + if (input === null || input === undefined) { + return ''; + } else if (typeof input === 'string' || input instanceof String) { + return input; + } + return JSON.stringify(input); } diff --git a/biome.jsonc b/biome.jsonc index edd0ea8717..adadd8f597 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -1,19 +1,13 @@ { "$schema": "https://biomejs.dev/schemas/1.9.3/schema.json", "files": { - "ignore": [ - "vendor", - "**/dist/**", - "**/smoke/**", - "**/fixtures/**", - "**/_temp-fixtures/**", - "**/vendor/**", - "**/.vercel/**", - "benchmark/projects/", - "benchmark/results/", - "benchmark/bench/_template.js", - ], - "include": ["test/**", "e2e/**", "packages/**", "/scripts/**", "benchmark/bench"], + "ignore": ["**/smoke/**", "**/fixtures/**", "**/_temp-fixtures/**", "**/vendor/**"], + "include": ["test/**", "e2e/**", "packages/**", "scripts/**", "benchmark/bench"], + }, + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": true, }, "formatter": { "indentStyle": "tab", diff --git a/scripts/deps/update-example-versions.js b/scripts/deps/update-example-versions.js index 077c12b978..93b8b71406 100644 --- a/scripts/deps/update-example-versions.js +++ b/scripts/deps/update-example-versions.js @@ -26,7 +26,7 @@ for (const workspaceDir of workspaceDirs) { const packageJson = await readAndParsePackageJson(packageJsonPath); if (!packageJson) continue; - if (packageJson.private === true) continue + if (packageJson.private === true) continue; if (!packageJson.name) { throw new Error(`${packageJsonPath} does not contain a "name" field.`); From f64934086e84966bcfd02b699d64a80cb8392fa2 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Mon, 18 Nov 2024 13:35:34 +0000 Subject: [PATCH 09/27] [ci] format --- .github/scripts/announce.mjs | 4 ++-- .github/scripts/bundle-size.mjs | 2 +- .github/scripts/utils.mjs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/scripts/announce.mjs b/.github/scripts/announce.mjs index 27a3c71010..2e05a7ae8a 100755 --- a/.github/scripts/announce.mjs +++ b/.github/scripts/announce.mjs @@ -1,6 +1,6 @@ -import { globby as glob } from 'globby'; -import { fileURLToPath } from 'node:url'; import { readFile } from 'node:fs/promises'; +import { fileURLToPath } from 'node:url'; +import { globby as glob } from 'globby'; import { setOutput } from './utils.mjs'; const { GITHUB_REF = 'main' } = process.env; diff --git a/.github/scripts/bundle-size.mjs b/.github/scripts/bundle-size.mjs index b5ef31b480..76d6b3f297 100644 --- a/.github/scripts/bundle-size.mjs +++ b/.github/scripts/bundle-size.mjs @@ -1,5 +1,5 @@ -import { build } from 'esbuild'; import { existsSync } from 'node:fs'; +import { build } from 'esbuild'; const CLIENT_RUNTIME_PATH = 'packages/astro/src/runtime/client/'; diff --git a/.github/scripts/utils.mjs b/.github/scripts/utils.mjs index 9aaa383d81..7683022301 100644 --- a/.github/scripts/utils.mjs +++ b/.github/scripts/utils.mjs @@ -1,6 +1,6 @@ +import * as crypto from 'node:crypto'; import * as fs from 'node:fs'; import * as os from 'node:os'; -import * as crypto from 'node:crypto'; /** Based on https://github.com/actions/toolkit/blob/4e3b068ce116d28cb840033c02f912100b4592b0/packages/core/src/file-command.ts */ export function setOutput(key, value) { From 80a9a5299a9d51f2b09900d3200976d687feae8f Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Tue, 19 Nov 2024 16:56:28 +0100 Subject: [PATCH 10/27] fix: content layer glob deletion (#12476) --- .changeset/six-pianos-draw.md | 5 +++++ packages/astro/src/content/loaders/glob.ts | 4 ++-- packages/astro/test/content-layer.test.js | 21 +++++++++++++++++++ .../src/pages/collections.json.js | 6 +++++- 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 .changeset/six-pianos-draw.md diff --git a/.changeset/six-pianos-draw.md b/.changeset/six-pianos-draw.md new file mode 100644 index 0000000000..61a6d07eb3 --- /dev/null +++ b/.changeset/six-pianos-draw.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes a case where the Content Layer `glob()` loader would not update when renaming or deleting an entry diff --git a/packages/astro/src/content/loaders/glob.ts b/packages/astro/src/content/loaders/glob.ts index e0b1d79c1b..4a515a92bf 100644 --- a/packages/astro/src/content/loaders/glob.ts +++ b/packages/astro/src/content/loaders/glob.ts @@ -101,6 +101,7 @@ export function glob(globOptions: GlobOptions): Loader { const existingEntry = store.get(id); const digest = generateDigest(contents); + const filePath = fileURLToPath(fileUrl); if (existingEntry && existingEntry.digest === digest && existingEntry.filePath) { if (existingEntry.deferredRender) { @@ -112,11 +113,10 @@ export function glob(globOptions: GlobOptions): Loader { store.addAssetImports(existingEntry.assetImports, existingEntry.filePath); } + fileToIdMap.set(filePath, id); return; } - const filePath = fileURLToPath(fileUrl); - const relativePath = posixRelative(fileURLToPath(config.root), filePath); const parsedData = await parseData({ diff --git a/packages/astro/test/content-layer.test.js b/packages/astro/test/content-layer.test.js index d8bd7bd2d0..1f2ceb7d86 100644 --- a/packages/astro/test/content-layer.test.js +++ b/packages/astro/test/content-layer.test.js @@ -323,5 +323,26 @@ describe('Content Layer', () => { assert.equal(res.status, 500); assert.ok(text.includes('RenderUndefinedEntryError')); }); + + it('update the store when a file is renamed', async () => { + const rawJsonResponse = await fixture.fetch('/collections.json'); + const initialJson = devalue.parse(await rawJsonResponse.text()); + assert.equal(initialJson.numbers.map((e) => e.id).includes('src/data/glob-data/three'), true); + + const oldPath = new URL('./data/glob-data/three.json', fixture.config.srcDir); + const newPath = new URL('./data/glob-data/four.json', fixture.config.srcDir); + + await fs.rename(oldPath, newPath); + await fixture.onNextDataStoreChange(); + + try { + const updatedJsonResponse = await fixture.fetch('/collections.json'); + const updated = devalue.parse(await updatedJsonResponse.text()); + assert.equal(updated.numbers.map((e) => e.id).includes('src/data/glob-data/three'), false); + assert.equal(updated.numbers.map((e) => e.id).includes('src/data/glob-data/four'), true); + } finally { + await fs.rename(newPath, oldPath); + } + }); }); }); diff --git a/packages/astro/test/fixtures/content-layer/src/pages/collections.json.js b/packages/astro/test/fixtures/content-layer/src/pages/collections.json.js index 5bce6ed54e..d218613fa7 100644 --- a/packages/astro/test/fixtures/content-layer/src/pages/collections.json.js +++ b/packages/astro/test/fixtures/content-layer/src/pages/collections.json.js @@ -19,6 +19,9 @@ export async function GET() { const increment = await getEntry('increment', 'value'); const images = await getCollection('images'); + + const numbers = await getCollection('numbers'); + return new Response( devalue.stringify({ customLoader, @@ -29,7 +32,8 @@ export async function GET() { entryWithImagePath, referencedEntry, increment, - images + images, + numbers, }) ); } From 46f6b386b3db6332f286d79958ef10261958cceb Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Tue, 19 Nov 2024 16:12:40 +0000 Subject: [PATCH 11/27] fix(build): generated entry (#12477) --- .changeset/thin-cups-peel.md | 5 +++++ packages/astro/src/core/build/plugins/plugin-ssr.ts | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .changeset/thin-cups-peel.md diff --git a/.changeset/thin-cups-peel.md b/.changeset/thin-cups-peel.md new file mode 100644 index 0000000000..3fc4678cb5 --- /dev/null +++ b/.changeset/thin-cups-peel.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes an issue where the SSR build was emitting the `dist/server/entry.mjs` file with an incorrect import at the top of the file/ diff --git a/packages/astro/src/core/build/plugins/plugin-ssr.ts b/packages/astro/src/core/build/plugins/plugin-ssr.ts index 883cdee388..eb59eff650 100644 --- a/packages/astro/src/core/build/plugins/plugin-ssr.ts +++ b/packages/astro/src/core/build/plugins/plugin-ssr.ts @@ -283,7 +283,6 @@ function generateSSRCode(settings: AstroSettings, adapter: AstroAdapter, middlew `import { renderers } from '${RENDERERS_MODULE_ID}';`, `import * as serverEntrypointModule from '${ADAPTER_VIRTUAL_MODULE_ID}';`, `import { manifest as defaultManifest } from '${SSR_MANIFEST_VIRTUAL_MODULE_ID}';`, - edgeMiddleware ? `` : `import { onRequest as middleware } from '${middlewareId}';`, settings.config.experimental.serverIslands ? `import { serverIslandMap } from '${VIRTUAL_ISLAND_MAP_ID}';` : '', From c3b7e7cfa13603c08eb923703f31a92d514e82db Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Wed, 20 Nov 2024 06:09:43 -0500 Subject: [PATCH 12/27] Remove default throw behavior in astro:env (#12480) Co-authored-by: Emanuele Stoppa --- .changeset/early-scissors-beg.md | 5 +++++ packages/astro/src/core/app/pipeline.ts | 1 - packages/astro/src/core/base-pipeline.ts | 8 -------- packages/astro/src/core/errors/errors-data.ts | 11 ----------- 4 files changed, 5 insertions(+), 20 deletions(-) create mode 100644 .changeset/early-scissors-beg.md diff --git a/.changeset/early-scissors-beg.md b/.changeset/early-scissors-beg.md new file mode 100644 index 0000000000..0b3d85e430 --- /dev/null +++ b/.changeset/early-scissors-beg.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Removes the default throw behavior in `astro:env` diff --git a/packages/astro/src/core/app/pipeline.ts b/packages/astro/src/core/app/pipeline.ts index 4f753419a0..f3813e12ac 100644 --- a/packages/astro/src/core/app/pipeline.ts +++ b/packages/astro/src/core/app/pipeline.ts @@ -54,7 +54,6 @@ export class AppPipeline extends Pipeline { undefined, undefined, undefined, - false, defaultRoutes, ); pipeline.#manifestData = manifestData; diff --git a/packages/astro/src/core/base-pipeline.ts b/packages/astro/src/core/base-pipeline.ts index 4eeb2f0525..0dcd9ac529 100644 --- a/packages/astro/src/core/base-pipeline.ts +++ b/packages/astro/src/core/base-pipeline.ts @@ -57,7 +57,6 @@ export abstract class Pipeline { * Used for `Astro.site`. */ readonly site = manifest.site ? new URL(manifest.site) : undefined, - readonly callSetGetEnv = true, /** * Array of built-in, internal, routes. * Used to find the route module @@ -71,13 +70,6 @@ export abstract class Pipeline { createI18nMiddleware(i18n, manifest.base, manifest.trailingSlash, manifest.buildFormat), ); } - // In SSR, getSecret should fail by default. Setting it here will run before the - // adapter override. - if (callSetGetEnv && manifest.experimentalEnvGetSecretEnabled) { - setGetEnv(() => { - throw new AstroError(AstroErrorData.EnvUnsupportedGetSecret); - }, true); - } } abstract headElements(routeData: RouteData): Promise | HeadElements; diff --git a/packages/astro/src/core/errors/errors-data.ts b/packages/astro/src/core/errors/errors-data.ts index e8492584a9..085f52dfbf 100644 --- a/packages/astro/src/core/errors/errors-data.ts +++ b/packages/astro/src/core/errors/errors-data.ts @@ -1174,17 +1174,6 @@ export const EnvInvalidVariables = { `The following environment variables defined in \`experimental.env.schema\` are invalid:\n\n${errors.map((err) => `- ${err}`).join('\n')}\n`, } satisfies ErrorData; -/** - * @docs - * @description - * The `astro:env/server` exported function `getSecret()` is not supported by your adapter. - */ -export const EnvUnsupportedGetSecret = { - name: 'EnvUnsupportedGetSecret', - title: 'Unsupported astro:env getSecret', - message: '`astro:env/server` exported function `getSecret` is not supported by your adapter.', -} satisfies ErrorData; - /** * @docs * @description From ab0580bc94334d7924b5bb0ac808669d9d8930c3 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Wed, 20 Nov 2024 11:21:40 +0000 Subject: [PATCH 13/27] refactor(build): don't emit `middleware.mjs` (#12479) --- packages/astro/src/core/build/generate.ts | 12 ++++-------- packages/astro/src/core/build/pipeline.ts | 16 +++++++--------- .../astro/src/core/middleware/vite-plugin.ts | 15 +-------------- 3 files changed, 12 insertions(+), 31 deletions(-) diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index 5ba5df366d..b854b6ae35 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -33,6 +33,7 @@ import { getOutputDirectory } from '../../prerender/utils.js'; import type { SSRManifestI18n } from '../app/types.js'; import { NoPrerenderedRoutesWithDomains } from '../errors/errors-data.js'; import { AstroError, AstroErrorData } from '../errors/index.js'; +import { NOOP_MIDDLEWARE_FN } from '../middleware/noop-middleware.js'; import { getRedirectLocationOrThrow, routeIsRedirect } from '../redirects/index.js'; import { RenderContext } from '../render-context.js'; import { callGetStaticPaths } from '../render/route-cache.js'; @@ -65,14 +66,9 @@ export async function generatePages(options: StaticBuildOptions, internals: Buil const baseDirectory = getOutputDirectory(options.settings.config); const renderersEntryUrl = new URL('renderers.mjs', baseDirectory); const renderers = await import(renderersEntryUrl.toString()); - let middleware: MiddlewareHandler = (_, next) => next(); - try { - // middleware.mjs is not emitted if there is no user middleware - // in which case the import fails with ERR_MODULE_NOT_FOUND, and we fall back to a no-op middleware - middleware = await import(new URL('middleware.mjs', baseDirectory).toString()).then( - (mod) => mod.onRequest, - ); - } catch {} + const middleware: MiddlewareHandler = internals.middlewareEntryPoint + ? await import(internals.middlewareEntryPoint.toString()).then((mod) => mod.onRequest) + : NOOP_MIDDLEWARE_FN; manifest = createBuildManifest( options.settings, internals, diff --git a/packages/astro/src/core/build/pipeline.ts b/packages/astro/src/core/build/pipeline.ts index 38fd4dfe16..ed32e7e420 100644 --- a/packages/astro/src/core/build/pipeline.ts +++ b/packages/astro/src/core/build/pipeline.ts @@ -137,15 +137,13 @@ export class BuildPipeline extends Pipeline { const renderersEntryUrl = new URL(`renderers.mjs?time=${Date.now()}`, baseDirectory); const renderers = await import(renderersEntryUrl.toString()); - const middleware = await import(new URL('middleware.mjs', baseDirectory).toString()) - .then((mod) => { - return function () { - return { onRequest: mod.onRequest }; - }; - }) - // middleware.mjs is not emitted if there is no user middleware - // in which case the import fails with ERR_MODULE_NOT_FOUND, and we fall back to a no-op middleware - .catch(() => manifest.middleware); + const middleware = internals.middlewareEntryPoint + ? await import(internals.middlewareEntryPoint.toString()).then((mod) => { + return function () { + return { onRequest: mod.onRequest }; + }; + }) + : manifest.middleware; if (!renderers) { throw new Error( diff --git a/packages/astro/src/core/middleware/vite-plugin.ts b/packages/astro/src/core/middleware/vite-plugin.ts index 7ac8bf2ed1..2579bd93a5 100644 --- a/packages/astro/src/core/middleware/vite-plugin.ts +++ b/packages/astro/src/core/middleware/vite-plugin.ts @@ -13,7 +13,6 @@ export const MIDDLEWARE_MODULE_ID = '\0astro-internal:middleware'; const NOOP_MIDDLEWARE = '\0noop-middleware'; export function vitePluginMiddleware({ settings }: { settings: AstroSettings }): VitePlugin { - let isCommandBuild = false; let resolvedMiddlewareId: string | undefined = undefined; const hasIntegrationMiddleware = settings.middlewares.pre.length > 0 || settings.middlewares.post.length > 0; @@ -21,9 +20,6 @@ export function vitePluginMiddleware({ settings }: { settings: AstroSettings }): return { name: '@astro/plugin-middleware', - config(_, { command }) { - isCommandBuild = command === 'build'; - }, async resolveId(id) { if (id === MIDDLEWARE_MODULE_ID) { const middlewareId = await this.resolve( @@ -53,15 +49,6 @@ export function vitePluginMiddleware({ settings }: { settings: AstroSettings }): if (!userMiddlewareIsPresent && settings.config.i18n?.routing === 'manual') { throw new AstroError(MissingMiddlewareForInternationalization); } - // In the build, tell Vite to emit this file - if (isCommandBuild) { - this.emitFile({ - type: 'chunk', - preserveSignature: 'strict', - fileName: 'middleware.mjs', - id, - }); - } const preMiddleware = createMiddlewareImports(settings.middlewares.pre, 'pre'); const postMiddleware = createMiddlewareImports(settings.middlewares.post, 'post'); @@ -124,7 +111,7 @@ export function vitePluginMiddlewareBuild( writeBundle(_, bundle) { for (const [chunkName, chunk] of Object.entries(bundle)) { - if (chunk.type !== 'asset' && chunk.fileName === 'middleware.mjs') { + if (chunk.type !== 'asset' && chunk.facadeModuleId === MIDDLEWARE_MODULE_ID) { const outputDirectory = getOutputDirectory(opts.settings.config); internals.middlewareEntryPoint = new URL(chunkName, outputDirectory); } From e1a5e65ad7ed6c334aecf86503be47860f73a720 Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Wed, 20 Nov 2024 13:12:17 +0000 Subject: [PATCH 14/27] chore: clarify wording of responsive image props (#12482) --- packages/astro/src/assets/internal.ts | 1 + packages/astro/src/types/public/config.ts | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/astro/src/assets/internal.ts b/packages/astro/src/assets/internal.ts index 3363a5648d..d9c2db5a05 100644 --- a/packages/astro/src/assets/internal.ts +++ b/packages/astro/src/assets/internal.ts @@ -150,6 +150,7 @@ export async function getImage( resolvedOptions.fetchpriority ??= 'auto'; } delete resolvedOptions.priority; + delete resolvedOptions.densities; } const validatedOptions = service.validateOptions diff --git a/packages/astro/src/types/public/config.ts b/packages/astro/src/types/public/config.ts index 6af76676aa..354d304937 100644 --- a/packages/astro/src/types/public/config.ts +++ b/packages/astro/src/types/public/config.ts @@ -1899,11 +1899,10 @@ export interface ViteUserConfig extends OriginalViteUserConfig { * - `position`: Defines the position of the image crop if the aspect ratio is changed. Values match those of CSS `object-position`. Defaults to `center`, or the value of `image.experimentalObjectPosition` if set. * - `priority`: If set, eagerly loads the image. Otherwise images will be lazy-loaded. Use this for your largest above-the-fold image. Defaults to `false`. * - * The following `` component properties should not be used with responsive images as these are automatically generated: - * - * - `densities` - * - `widths` - * - `sizes` + * The `widths` and `sizes` attributes are automatically generated based on the image's dimensions and the layout type, and in most cases should not be set manually. The generated `sizes` attribute for `responsive` and `full-width` images + * is based on the assumption that the image is displayed at close to the full width of the screen when the viewport is smaller than the image's width. If it is significantly different (e.g. if it's in a multi-column layout on small screens) you may need to adjust the `sizes` attribute manually for best results. + * + * The `densities` attribute is not compatible with responsive images and will be ignored if set. */ responsiveImages?: boolean; From 3f8b0725dabbc219aa4126c7f108c5cbdfc30714 Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Wed, 20 Nov 2024 13:12:39 +0000 Subject: [PATCH 15/27] chore: better images changeset (#12483) --- .changeset/proud-terms-swim.md | 112 ++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 2 deletions(-) diff --git a/.changeset/proud-terms-swim.md b/.changeset/proud-terms-swim.md index e33b3d1aff..f5851dab44 100644 --- a/.changeset/proud-terms-swim.md +++ b/.changeset/proud-terms-swim.md @@ -1,5 +1,113 @@ --- -'astro': patch +'astro': minor --- -Adds experimental reponsive image support +Adds experimental support for automatic responsive images + +This feature is experimental and may change in future versions. To enable it, set `experimental.responsiveImages` to `true` in your `astro.config.mjs` file. + + ```js title=astro.config.mjs + { + experimental: { + responsiveImages: true, + }, + } + ``` + + When this flag is enabled, you can pass a `layout` props to any `` or `` component to create a responsive image. When a layout is set, images have automatically generated `srcset` and `sizes` attributes based on the image's dimensions and the layout type. Images with `responsive` and `full-width` layouts will have styles applied to ensure they resize according to their container. + + ```astro + // MyComponent.astro + --- + import { Image, Picture } from 'astro:assets'; + import myImage from '../assets/my_image.png'; + --- + A description of my image. + + ``` + This `` component will generate the following HTML output: + ```html title=Output + + A description of my image + ``` + + The following styles are applied to ensure the images resize correctly: + + ```css + [data-astro-image] { + width: 100%; + height: auto; + object-fit: var(--fit); + object-position: var(--pos); + aspect-ratio: var(--w) / var(--h) + } + + [data-astro-image=responsive] { + max-width: calc(var(--w) * 1px); + max-height: calc(var(--h) * 1px) + } + + [data-astro-image=fixed] { + width: calc(var(--w) * 1px); + height: calc(var(--h) * 1px) + } + ``` + You can enable responsive images for all `` and `` components by setting `image.experimentalLayout` with a default value. This can be overridden by the `layout` prop on each component. + + **Example:** + ```js title=astro.config.mjs + { + image: { + // Used for all `` and `` components unless overridden + experimentalLayout: 'responsive', + }, + experimental: { + responsiveImages: true, + }, + } + ``` + + ```astro title=MyComponent.astro + --- + import { Image } from 'astro:assets'; + import myImage from '../assets/my_image.png'; + --- + + This will use responsive layout + + This will use full-width layout + + This will disable responsive images + ``` + + #### Responsive image properties + + These are additional properties available to the `` and `` components when responsive images are enabled: + + - `layout`: The layout type for the image. Can be `responsive`, `fixed`, `full-width` or `none`. Defaults to value of `image.experimentalLayout`. + - `fit`: Defines how the image should be cropped if the aspect ratio is changed. Values match those of CSS `object-fit`. Defaults to `cover`, or the value of `image.experimentalObjectFit` if set. + - `position`: Defines the position of the image crop if the aspect ratio is changed. Values match those of CSS `object-position`. Defaults to `center`, or the value of `image.experimentalObjectPosition` if set. + - `priority`: If set, eagerly loads the image. Otherwise images will be lazy-loaded. Use this for your largest above-the-fold image. Defaults to `false`. + +The `widths` and `sizes` attributes are automatically generated based on the image's dimensions and the layout type, and in most cases should not be set manually. The generated `sizes` attribute for `responsive` and `full-width` images +is based on the assumption that the image is displayed at close to the full width of the screen when the viewport is smaller than the image's width. If it is significantly different (e.g. if it's in a multi-column layout on small screens) you may need to adjust the `sizes` attribute manually for best results. + +The `densities` attribute is not compatible with responsive images and will be ignored if set. From 18a04c008aa13dd9b42a20161663f13dcec56e0d Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Wed, 20 Nov 2024 13:51:45 +0000 Subject: [PATCH 16/27] chore: better images changeset pt 2 (#12484) --- .changeset/proud-terms-swim.md | 101 +++++++++++++-------------------- 1 file changed, 39 insertions(+), 62 deletions(-) diff --git a/.changeset/proud-terms-swim.md b/.changeset/proud-terms-swim.md index f5851dab44..08824a8aba 100644 --- a/.changeset/proud-terms-swim.md +++ b/.changeset/proud-terms-swim.md @@ -8,16 +8,15 @@ This feature is experimental and may change in future versions. To enable it, se ```js title=astro.config.mjs { - experimental: { - responsiveImages: true, - }, + experimental: { + responsiveImages: true, + }, } ``` - When this flag is enabled, you can pass a `layout` props to any `` or `` component to create a responsive image. When a layout is set, images have automatically generated `srcset` and `sizes` attributes based on the image's dimensions and the layout type. Images with `responsive` and `full-width` layouts will have styles applied to ensure they resize according to their container. + When this flag is enabled, you can pass a `layout` prop to any `` or `` component to create a responsive image. When a layout is set, images have automatically generated `srcset` and `sizes` attributes based on the image's dimensions and the layout type. Images with `responsive` and `full-width` layouts will have styles applied to ensure they resize according to their container. ```astro - // MyComponent.astro --- import { Image, Picture } from 'astro:assets'; import myImage from '../assets/my_image.png'; @@ -28,64 +27,54 @@ This feature is experimental and may change in future versions. To enable it, se This `` component will generate the following HTML output: ```html title=Output - A description of my image ``` - The following styles are applied to ensure the images resize correctly: + #### Responsive image properties - ```css - [data-astro-image] { - width: 100%; - height: auto; - object-fit: var(--fit); - object-position: var(--pos); - aspect-ratio: var(--w) / var(--h) - } + These are additional properties available to the `` and `` components when responsive images are enabled: - [data-astro-image=responsive] { - max-width: calc(var(--w) * 1px); - max-height: calc(var(--h) * 1px) - } + - `layout`: The layout type for the image. Can be `responsive`, `fixed`, `full-width` or `none`. Defaults to value of `image.experimentalLayout`. + - `fit`: Defines how the image should be cropped if the aspect ratio is changed. Values match those of CSS `object-fit`. Defaults to `cover`, or the value of `image.experimentalObjectFit` if set. + - `position`: Defines the position of the image crop if the aspect ratio is changed. Values match those of CSS `object-position`. Defaults to `center`, or the value of `image.experimentalObjectPosition` if set. + - `priority`: If set, eagerly loads the image. Otherwise images will be lazy-loaded. Use this for your largest above-the-fold image. Defaults to `false`. + +#### Default responsive image settings - [data-astro-image=fixed] { - width: calc(var(--w) * 1px); - height: calc(var(--h) * 1px) - } - ``` You can enable responsive images for all `` and `` components by setting `image.experimentalLayout` with a default value. This can be overridden by the `layout` prop on each component. **Example:** ```js title=astro.config.mjs { - image: { - // Used for all `` and `` components unless overridden - experimentalLayout: 'responsive', - }, - experimental: { - responsiveImages: true, - }, + image: { + // Used for all `` and `` components unless overridden + experimentalLayout: 'responsive', + }, + experimental: { + responsiveImages: true, + }, } ``` - ```astro title=MyComponent.astro + ```astro --- import { Image } from 'astro:assets'; import myImage from '../assets/my_image.png'; @@ -98,16 +87,4 @@ This feature is experimental and may change in future versions. To enable it, se This will disable responsive images ``` - #### Responsive image properties - - These are additional properties available to the `` and `` components when responsive images are enabled: - - - `layout`: The layout type for the image. Can be `responsive`, `fixed`, `full-width` or `none`. Defaults to value of `image.experimentalLayout`. - - `fit`: Defines how the image should be cropped if the aspect ratio is changed. Values match those of CSS `object-fit`. Defaults to `cover`, or the value of `image.experimentalObjectFit` if set. - - `position`: Defines the position of the image crop if the aspect ratio is changed. Values match those of CSS `object-position`. Defaults to `center`, or the value of `image.experimentalObjectPosition` if set. - - `priority`: If set, eagerly loads the image. Otherwise images will be lazy-loaded. Use this for your largest above-the-fold image. Defaults to `false`. - -The `widths` and `sizes` attributes are automatically generated based on the image's dimensions and the layout type, and in most cases should not be set manually. The generated `sizes` attribute for `responsive` and `full-width` images -is based on the assumption that the image is displayed at close to the full width of the screen when the viewport is smaller than the image's width. If it is significantly different (e.g. if it's in a multi-column layout on small screens) you may need to adjust the `sizes` attribute manually for best results. - -The `densities` attribute is not compatible with responsive images and will be ignored if set. +For a complete overview, and to give feedback on this experimental API, see the [Responsive Images RFC](https://github.com/withastro/roadmap/blob/responsive-images/proposals/0053-responsive-images.md). From 28dd3ce5222a667fe113238254edf59318b3fa14 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Wed, 20 Nov 2024 15:08:26 +0000 Subject: [PATCH 17/27] fix: server island hydration (#12444) --- .changeset/olive-garlics-marry.md | 5 +++++ packages/astro/src/runtime/server/render/server-islands.ts | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/olive-garlics-marry.md diff --git a/.changeset/olive-garlics-marry.md b/.changeset/olive-garlics-marry.md new file mode 100644 index 0000000000..342db3a6f6 --- /dev/null +++ b/.changeset/olive-garlics-marry.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes an issue where a server island hydration script might fail case the island ID misses from the DOM. diff --git a/packages/astro/src/runtime/server/render/server-islands.ts b/packages/astro/src/runtime/server/render/server-islands.ts index 6dd06b8d7b..b8ac34024a 100644 --- a/packages/astro/src/runtime/server/render/server-islands.ts +++ b/packages/astro/src/runtime/server/render/server-islands.ts @@ -81,8 +81,8 @@ let response = await fetch('${serverIslandUrl}', { method: 'POST', body: JSON.stringify(data), }); - -if(response.status === 200 && response.headers.get('content-type') === 'text/html') { +if (script) { + if(response.status === 200 && response.headers.get('content-type') === 'text/html') { let html = await response.text(); // Swap! @@ -97,6 +97,7 @@ if(response.status === 200 && response.headers.get('content-type') === 'text/htm script.before(frag); } script.remove(); +} `); }, }; From a23985b02165c2ddce56d511b3f97b6815c452c9 Mon Sep 17 00:00:00 2001 From: Arpan Patel Date: Thu, 21 Nov 2024 03:31:17 -0600 Subject: [PATCH 18/27] fix: return correct locale in root 404 and 500 page with i18n (#12365) Co-authored-by: Emanuele Stoppa --- .changeset/warm-poems-breathe.md | 5 ++++ packages/astro/src/core/render-context.ts | 9 +++---- packages/astro/src/core/routing/match.ts | 10 +++++++ .../fixtures/i18n-routing/src/pages/404.astro | 12 +++++++++ packages/astro/test/i18n-routing.test.js | 26 +++++++++++++++++++ 5 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 .changeset/warm-poems-breathe.md create mode 100644 packages/astro/test/fixtures/i18n-routing/src/pages/404.astro diff --git a/.changeset/warm-poems-breathe.md b/.changeset/warm-poems-breathe.md new file mode 100644 index 0000000000..e4e9acf80d --- /dev/null +++ b/.changeset/warm-poems-breathe.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes an issue where `Astro.currentLocale` was not correctly returning the locale for 404 and 500 pages. diff --git a/packages/astro/src/core/render-context.ts b/packages/astro/src/core/render-context.ts index 7ccbdd2ef5..5b6243f30a 100644 --- a/packages/astro/src/core/render-context.ts +++ b/packages/astro/src/core/render-context.ts @@ -36,6 +36,7 @@ import { callMiddleware } from './middleware/callMiddleware.js'; import { sequence } from './middleware/index.js'; import { renderRedirect } from './redirects/render.js'; import { type Pipeline, Slots, getParams, getProps } from './render/index.js'; +import { isRoute404or500 } from './routing/match.js'; import { copyRequest, setOriginPathname } from './routing/rewrite.js'; export const apiContextRoutesSymbol = Symbol.for('context.routes'); @@ -541,11 +542,9 @@ export class RenderContext { } let computedLocale; - if (routeData.pathname) { - computedLocale = computeCurrentLocale(routeData.pathname, locales, defaultLocale); - } else { - computedLocale = computeCurrentLocale(url.pathname, locales, defaultLocale); - } + const pathname = + routeData.pathname && !isRoute404or500(routeData) ? routeData.pathname : url.pathname; + computedLocale = computeCurrentLocale(pathname, locales, defaultLocale); this.#currentLocale = computedLocale ?? fallbackTo; return this.#currentLocale; diff --git a/packages/astro/src/core/routing/match.ts b/packages/astro/src/core/routing/match.ts index 40a8b95fba..dbcd173761 100644 --- a/packages/astro/src/core/routing/match.ts +++ b/packages/astro/src/core/routing/match.ts @@ -15,3 +15,13 @@ export function matchRoute(pathname: string, manifest: ManifestData): RouteData export function matchAllRoutes(pathname: string, manifest: ManifestData): RouteData[] { return manifest.routes.filter((route) => route.pattern.test(decodeURI(pathname))); } + +/** + * Determines if the given route matches a 404 or 500 error page. + * + * @param {RouteData} route - The route data to check. + * @returns {boolean} `true` if the route matches a 404 or 500 error page, otherwise `false`. + */ +export function isRoute404or500(route: RouteData): boolean { + return route.pattern.test('/404') || route.pattern.test('/500'); +} diff --git a/packages/astro/test/fixtures/i18n-routing/src/pages/404.astro b/packages/astro/test/fixtures/i18n-routing/src/pages/404.astro new file mode 100644 index 0000000000..fce4a30b83 --- /dev/null +++ b/packages/astro/test/fixtures/i18n-routing/src/pages/404.astro @@ -0,0 +1,12 @@ +--- +const currentLocale = Astro.currentLocale; +--- + + + 404 - Not Found + + +

404 - Not Found

+

Current Locale: {currentLocale ? currentLocale : "none"}

+ + diff --git a/packages/astro/test/i18n-routing.test.js b/packages/astro/test/i18n-routing.test.js index 10c35bacd9..d91a06ec3f 100644 --- a/packages/astro/test/i18n-routing.test.js +++ b/packages/astro/test/i18n-routing.test.js @@ -82,6 +82,18 @@ describe('[DEV] i18n routing', () => { assert.equal(response.status, 200); assert.equal((await response.text()).includes('Endurance'), true); }); + + it('should return the correct locale on 404 page for non existing default locale page', async () => { + const response = await fixture.fetch('/es/nonexistent-page'); + assert.equal(response.status, 404); + assert.equal((await response.text()).includes('Current Locale: es'), true); + }); + + it('should return the correct locale on 404 page for non existing english locale page', async () => { + const response = await fixture.fetch('/en/nonexistent-page'); + assert.equal(response.status, 404); + assert.equal((await response.text()).includes('Current Locale: en'), true); + }); }); describe('i18n routing', () => { @@ -1200,6 +1212,20 @@ describe('[SSR] i18n routing', () => { assert.equal(response.status, 200); assert.equal((await response.text()).includes('Endurance'), true); }); + + it('should return the correct locale on 404 page for non existing default locale page', async () => { + let request = new Request('http://example.com/es/nonexistent-page'); + let response = await app.render(request); + assert.equal(response.status, 404); + assert.equal((await response.text()).includes('Current Locale: es'), true); + }); + + it('should return the correct locale on 404 page for non existing english locale page', async () => { + let request = new Request('http://example.com/en/nonexistent-page'); + let response = await app.render(request); + assert.equal(response.status, 404); + assert.equal((await response.text()).includes('Current Locale: en'), true); + }); }); describe('default', () => { From e329657a00ae4b36efa395670eacb66a4bb0c576 Mon Sep 17 00:00:00 2001 From: Arpan Patel Date: Thu, 21 Nov 2024 09:32:06 +0000 Subject: [PATCH 19/27] [ci] format --- packages/astro/test/i18n-routing.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/astro/test/i18n-routing.test.js b/packages/astro/test/i18n-routing.test.js index d91a06ec3f..8e6c672bee 100644 --- a/packages/astro/test/i18n-routing.test.js +++ b/packages/astro/test/i18n-routing.test.js @@ -87,13 +87,13 @@ describe('[DEV] i18n routing', () => { const response = await fixture.fetch('/es/nonexistent-page'); assert.equal(response.status, 404); assert.equal((await response.text()).includes('Current Locale: es'), true); - }); + }); - it('should return the correct locale on 404 page for non existing english locale page', async () => { + it('should return the correct locale on 404 page for non existing english locale page', async () => { const response = await fixture.fetch('/en/nonexistent-page'); assert.equal(response.status, 404); assert.equal((await response.text()).includes('Current Locale: en'), true); - }); + }); }); describe('i18n routing', () => { From 3f02d5f12b167514fff6eb9693b4e25c668e7a31 Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Thu, 21 Nov 2024 10:45:02 +0000 Subject: [PATCH 20/27] feat: support new location for content config (#12475) * feat: support new location for content config * Test fixes * Handle missing dir * Handle missing content dir * chore: changes from review * Revert legacy fixtures * Clarify changeset --- .changeset/thirty-clocks-jump.md | 7 ++++++ .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 0 packages/astro/src/content/runtime.ts | 14 ++++++++++-- .../astro/src/content/server-listeners.ts | 12 ++++++++-- packages/astro/src/content/types-generator.ts | 7 +++--- packages/astro/src/content/utils.ts | 22 ++++++++++++------- packages/astro/src/core/errors/errors-data.ts | 11 +++++----- packages/astro/src/core/sync/index.ts | 17 +++++++++++--- packages/astro/src/types/public/config.ts | 2 +- packages/astro/test/astro-sync.test.js | 2 +- packages/astro/test/content-layer.test.js | 2 +- .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 2 +- .../{content/config.ts => content.config.ts} | 4 ++-- .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 0 .../{content/config.ts => content.config.ts} | 0 .../content-collections/frontmatter.test.js | 2 +- .../get-entry-type.test.js | 2 +- .../collections-mixed-content-errors.test.js | 6 ++--- .../units/dev/collections-renderentry.test.js | 4 ++-- 39 files changed, 79 insertions(+), 37 deletions(-) create mode 100644 .changeset/thirty-clocks-jump.md rename examples/blog/src/{content/config.ts => content.config.ts} (100%) rename examples/portfolio/src/{content/config.ts => content.config.ts} (100%) rename examples/starlog/src/{content/config.ts => content.config.ts} (100%) rename examples/with-markdoc/src/{content/config.ts => content.config.ts} (100%) rename packages/astro/test/fixtures/astro-assets-dir/src/{content/config.ts => content.config.ts} (100%) rename packages/astro/test/fixtures/astro-assets-prefix/src/{content/config.ts => content.config.ts} (100%) rename packages/astro/test/fixtures/astro-env-content-collections/src/{content/config.ts => content.config.ts} (100%) rename packages/astro/test/fixtures/content with spaces in folder name/src/{content/config.ts => content.config.ts} (100%) rename packages/astro/test/fixtures/content-collection-references/src/{content/config.ts => content.config.ts} (100%) rename packages/astro/test/fixtures/content-collections-base/src/{content/config.ts => content.config.ts} (100%) rename packages/astro/test/fixtures/content-collections-cache-invalidation/src/{content/config.ts => content.config.ts} (100%) rename packages/astro/test/fixtures/content-collections-empty-dir/src/{content/config.ts => content.config.ts} (100%) rename packages/astro/test/fixtures/content-collections-mutation/src/{content/config.ts => content.config.ts} (100%) rename packages/astro/test/fixtures/content-collections-same-contents/src/{content/config.ts => content.config.ts} (100%) rename packages/astro/test/fixtures/content-collections/src/{content/config.ts => content.config.ts} (100%) rename packages/astro/test/fixtures/content-intellisense/src/{content/config.ts => content.config.ts} (100%) rename packages/astro/test/fixtures/content-layer-markdoc/src/{content/config.ts => content.config.ts} (100%) rename packages/astro/test/fixtures/content-layer-rendering/src/{content/config.ts => content.config.ts} (84%) rename packages/astro/test/fixtures/content-layer/src/{content/config.ts => content.config.ts} (98%) rename packages/astro/test/fixtures/content-static-paths-integration/src/{content/config.ts => content.config.ts} (100%) rename packages/astro/test/fixtures/core-image-base/src/{content/config.ts => content.config.ts} (100%) rename packages/astro/test/fixtures/core-image-deletion/src/{content/config.ts => content.config.ts} (100%) rename packages/astro/test/fixtures/core-image-ssg/src/{content/config.ts => content.config.ts} (100%) rename packages/astro/test/fixtures/data-collections-schema/src/{content/config.ts => content.config.ts} (100%) rename packages/astro/test/fixtures/data-collections/src/{content/config.ts => content.config.ts} (100%) diff --git a/.changeset/thirty-clocks-jump.md b/.changeset/thirty-clocks-jump.md new file mode 100644 index 0000000000..39864b2ecb --- /dev/null +++ b/.changeset/thirty-clocks-jump.md @@ -0,0 +1,7 @@ +--- +'astro': minor +--- + +Changes the default content config location from `src/content/config.*` to `src/content.config.*`. + +The previous location is still supported, and is required if the `legacy.collections` flag is enabled. diff --git a/examples/blog/src/content/config.ts b/examples/blog/src/content.config.ts similarity index 100% rename from examples/blog/src/content/config.ts rename to examples/blog/src/content.config.ts diff --git a/examples/portfolio/src/content/config.ts b/examples/portfolio/src/content.config.ts similarity index 100% rename from examples/portfolio/src/content/config.ts rename to examples/portfolio/src/content.config.ts diff --git a/examples/starlog/src/content/config.ts b/examples/starlog/src/content.config.ts similarity index 100% rename from examples/starlog/src/content/config.ts rename to examples/starlog/src/content.config.ts diff --git a/examples/with-markdoc/src/content/config.ts b/examples/with-markdoc/src/content.config.ts similarity index 100% rename from examples/with-markdoc/src/content/config.ts rename to examples/with-markdoc/src/content.config.ts diff --git a/packages/astro/src/content/runtime.ts b/packages/astro/src/content/runtime.ts index 6a8d3f214a..81590da8b3 100644 --- a/packages/astro/src/content/runtime.ts +++ b/packages/astro/src/content/runtime.ts @@ -26,12 +26,22 @@ type GlobResult = Record; type CollectionToEntryMap = Record; type GetEntryImport = (collection: string, lookupId: string) => Promise; +export function getImporterFilename() { + // The 4th line in the stack trace should be the importer filename + const stackLine = new Error().stack?.split('\n')?.[3]; + if (!stackLine) { + return null; + } + // Extract the relative path from the stack line + const match = /\/(src\/.*?):\d+:\d+/.exec(stackLine); + return match?.[1] ?? null; +} + export function defineCollection(config: any) { if ('loader' in config) { if (config.type && config.type !== CONTENT_LAYER_TYPE) { throw new AstroUserError( - 'Collections that use the Content Layer API must have a `loader` defined and no `type` set.', - "Check your collection definitions in `src/content/config.*`.'", + `Collections that use the Content Layer API must have a \`loader\` defined and no \`type\` set. Check your collection definitions in ${getImporterFilename() ?? 'your content config file'}.`, ); } config.type = CONTENT_LAYER_TYPE; diff --git a/packages/astro/src/content/server-listeners.ts b/packages/astro/src/content/server-listeners.ts index 28f5b16a83..33ab2c8959 100644 --- a/packages/astro/src/content/server-listeners.ts +++ b/packages/astro/src/content/server-listeners.ts @@ -24,8 +24,16 @@ export async function attachContentServerListeners({ settings, }: ContentServerListenerParams) { const contentPaths = getContentPaths(settings.config, fs); - - if (fs.existsSync(contentPaths.contentDir)) { + if (!settings.config.legacy?.collections) { + const contentGenerator = await createContentTypesGenerator({ + fs, + settings, + logger, + viteServer, + contentConfigObserver: globalContentConfigObserver, + }); + await contentGenerator.init(); + } else if (fs.existsSync(contentPaths.contentDir)) { logger.debug( 'content', `Watching ${cyan( diff --git a/packages/astro/src/content/types-generator.ts b/packages/astro/src/content/types-generator.ts index c5123acef2..fe76400bba 100644 --- a/packages/astro/src/content/types-generator.ts +++ b/packages/astro/src/content/types-generator.ts @@ -86,13 +86,12 @@ export async function createContentTypesGenerator({ async function init(): Promise< { typesGenerated: true } | { typesGenerated: false; reason: 'no-content-dir' } > { - if (!fs.existsSync(contentPaths.contentDir)) { - return { typesGenerated: false, reason: 'no-content-dir' }; - } - events.push({ name: 'add', entry: contentPaths.config.url }); if (settings.config.legacy.collections) { + if (!fs.existsSync(contentPaths.contentDir)) { + return { typesGenerated: false, reason: 'no-content-dir' }; + } const globResult = await glob('**', { cwd: fileURLToPath(contentPaths.contentDir), fs: { diff --git a/packages/astro/src/content/utils.ts b/packages/astro/src/content/utils.ts index f67a7ad63d..1cdafa1907 100644 --- a/packages/astro/src/content/utils.ts +++ b/packages/astro/src/content/utils.ts @@ -597,7 +597,7 @@ export async function autogenerateCollections({ }) as any, }; } - if (!usesContentLayer) { + if (!usesContentLayer && fs.existsSync(contentDir)) { // If the user hasn't defined any collections using the content layer, we'll try and help out by checking for // any orphaned folders in the content directory and creating collections for them. const orphanedCollections = []; @@ -623,7 +623,7 @@ export async function autogenerateCollections({ console.warn( ` Auto-generating collections for folders in "src/content/" that are not defined as collections. -This is deprecated, so you should define these collections yourself in "src/content/config.ts". +This is deprecated, so you should define these collections yourself in "src/content.config.ts". The following collections have been auto-generated: ${orphanedCollections .map((name) => green(name)) .join(', ')}\n`, @@ -715,10 +715,10 @@ export type ContentPaths = { }; export function getContentPaths( - { srcDir }: Pick, + { srcDir, legacy }: Pick, fs: typeof fsMod = fsMod, ): ContentPaths { - const configStats = search(fs, srcDir); + const configStats = search(fs, srcDir, legacy?.collections); const pkgBase = new URL('../../', import.meta.url); return { contentDir: new URL('./content/', srcDir), @@ -728,10 +728,16 @@ export function getContentPaths( config: configStats, }; } -function search(fs: typeof fsMod, srcDir: URL) { - const paths = ['config.mjs', 'config.js', 'config.mts', 'config.ts'].map( - (p) => new URL(`./content/${p}`, srcDir), - ); +function search(fs: typeof fsMod, srcDir: URL, legacy?: boolean) { + const paths = [ + ...(legacy + ? [] + : ['content.config.mjs', 'content.config.js', 'content.config.mts', 'content.config.ts']), + 'content/config.mjs', + 'content/config.js', + 'content/config.mts', + 'content/config.ts', + ].map((p) => new URL(`./${p}`, srcDir)); for (const file of paths) { if (fs.existsSync(file)) { return { exists: true, url: file }; diff --git a/packages/astro/src/core/errors/errors-data.ts b/packages/astro/src/core/errors/errors-data.ts index 7c5479a665..1b19b6064a 100644 --- a/packages/astro/src/core/errors/errors-data.ts +++ b/packages/astro/src/core/errors/errors-data.ts @@ -1446,7 +1446,8 @@ export const GenerateContentTypesError = { title: 'Failed to generate content types.', message: (errorMessage: string) => `\`astro sync\` command failed to generate content collection types: ${errorMessage}`, - hint: 'This error is often caused by a syntax error inside your content, or your content configuration file. Check your `src/content/config.*` file for typos.', + hint: (fileName?: string) => + `This error is often caused by a syntax error inside your content, or your content configuration file. Check your ${fileName ?? 'content config'} file for typos.`, } satisfies ErrorData; /** * @docs @@ -1458,7 +1459,7 @@ export const GenerateContentTypesError = { * @docs * @description * Astro encountered an unknown error loading your content collections. - * This can be caused by certain errors inside your `src/content/config.ts` file or some internal errors. + * This can be caused by certain errors inside your `src/content.config.ts` file or some internal errors. * * If you can reliably cause this error to happen, we'd appreciate if you could [open an issue](https://astro.build/issues/) */ @@ -1501,7 +1502,7 @@ export const GetEntryDeprecationError = { * @description * A Markdown or MDX entry does not match its collection schema. * Make sure that all required fields are present, and that all fields are of the correct type. - * You can check against the collection schema in your `src/content/config.*` file. + * You can check against the collection schema in your `src/content.config.*` file. * See the [Content collections documentation](https://docs.astro.build/en/guides/content-collections/) for more information. */ export const InvalidContentEntryFrontmatterError = { @@ -1528,7 +1529,7 @@ export const InvalidContentEntryFrontmatterError = { * @description * A content entry does not match its collection schema. * Make sure that all required fields are present, and that all fields are of the correct type. - * You can check against the collection schema in your `src/content/config.*` file. + * You can check against the collection schema in your `src/content.config.*` file. * See the [Content collections documentation](https://docs.astro.build/en/guides/content-collections/) for more information. */ export const InvalidContentEntryDataError = { @@ -1553,7 +1554,7 @@ export const InvalidContentEntryDataError = { * @description * A content entry does not match its collection schema. * Make sure that all required fields are present, and that all fields are of the correct type. - * You can check against the collection schema in your `src/content/config.*` file. + * You can check against the collection schema in your `src/content.config.*` file. * See the [Content collections documentation](https://docs.astro.build/en/guides/content-collections/) for more information. */ export const ContentEntryDataError = { diff --git a/packages/astro/src/core/sync/index.ts b/packages/astro/src/core/sync/index.ts index 5fba6196a8..832a55b282 100644 --- a/packages/astro/src/core/sync/index.ts +++ b/packages/astro/src/core/sync/index.ts @@ -21,7 +21,6 @@ import { resolveConfig } from '../config/config.js'; import { createNodeLogger } from '../config/logging.js'; import { createSettings } from '../config/settings.js'; import { createVite } from '../create-vite.js'; -import { collectErrorMetadata } from '../errors/dev/utils.js'; import { AstroError, AstroErrorData, @@ -31,7 +30,6 @@ import { isAstroError, } from '../errors/index.js'; import type { Logger } from '../logger/core.js'; -import { formatErrorMessage } from '../messages.js'; import { createRouteManifest } from '../routing/index.js'; import { ensureProcessNodeEnv } from '../util.js'; @@ -255,7 +253,20 @@ async function syncContentCollections( if (isAstroError(e)) { throw e; } - const hint = AstroUserError.is(e) ? e.hint : AstroErrorData.GenerateContentTypesError.hint; + let configFile + try { + const contentPaths = getContentPaths(settings.config, fs); + if(contentPaths.config.exists) { + const matches = /\/(src\/.+)/.exec(contentPaths.config.url.href); + if (matches) { + configFile = matches[1] + } + } + } catch { + // ignore + } + + const hint = AstroUserError.is(e) ? e.hint : AstroErrorData.GenerateContentTypesError.hint(configFile); throw new AstroError( { ...AstroErrorData.GenerateContentTypesError, diff --git a/packages/astro/src/types/public/config.ts b/packages/astro/src/types/public/config.ts index 354d304937..a01dc42cd7 100644 --- a/packages/astro/src/types/public/config.ts +++ b/packages/astro/src/types/public/config.ts @@ -1707,7 +1707,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig { * When you are ready to remove this flag and migrate to the new Content Layer API for your legacy collections, you must define a collection for any directories in `src/content/` that you want to continue to use as a collection. It is sufficient to declare an empty collection, and Astro will implicitly generate an appropriate definition for your legacy collections: * * ```js - * // src/content/config.ts + * // src/content.config.ts * import { defineCollection, z } from 'astro:content'; * * const blog = defineCollection({ }) diff --git a/packages/astro/test/astro-sync.test.js b/packages/astro/test/astro-sync.test.js index 94e6b326b7..e9ab90cf75 100644 --- a/packages/astro/test/astro-sync.test.js +++ b/packages/astro/test/astro-sync.test.js @@ -209,7 +209,7 @@ describe('astro sync', () => { assert.fail(); } }); - it('Does not throw if a virtual module is imported in content/config.ts', async () => { + it('Does not throw if a virtual module is imported in content.config.ts', async () => { try { await fixture.load('./fixtures/astro-env-content-collections/'); fixture.clean(); diff --git a/packages/astro/test/content-layer.test.js b/packages/astro/test/content-layer.test.js index 7353c23843..e2d92df3d9 100644 --- a/packages/astro/test/content-layer.test.js +++ b/packages/astro/test/content-layer.test.js @@ -285,7 +285,7 @@ describe('Content Layer', () => { it('clears the store on new build if the config has changed', async () => { let newJson = devalue.parse(await fixture.readFile('/collections.json')); assert.equal(newJson.increment.data.lastValue, 1); - await fixture.editFile('src/content/config.ts', (prev) => { + await fixture.editFile('src/content.config.ts', (prev) => { return `${prev}\nexport const foo = 'bar';`; }); await fixture.build(); diff --git a/packages/astro/test/fixtures/astro-assets-dir/src/content/config.ts b/packages/astro/test/fixtures/astro-assets-dir/src/content.config.ts similarity index 100% rename from packages/astro/test/fixtures/astro-assets-dir/src/content/config.ts rename to packages/astro/test/fixtures/astro-assets-dir/src/content.config.ts diff --git a/packages/astro/test/fixtures/astro-assets-prefix/src/content/config.ts b/packages/astro/test/fixtures/astro-assets-prefix/src/content.config.ts similarity index 100% rename from packages/astro/test/fixtures/astro-assets-prefix/src/content/config.ts rename to packages/astro/test/fixtures/astro-assets-prefix/src/content.config.ts diff --git a/packages/astro/test/fixtures/astro-env-content-collections/src/content/config.ts b/packages/astro/test/fixtures/astro-env-content-collections/src/content.config.ts similarity index 100% rename from packages/astro/test/fixtures/astro-env-content-collections/src/content/config.ts rename to packages/astro/test/fixtures/astro-env-content-collections/src/content.config.ts diff --git a/packages/astro/test/fixtures/content with spaces in folder name/src/content/config.ts b/packages/astro/test/fixtures/content with spaces in folder name/src/content.config.ts similarity index 100% rename from packages/astro/test/fixtures/content with spaces in folder name/src/content/config.ts rename to packages/astro/test/fixtures/content with spaces in folder name/src/content.config.ts diff --git a/packages/astro/test/fixtures/content-collection-references/src/content/config.ts b/packages/astro/test/fixtures/content-collection-references/src/content.config.ts similarity index 100% rename from packages/astro/test/fixtures/content-collection-references/src/content/config.ts rename to packages/astro/test/fixtures/content-collection-references/src/content.config.ts diff --git a/packages/astro/test/fixtures/content-collections-base/src/content/config.ts b/packages/astro/test/fixtures/content-collections-base/src/content.config.ts similarity index 100% rename from packages/astro/test/fixtures/content-collections-base/src/content/config.ts rename to packages/astro/test/fixtures/content-collections-base/src/content.config.ts diff --git a/packages/astro/test/fixtures/content-collections-cache-invalidation/src/content/config.ts b/packages/astro/test/fixtures/content-collections-cache-invalidation/src/content.config.ts similarity index 100% rename from packages/astro/test/fixtures/content-collections-cache-invalidation/src/content/config.ts rename to packages/astro/test/fixtures/content-collections-cache-invalidation/src/content.config.ts diff --git a/packages/astro/test/fixtures/content-collections-empty-dir/src/content/config.ts b/packages/astro/test/fixtures/content-collections-empty-dir/src/content.config.ts similarity index 100% rename from packages/astro/test/fixtures/content-collections-empty-dir/src/content/config.ts rename to packages/astro/test/fixtures/content-collections-empty-dir/src/content.config.ts diff --git a/packages/astro/test/fixtures/content-collections-mutation/src/content/config.ts b/packages/astro/test/fixtures/content-collections-mutation/src/content.config.ts similarity index 100% rename from packages/astro/test/fixtures/content-collections-mutation/src/content/config.ts rename to packages/astro/test/fixtures/content-collections-mutation/src/content.config.ts diff --git a/packages/astro/test/fixtures/content-collections-same-contents/src/content/config.ts b/packages/astro/test/fixtures/content-collections-same-contents/src/content.config.ts similarity index 100% rename from packages/astro/test/fixtures/content-collections-same-contents/src/content/config.ts rename to packages/astro/test/fixtures/content-collections-same-contents/src/content.config.ts diff --git a/packages/astro/test/fixtures/content-collections/src/content/config.ts b/packages/astro/test/fixtures/content-collections/src/content.config.ts similarity index 100% rename from packages/astro/test/fixtures/content-collections/src/content/config.ts rename to packages/astro/test/fixtures/content-collections/src/content.config.ts diff --git a/packages/astro/test/fixtures/content-intellisense/src/content/config.ts b/packages/astro/test/fixtures/content-intellisense/src/content.config.ts similarity index 100% rename from packages/astro/test/fixtures/content-intellisense/src/content/config.ts rename to packages/astro/test/fixtures/content-intellisense/src/content.config.ts diff --git a/packages/astro/test/fixtures/content-layer-markdoc/src/content/config.ts b/packages/astro/test/fixtures/content-layer-markdoc/src/content.config.ts similarity index 100% rename from packages/astro/test/fixtures/content-layer-markdoc/src/content/config.ts rename to packages/astro/test/fixtures/content-layer-markdoc/src/content.config.ts diff --git a/packages/astro/test/fixtures/content-layer-rendering/src/content/config.ts b/packages/astro/test/fixtures/content-layer-rendering/src/content.config.ts similarity index 84% rename from packages/astro/test/fixtures/content-layer-rendering/src/content/config.ts rename to packages/astro/test/fixtures/content-layer-rendering/src/content.config.ts index eb175fa99b..2a8c005d5f 100644 --- a/packages/astro/test/fixtures/content-layer-rendering/src/content/config.ts +++ b/packages/astro/test/fixtures/content-layer-rendering/src/content.config.ts @@ -4,7 +4,7 @@ import { glob } from 'astro/loaders'; const reptiles = defineCollection({ loader: glob({ pattern: '*.mdx', - base: new URL('../../content-outside-src-mdx', import.meta.url), + base: new URL('../content-outside-src-mdx', import.meta.url), }), schema: () => z.object({ diff --git a/packages/astro/test/fixtures/content-layer/src/content/config.ts b/packages/astro/test/fixtures/content-layer/src/content.config.ts similarity index 98% rename from packages/astro/test/fixtures/content-layer/src/content/config.ts rename to packages/astro/test/fixtures/content-layer/src/content.config.ts index 65c0c5df05..82228f61da 100644 --- a/packages/astro/test/fixtures/content-layer/src/content/config.ts +++ b/packages/astro/test/fixtures/content-layer/src/content.config.ts @@ -1,6 +1,6 @@ import { defineCollection, z, reference } from 'astro:content'; import { file, glob } from 'astro/loaders'; -import { loader } from '../loaders/post-loader.js'; +import { loader } from './loaders/post-loader.js'; import { parse as parseToml } from 'toml'; const blog = defineCollection({ @@ -141,7 +141,7 @@ const birds = defineCollection({ }); // Absolute paths should also work -const absoluteRoot = new URL('space', import.meta.url); +const absoluteRoot = new URL('content/space', import.meta.url); const spacecraft = defineCollection({ loader: glob({ pattern: '*.md', base: absoluteRoot }), diff --git a/packages/astro/test/fixtures/content-static-paths-integration/src/content/config.ts b/packages/astro/test/fixtures/content-static-paths-integration/src/content.config.ts similarity index 100% rename from packages/astro/test/fixtures/content-static-paths-integration/src/content/config.ts rename to packages/astro/test/fixtures/content-static-paths-integration/src/content.config.ts diff --git a/packages/astro/test/fixtures/core-image-base/src/content/config.ts b/packages/astro/test/fixtures/core-image-base/src/content.config.ts similarity index 100% rename from packages/astro/test/fixtures/core-image-base/src/content/config.ts rename to packages/astro/test/fixtures/core-image-base/src/content.config.ts diff --git a/packages/astro/test/fixtures/core-image-deletion/src/content/config.ts b/packages/astro/test/fixtures/core-image-deletion/src/content.config.ts similarity index 100% rename from packages/astro/test/fixtures/core-image-deletion/src/content/config.ts rename to packages/astro/test/fixtures/core-image-deletion/src/content.config.ts diff --git a/packages/astro/test/fixtures/core-image-ssg/src/content/config.ts b/packages/astro/test/fixtures/core-image-ssg/src/content.config.ts similarity index 100% rename from packages/astro/test/fixtures/core-image-ssg/src/content/config.ts rename to packages/astro/test/fixtures/core-image-ssg/src/content.config.ts diff --git a/packages/astro/test/fixtures/data-collections-schema/src/content/config.ts b/packages/astro/test/fixtures/data-collections-schema/src/content.config.ts similarity index 100% rename from packages/astro/test/fixtures/data-collections-schema/src/content/config.ts rename to packages/astro/test/fixtures/data-collections-schema/src/content.config.ts diff --git a/packages/astro/test/fixtures/data-collections/src/content/config.ts b/packages/astro/test/fixtures/data-collections/src/content.config.ts similarity index 100% rename from packages/astro/test/fixtures/data-collections/src/content/config.ts rename to packages/astro/test/fixtures/data-collections/src/content.config.ts diff --git a/packages/astro/test/units/content-collections/frontmatter.test.js b/packages/astro/test/units/content-collections/frontmatter.test.js index 4f587a90fe..feffabf956 100644 --- a/packages/astro/test/units/content-collections/frontmatter.test.js +++ b/packages/astro/test/units/content-collections/frontmatter.test.js @@ -10,7 +10,7 @@ describe('frontmatter', () => { title: One --- `, - '/src/content/config.ts': `\ + '/src/content.config.ts': `\ import { defineCollection, z } from 'astro:content'; const posts = defineCollection({ diff --git a/packages/astro/test/units/content-collections/get-entry-type.test.js b/packages/astro/test/units/content-collections/get-entry-type.test.js index 2876e5bfc3..9d60c4c5c0 100644 --- a/packages/astro/test/units/content-collections/get-entry-type.test.js +++ b/packages/astro/test/units/content-collections/get-entry-type.test.js @@ -8,7 +8,7 @@ const fixtures = [ title: 'Without any underscore above the content directory tree', contentPaths: { config: { - url: new URL('src/content/config.ts', import.meta.url), + url: new URL('src/content.config.ts', import.meta.url), exists: true, }, contentDir: new URL('src/content/', import.meta.url), diff --git a/packages/astro/test/units/dev/collections-mixed-content-errors.test.js b/packages/astro/test/units/dev/collections-mixed-content-errors.test.js index da72f4a768..295662c931 100644 --- a/packages/astro/test/units/dev/collections-mixed-content-errors.test.js +++ b/packages/astro/test/units/dev/collections-mixed-content-errors.test.js @@ -57,7 +57,7 @@ name: Ben # Ben `, '/src/content/authors/tony.json': `{ "name": "Tony" }`, - '/src/content/config.ts': `\ + '/src/content.config.ts': `\ import { z, defineCollection } from 'astro:content'; const authors = defineCollection({ @@ -85,7 +85,7 @@ title: Post # Post `, '/src/content/blog/post.yaml': `title: YAML Post`, - '/src/content/config.ts': `\ + '/src/content.config.ts': `\ import { z, defineCollection } from 'astro:content'; const blog = defineCollection({ @@ -128,7 +128,7 @@ export const collections = { banners }; ...baseFileTree, // Add placeholder to ensure directory exists '/src/content/i18n/_placeholder.txt': 'Need content here', - '/src/content/config.ts': `\ + '/src/content.config.ts': `\ import { z, defineCollection } from 'astro:content'; const i18n = defineCollection({ diff --git a/packages/astro/test/units/dev/collections-renderentry.test.js b/packages/astro/test/units/dev/collections-renderentry.test.js index 42e11c2a22..c30c471b88 100644 --- a/packages/astro/test/units/dev/collections-renderentry.test.js +++ b/packages/astro/test/units/dev/collections-renderentry.test.js @@ -166,7 +166,7 @@ describe('Content Collections - render()', () => { it('can be used in a slot', async () => { const fixture = await createFixture({ ...baseFileTree, - '/src/content/config.ts': ` + '/src/content.config.ts': ` import { z, defineCollection } from 'astro:content'; const blog = defineCollection({ @@ -233,7 +233,7 @@ describe('Content Collections - render()', () => { it('can be called from any js/ts file', async () => { const fixture = await createFixture({ ...baseFileTree, - '/src/content/config.ts': ` + '/src/content.config.ts': ` import { z, defineCollection } from 'astro:content'; const blog = defineCollection({ From 8a46e8074d6afb4a23badbd59ed239d526294e8c Mon Sep 17 00:00:00 2001 From: Eldar Kasmamytov <42811701+marbrex@users.noreply.github.com> Date: Thu, 21 Nov 2024 12:12:00 +0100 Subject: [PATCH 21/27] Resolve peer dependency problem in the integration packages (SolidJS, Vue, Svelte, React) (#12481) Co-authored-by: Bjorn Lu Co-authored-by: ematipico <602478+ematipico@users.noreply.github.com> Co-authored-by: bluwy <34116392+bluwy@users.noreply.github.com> --- .changeset/strong-stingrays-provide.md | 9 ++++++++ packages/integrations/preact/package.json | 3 ++- packages/integrations/react/package.json | 6 ++--- packages/integrations/solid/package.json | 6 ++--- packages/integrations/svelte/package.json | 6 ++--- packages/integrations/vue/package.json | 4 ++-- pnpm-lock.yaml | 27 +++++++++++++---------- 7 files changed, 37 insertions(+), 24 deletions(-) create mode 100644 .changeset/strong-stingrays-provide.md diff --git a/.changeset/strong-stingrays-provide.md b/.changeset/strong-stingrays-provide.md new file mode 100644 index 0000000000..a98fea0f8d --- /dev/null +++ b/.changeset/strong-stingrays-provide.md @@ -0,0 +1,9 @@ +--- +'@astrojs/solid-js': patch +'@astrojs/vue': patch +'@astrojs/svelte': patch +'@astrojs/react': patch +'@astrojs/preact': patch +--- + +Resolve `vite` peer dependency problem for strict package managers like **Yarn in PnP mode**. diff --git a/packages/integrations/preact/package.json b/packages/integrations/preact/package.json index c239259561..b441bca21a 100644 --- a/packages/integrations/preact/package.json +++ b/packages/integrations/preact/package.json @@ -40,7 +40,8 @@ "@preact/preset-vite": "2.8.2", "@preact/signals": "^1.3.0", "babel-plugin-transform-hook-names": "^1.0.2", - "preact-render-to-string": "^6.5.11" + "preact-render-to-string": "^6.5.11", + "vite": "^5.4.10" }, "devDependencies": { "astro": "workspace:*", diff --git a/packages/integrations/react/package.json b/packages/integrations/react/package.json index 9bb7a4e193..40749c76df 100644 --- a/packages/integrations/react/package.json +++ b/packages/integrations/react/package.json @@ -50,7 +50,8 @@ }, "dependencies": { "@vitejs/plugin-react": "^4.3.3", - "ultrahtml": "^1.5.3" + "ultrahtml": "^1.5.3", + "vite": "^5.4.10" }, "devDependencies": { "@types/react": "^18.3.12", @@ -59,8 +60,7 @@ "astro-scripts": "workspace:*", "cheerio": "1.0.0", "react": "^18.3.1", - "react-dom": "^18.3.1", - "vite": "^5.4.10" + "react-dom": "^18.3.1" }, "peerDependencies": { "@types/react": "^17.0.50 || ^18.0.21", diff --git a/packages/integrations/solid/package.json b/packages/integrations/solid/package.json index d786893628..e41bca6f64 100644 --- a/packages/integrations/solid/package.json +++ b/packages/integrations/solid/package.json @@ -35,13 +35,13 @@ "dev": "astro-scripts dev \"src/**/*.ts\"" }, "dependencies": { - "vite-plugin-solid": "^2.10.2" + "vite-plugin-solid": "^2.10.2", + "vite": "^5.4.10" }, "devDependencies": { "astro": "workspace:*", "astro-scripts": "workspace:*", - "solid-js": "^1.9.3", - "vite": "^5.4.10" + "solid-js": "^1.9.3" }, "peerDependencies": { "solid-devtools": "^0.30.1", diff --git a/packages/integrations/svelte/package.json b/packages/integrations/svelte/package.json index 2a25510b2f..3a212a87c5 100644 --- a/packages/integrations/svelte/package.json +++ b/packages/integrations/svelte/package.json @@ -40,13 +40,13 @@ }, "dependencies": { "@sveltejs/vite-plugin-svelte": "^4.0.0", - "svelte2tsx": "^0.7.22" + "svelte2tsx": "^0.7.22", + "vite": "^5.4.10" }, "devDependencies": { "astro": "workspace:*", "astro-scripts": "workspace:*", - "svelte": "^5.1.16", - "vite": "^5.4.10" + "svelte": "^5.1.16" }, "peerDependencies": { "astro": "^4.0.0", diff --git a/packages/integrations/vue/package.json b/packages/integrations/vue/package.json index 325d8781f4..ce658b6a8c 100644 --- a/packages/integrations/vue/package.json +++ b/packages/integrations/vue/package.json @@ -45,14 +45,14 @@ "@vitejs/plugin-vue": "^5.1.4", "@vitejs/plugin-vue-jsx": "^4.0.1", "@vue/compiler-sfc": "^3.5.12", - "vite-plugin-vue-devtools": "^7.6.3" + "vite-plugin-vue-devtools": "^7.6.3", + "vite": "^5.4.10" }, "devDependencies": { "astro": "workspace:*", "astro-scripts": "workspace:*", "cheerio": "1.0.0", "linkedom": "^0.18.5", - "vite": "^5.4.10", "vue": "^3.5.12" }, "peerDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3066c19961..f7ae0646d8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5018,6 +5018,9 @@ importers: preact-render-to-string: specifier: ^6.5.11 version: 6.5.11(preact@10.24.3) + vite: + specifier: ^5.4.10 + version: 5.4.10(@types/node@18.19.50)(sass@1.80.6) devDependencies: astro: specifier: workspace:* @@ -5037,6 +5040,9 @@ importers: ultrahtml: specifier: ^1.5.3 version: 1.5.3 + vite: + specifier: ^5.4.10 + version: 5.4.10(@types/node@18.19.50)(sass@1.80.6) devDependencies: '@types/react': specifier: ^18.3.12 @@ -5059,9 +5065,6 @@ importers: react-dom: specifier: ^18.3.1 version: 18.3.1(react@18.3.1) - vite: - specifier: ^5.4.10 - version: 5.4.10(@types/node@18.19.50)(sass@1.80.6) packages/integrations/react/test/fixtures/react-component: dependencies: @@ -5147,6 +5150,9 @@ importers: packages/integrations/solid: dependencies: + vite: + specifier: ^5.4.10 + version: 5.4.10(@types/node@18.19.50)(sass@1.80.6) vite-plugin-solid: specifier: ^2.10.2 version: 2.10.2(solid-js@1.9.3)(vite@5.4.10(@types/node@18.19.50)(sass@1.80.6)) @@ -5160,9 +5166,6 @@ importers: solid-js: specifier: ^1.9.3 version: 1.9.3 - vite: - specifier: ^5.4.10 - version: 5.4.10(@types/node@18.19.50)(sass@1.80.6) packages/integrations/svelte: dependencies: @@ -5172,6 +5175,9 @@ importers: svelte2tsx: specifier: ^0.7.22 version: 0.7.22(svelte@5.1.16)(typescript@5.6.3) + vite: + specifier: ^5.4.10 + version: 5.4.10(@types/node@18.19.50)(sass@1.80.6) devDependencies: astro: specifier: workspace:* @@ -5182,9 +5188,6 @@ importers: svelte: specifier: ^5.1.16 version: 5.1.16 - vite: - specifier: ^5.4.10 - version: 5.4.10(@types/node@18.19.50)(sass@1.80.6) packages/integrations/tailwind: dependencies: @@ -5233,6 +5236,9 @@ importers: '@vue/compiler-sfc': specifier: ^3.5.12 version: 3.5.12 + vite: + specifier: ^5.4.10 + version: 5.4.10(@types/node@18.19.50)(sass@1.80.6) vite-plugin-vue-devtools: specifier: ^7.6.3 version: 7.6.3(rollup@4.24.4)(vite@5.4.10(@types/node@18.19.50)(sass@1.80.6))(vue@3.5.12(typescript@5.6.3)) @@ -5249,9 +5255,6 @@ importers: linkedom: specifier: ^0.18.5 version: 0.18.5 - vite: - specifier: ^5.4.10 - version: 5.4.10(@types/node@18.19.50)(sass@1.80.6) vue: specifier: ^3.5.12 version: 3.5.12(typescript@5.6.3) From b9c05f45b2c9780d7b5518adb4a545cf69f075a6 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 21 Nov 2024 03:12:37 -0800 Subject: [PATCH 22/27] [ci] release (#12452) Co-authored-by: github-actions[bot] --- .changeset/early-scissors-beg.md | 5 --- .changeset/olive-garlics-marry.md | 5 --- .changeset/six-pianos-draw.md | 5 --- .changeset/thick-shrimps-hammer.md | 5 --- .changeset/thin-cups-peel.md | 5 --- .changeset/warm-poems-breathe.md | 5 --- examples/basics/package.json | 2 +- examples/blog/package.json | 2 +- examples/component/package.json | 2 +- examples/container-with-vitest/package.json | 2 +- examples/framework-alpine/package.json | 2 +- examples/framework-lit/package.json | 2 +- examples/framework-multiple/package.json | 2 +- examples/framework-preact/package.json | 2 +- examples/framework-react/package.json | 2 +- examples/framework-solid/package.json | 2 +- examples/framework-svelte/package.json | 2 +- examples/framework-vue/package.json | 2 +- examples/hackernews/package.json | 2 +- examples/integration/package.json | 2 +- examples/minimal/package.json | 2 +- examples/portfolio/package.json | 2 +- examples/ssr/package.json | 2 +- examples/starlog/package.json | 2 +- examples/toolbar-app/package.json | 2 +- examples/with-markdoc/package.json | 2 +- examples/with-mdx/package.json | 2 +- examples/with-nanostores/package.json | 2 +- examples/with-tailwindcss/package.json | 2 +- examples/with-vitest/package.json | 2 +- packages/astro/CHANGELOG.md | 16 +++++++ packages/astro/package.json | 2 +- pnpm-lock.yaml | 48 ++++++++++----------- 33 files changed, 65 insertions(+), 79 deletions(-) delete mode 100644 .changeset/early-scissors-beg.md delete mode 100644 .changeset/olive-garlics-marry.md delete mode 100644 .changeset/six-pianos-draw.md delete mode 100644 .changeset/thick-shrimps-hammer.md delete mode 100644 .changeset/thin-cups-peel.md delete mode 100644 .changeset/warm-poems-breathe.md diff --git a/.changeset/early-scissors-beg.md b/.changeset/early-scissors-beg.md deleted file mode 100644 index 0b3d85e430..0000000000 --- a/.changeset/early-scissors-beg.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Removes the default throw behavior in `astro:env` diff --git a/.changeset/olive-garlics-marry.md b/.changeset/olive-garlics-marry.md deleted file mode 100644 index 342db3a6f6..0000000000 --- a/.changeset/olive-garlics-marry.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes an issue where a server island hydration script might fail case the island ID misses from the DOM. diff --git a/.changeset/six-pianos-draw.md b/.changeset/six-pianos-draw.md deleted file mode 100644 index 61a6d07eb3..0000000000 --- a/.changeset/six-pianos-draw.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes a case where the Content Layer `glob()` loader would not update when renaming or deleting an entry diff --git a/.changeset/thick-shrimps-hammer.md b/.changeset/thick-shrimps-hammer.md deleted file mode 100644 index b46b9ad6c2..0000000000 --- a/.changeset/thick-shrimps-hammer.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fix cached image redownloading if it is the first asset diff --git a/.changeset/thin-cups-peel.md b/.changeset/thin-cups-peel.md deleted file mode 100644 index 3fc4678cb5..0000000000 --- a/.changeset/thin-cups-peel.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes an issue where the SSR build was emitting the `dist/server/entry.mjs` file with an incorrect import at the top of the file/ diff --git a/.changeset/warm-poems-breathe.md b/.changeset/warm-poems-breathe.md deleted file mode 100644 index e4e9acf80d..0000000000 --- a/.changeset/warm-poems-breathe.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes an issue where `Astro.currentLocale` was not correctly returning the locale for 404 and 500 pages. diff --git a/examples/basics/package.json b/examples/basics/package.json index 932cb1c6c9..c97f2010ed 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.16.13" + "astro": "^4.16.14" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 9983953cda..2dea4dac49 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -14,6 +14,6 @@ "@astrojs/mdx": "^3.1.9", "@astrojs/rss": "^4.0.9", "@astrojs/sitemap": "^3.2.1", - "astro": "^4.16.13" + "astro": "^4.16.14" } } diff --git a/examples/component/package.json b/examples/component/package.json index 9226413bf9..9d76784313 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.16.13" + "astro": "^4.16.14" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/container-with-vitest/package.json b/examples/container-with-vitest/package.json index 0ab9720ad2..ab3a295aad 100644 --- a/examples/container-with-vitest/package.json +++ b/examples/container-with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest run" }, "dependencies": { - "astro": "^4.16.13", + "astro": "^4.16.14", "@astrojs/react": "^3.6.2", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index 9c201175bb..ab1f6169e8 100644 --- a/examples/framework-alpine/package.json +++ b/examples/framework-alpine/package.json @@ -14,6 +14,6 @@ "@astrojs/alpinejs": "^0.4.0", "@types/alpinejs": "^3.13.10", "alpinejs": "^3.14.3", - "astro": "^4.16.13" + "astro": "^4.16.14" } } diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json index 9da0a1332e..1d7b9ca948 100644 --- a/examples/framework-lit/package.json +++ b/examples/framework-lit/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/lit": "^4.3.0", "@webcomponents/template-shadowroot": "^0.2.1", - "astro": "^4.16.13", + "astro": "^4.16.14", "lit": "^3.2.1" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index d8b86a81dc..d6900fff34 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -18,7 +18,7 @@ "@astrojs/vue": "^4.5.2", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", - "astro": "^4.16.13", + "astro": "^4.16.14", "preact": "^10.24.3", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index 7293b436cb..6c822be2e4 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.3", "@preact/signals": "^1.3.0", - "astro": "^4.16.13", + "astro": "^4.16.14", "preact": "^10.24.3" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index 1b7870164a..158f03dbd9 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -14,7 +14,7 @@ "@astrojs/react": "^3.6.2", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", - "astro": "^4.16.13", + "astro": "^4.16.14", "react": "^18.3.1", "react-dom": "^18.3.1" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index 14037fd844..dc9efdb80f 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/solid-js": "^4.4.3", - "astro": "^4.16.13", + "astro": "^4.16.14", "solid-js": "^1.9.3" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index 2a06f5d65c..2b3ea17916 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/svelte": "^6.0.1", - "astro": "^4.16.13", + "astro": "^4.16.14", "svelte": "^5.1.16" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index 153cd6a3cc..d7afee280b 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/vue": "^4.5.2", - "astro": "^4.16.13", + "astro": "^4.16.14", "vue": "^3.5.12" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index e9c4d08ef9..7706bac81d 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/node": "^8.3.4", - "astro": "^4.16.13" + "astro": "^4.16.14" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index 394c38db51..4d39c18f75 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.16.13" + "astro": "^4.16.14" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/minimal/package.json b/examples/minimal/package.json index 577c43e9c4..dc07957095 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.16.13" + "astro": "^4.16.14" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index a9412fd047..648b405826 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.16.13" + "astro": "^4.16.14" } } diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 88802eada3..97bb22f2f2 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -14,7 +14,7 @@ "dependencies": { "@astrojs/node": "^8.3.4", "@astrojs/svelte": "^6.0.1", - "astro": "^4.16.13", + "astro": "^4.16.14", "svelte": "^5.1.16" } } diff --git a/examples/starlog/package.json b/examples/starlog/package.json index 5bb986033e..c515133a55 100644 --- a/examples/starlog/package.json +++ b/examples/starlog/package.json @@ -10,7 +10,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.16.13", + "astro": "^4.16.14", "sass": "^1.80.6", "sharp": "^0.33.3" } diff --git a/examples/toolbar-app/package.json b/examples/toolbar-app/package.json index d64980b3b2..1462eb0989 100644 --- a/examples/toolbar-app/package.json +++ b/examples/toolbar-app/package.json @@ -15,6 +15,6 @@ "./app": "./dist/app.js" }, "devDependencies": { - "astro": "^4.16.13" + "astro": "^4.16.14" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index 4b5321bbdd..bd0e1cf9d0 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/markdoc": "^0.11.5", - "astro": "^4.16.13" + "astro": "^4.16.14" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index d372044bd4..cd3fd5fec8 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/mdx": "^3.1.9", "@astrojs/preact": "^3.5.3", - "astro": "^4.16.13", + "astro": "^4.16.14", "preact": "^10.24.3" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 0069ff91aa..66cd59afb4 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.3", "@nanostores/preact": "^0.5.2", - "astro": "^4.16.13", + "astro": "^4.16.14", "nanostores": "^0.11.3", "preact": "^10.24.3" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index feb9995419..0f4a99c373 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -14,7 +14,7 @@ "@astrojs/mdx": "^3.1.9", "@astrojs/tailwind": "^5.1.2", "@types/canvas-confetti": "^1.6.4", - "astro": "^4.16.13", + "astro": "^4.16.14", "autoprefixer": "^10.4.20", "canvas-confetti": "^1.9.3", "postcss": "^8.4.47", diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index 602430de64..14d77f5c68 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^4.16.13", + "astro": "^4.16.14", "vitest": "^2.1.4" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 9e919f2e1b..c873a77d57 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,21 @@ # astro +## 4.16.14 + +### Patch Changes + +- [#12480](https://github.com/withastro/astro/pull/12480) [`c3b7e7c`](https://github.com/withastro/astro/commit/c3b7e7cfa13603c08eb923703f31a92d514e82db) Thanks [@matthewp](https://github.com/matthewp)! - Removes the default throw behavior in `astro:env` + +- [#12444](https://github.com/withastro/astro/pull/12444) [`28dd3ce`](https://github.com/withastro/astro/commit/28dd3ce5222a667fe113238254edf59318b3fa14) Thanks [@ematipico](https://github.com/ematipico)! - Fixes an issue where a server island hydration script might fail case the island ID misses from the DOM. + +- [#12476](https://github.com/withastro/astro/pull/12476) [`80a9a52`](https://github.com/withastro/astro/commit/80a9a5299a9d51f2b09900d3200976d687feae8f) Thanks [@florian-lefebvre](https://github.com/florian-lefebvre)! - Fixes a case where the Content Layer `glob()` loader would not update when renaming or deleting an entry + +- [#12418](https://github.com/withastro/astro/pull/12418) [`25baa4e`](https://github.com/withastro/astro/commit/25baa4ed0c5f55fa85c2c7e2c15848937ed1dc9b) Thanks [@oliverlynch](https://github.com/oliverlynch)! - Fix cached image redownloading if it is the first asset + +- [#12477](https://github.com/withastro/astro/pull/12477) [`46f6b38`](https://github.com/withastro/astro/commit/46f6b386b3db6332f286d79958ef10261958cceb) Thanks [@ematipico](https://github.com/ematipico)! - Fixes an issue where the SSR build was emitting the `dist/server/entry.mjs` file with an incorrect import at the top of the file/ + +- [#12365](https://github.com/withastro/astro/pull/12365) [`a23985b`](https://github.com/withastro/astro/commit/a23985b02165c2ddce56d511b3f97b6815c452c9) Thanks [@apatel369](https://github.com/apatel369)! - Fixes an issue where `Astro.currentLocale` was not correctly returning the locale for 404 and 500 pages. + ## 4.16.13 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index fb0440afa9..0a4d34f651 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "4.16.13", + "version": "4.16.14", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f7ae0646d8..dd7b3f6473 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -142,7 +142,7 @@ importers: examples/basics: dependencies: astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro examples/blog: @@ -157,13 +157,13 @@ importers: specifier: ^3.2.1 version: link:../../packages/integrations/sitemap astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro examples/component: devDependencies: astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro examples/container-with-vitest: @@ -172,7 +172,7 @@ importers: specifier: ^3.6.2 version: link:../../packages/integrations/react astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -203,7 +203,7 @@ importers: specifier: ^3.14.3 version: 3.14.3 astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro examples/framework-lit: @@ -215,7 +215,7 @@ importers: specifier: ^0.2.1 version: 0.2.1 astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro lit: specifier: ^3.2.1 @@ -245,7 +245,7 @@ importers: specifier: ^18.3.1 version: 18.3.1 astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro preact: specifier: ^10.24.3 @@ -275,7 +275,7 @@ importers: specifier: ^1.3.0 version: 1.3.0(preact@10.24.3) astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro preact: specifier: ^10.24.3 @@ -293,7 +293,7 @@ importers: specifier: ^18.3.1 version: 18.3.1 astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -308,7 +308,7 @@ importers: specifier: ^4.4.3 version: link:../../packages/integrations/solid astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro solid-js: specifier: ^1.9.3 @@ -320,7 +320,7 @@ importers: specifier: ^6.0.1 version: link:../../packages/integrations/svelte astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro svelte: specifier: ^5.1.16 @@ -332,7 +332,7 @@ importers: specifier: ^4.5.2 version: link:../../packages/integrations/vue astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro vue: specifier: ^3.5.12 @@ -344,25 +344,25 @@ importers: specifier: ^8.3.4 version: 8.3.4(astro@packages+astro) astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro examples/integration: devDependencies: astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro examples/minimal: dependencies: astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro examples/portfolio: dependencies: astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro examples/ssr: @@ -374,7 +374,7 @@ importers: specifier: ^6.0.1 version: link:../../packages/integrations/svelte astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro svelte: specifier: ^5.1.16 @@ -383,7 +383,7 @@ importers: examples/starlog: dependencies: astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro sass: specifier: ^1.80.6 @@ -395,7 +395,7 @@ importers: examples/toolbar-app: devDependencies: astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro examples/with-markdoc: @@ -404,7 +404,7 @@ importers: specifier: ^0.11.5 version: link:../../packages/integrations/markdoc astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro examples/with-mdx: @@ -416,7 +416,7 @@ importers: specifier: ^3.5.3 version: link:../../packages/integrations/preact astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro preact: specifier: ^10.24.3 @@ -431,7 +431,7 @@ importers: specifier: ^0.5.2 version: 0.5.2(nanostores@0.11.3)(preact@10.24.3) astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro nanostores: specifier: ^0.11.3 @@ -452,7 +452,7 @@ importers: specifier: ^1.6.4 version: 1.6.4 astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro autoprefixer: specifier: ^10.4.20 @@ -470,7 +470,7 @@ importers: examples/with-vitest: dependencies: astro: - specifier: ^4.16.13 + specifier: ^4.16.14 version: link:../../packages/astro vitest: specifier: ^2.1.4 From 8309c61f0dfa5991d3f6c5c5fca4403794d6fda2 Mon Sep 17 00:00:00 2001 From: Florian Lefebvre Date: Thu, 21 Nov 2024 12:30:49 +0100 Subject: [PATCH 23/27] feat(next): astro:routes:resolved (#12329) Co-authored-by: Luiz Ferraz Co-authored-by: Emanuele Stoppa Co-authored-by: Sarah Rainsberger --- .changeset/giant-ravens-look.md | 50 ++++ packages/astro/src/actions/integration.ts | 3 +- packages/astro/src/assets/endpoint/config.ts | 1 + packages/astro/src/container/index.ts | 1 + packages/astro/src/core/dev/container.ts | 4 +- .../routing/astro-designed-error-pages.ts | 2 + .../astro/src/core/routing/manifest/create.ts | 11 +- .../core/routing/manifest/serialization.ts | 1 + .../astro/src/core/server-islands/endpoint.ts | 1 + packages/astro/src/integrations/hooks.ts | 50 +++- packages/astro/src/types/astro.ts | 6 +- .../astro/src/types/public/integrations.ts | 52 ++++- packages/astro/src/types/public/internal.ts | 18 ++ .../src/vite-plugin-astro-server/plugin.ts | 48 +++- .../index.ts | 4 +- .../astro/test/units/integrations/api.test.js | 217 +++++++++++++++++- 16 files changed, 434 insertions(+), 35 deletions(-) create mode 100644 .changeset/giant-ravens-look.md diff --git a/.changeset/giant-ravens-look.md b/.changeset/giant-ravens-look.md new file mode 100644 index 0000000000..dfa5d6d95b --- /dev/null +++ b/.changeset/giant-ravens-look.md @@ -0,0 +1,50 @@ +--- +'astro': minor +--- + +Adds a new `astro:routes:resolved` hook to the Integration API. Also update the `astro:build:done` hook by deprecating `routes` and adding a new `assets` map. + +When building an integration, you can now get access to routes inside the `astro:routes:resolved` hook: + +```js +const integration = () => { + return { + name: 'my-integration', + hooks: { + 'astro:routes:resolved': ({ routes }) => { + console.log(routes) + } + } + } +} +``` + +This hook runs before `astro:config:done`, and whenever a route changes in development. + +The `routes` array from `astro:build:done` is now deprecated, and exposed properties are now available on `astro:routes:resolved`, except for `distURL`. For this, you can use the newly exposed `assets` map: + +```diff +const integration = () => { ++ let routes + return { + name: 'my-integration', + hooks: { ++ 'astro:routes:resolved': (params) => { ++ routes = params.routes ++ }, + 'astro:build:done': ({ +- routes ++ assets + }) => { ++ for (const route of routes) { ++ const distURL = assets.get(route.pattern) ++ if (distURL) { ++ Object.assign(route, { distURL }) ++ } ++ } + console.log(routes) + } + } + } +} +``` \ No newline at end of file diff --git a/packages/astro/src/actions/integration.ts b/packages/astro/src/actions/integration.ts index d7c99fc421..13d76e8b60 100644 --- a/packages/astro/src/actions/integration.ts +++ b/packages/astro/src/actions/integration.ts @@ -18,10 +18,11 @@ export default function astroIntegrationActionsRouteHandler({ name: VIRTUAL_MODULE_ID, hooks: { async 'astro:config:setup'(params) { - params.injectRoute({ + settings.injectedRoutes.push({ pattern: ACTION_RPC_ROUTE_PATTERN, entrypoint: 'astro/actions/runtime/route.js', prerender: false, + origin: 'internal', }); params.addMiddleware({ diff --git a/packages/astro/src/assets/endpoint/config.ts b/packages/astro/src/assets/endpoint/config.ts index a910df25cc..b9309d4469 100644 --- a/packages/astro/src/assets/endpoint/config.ts +++ b/packages/astro/src/assets/endpoint/config.ts @@ -63,5 +63,6 @@ function getImageEndpointData( pathname: settings.config.image.endpoint.route, prerender: false, fallbackRoutes: [], + origin: 'internal', }; } diff --git a/packages/astro/src/container/index.ts b/packages/astro/src/container/index.ts index 7694f3afa2..2564e28750 100644 --- a/packages/astro/src/container/index.ts +++ b/packages/astro/src/container/index.ts @@ -544,6 +544,7 @@ export class experimental_AstroContainer { type, fallbackRoutes: [], isIndex: false, + origin: 'internal', }; } diff --git a/packages/astro/src/core/dev/container.ts b/packages/astro/src/core/dev/container.ts index 3f9090498b..0ca40cd74b 100644 --- a/packages/astro/src/core/dev/container.ts +++ b/packages/astro/src/core/dev/container.ts @@ -7,6 +7,7 @@ import * as vite from 'vite'; import { runHookConfigDone, runHookConfigSetup, + runHookRoutesResolved, runHookServerDone, runHookServerStart, } from '../../integrations/hooks.js'; @@ -83,10 +84,11 @@ export async function createContainer({ .filter(Boolean) as string[]; // Create the route manifest already outside of Vite so that `runHookConfigDone` can use it to inform integrations of the build output - let manifest = await createRouteManifest({ settings, fsMod: fs }, logger); + let manifest = await createRouteManifest({ settings, fsMod: fs }, logger, { dev: true }); const devSSRManifest = createDevelopmentManifest(settings); manifest = injectDefaultDevRoutes(settings, devSSRManifest, manifest); + await runHookRoutesResolved({ settings, logger, routes: manifest.routes }); await runHookConfigDone({ settings, logger, command: 'dev' }); diff --git a/packages/astro/src/core/routing/astro-designed-error-pages.ts b/packages/astro/src/core/routing/astro-designed-error-pages.ts index 671221b5d6..4348e6e974 100644 --- a/packages/astro/src/core/routing/astro-designed-error-pages.ts +++ b/packages/astro/src/core/routing/astro-designed-error-pages.ts @@ -15,6 +15,7 @@ export const DEFAULT_404_ROUTE: RouteData = { route: '/404', fallbackRoutes: [], isIndex: false, + origin: 'internal', }; export const DEFAULT_500_ROUTE: RouteData = { @@ -29,6 +30,7 @@ export const DEFAULT_500_ROUTE: RouteData = { route: '/500', fallbackRoutes: [], isIndex: false, + origin: 'internal', }; export function ensure404Route(manifest: ManifestData) { diff --git a/packages/astro/src/core/routing/manifest/create.ts b/packages/astro/src/core/routing/manifest/create.ts index 33b5216998..621164084e 100644 --- a/packages/astro/src/core/routing/manifest/create.ts +++ b/packages/astro/src/core/routing/manifest/create.ts @@ -20,6 +20,7 @@ import { routeComparator } from '../priority.js'; import { getRouteGenerator } from './generator.js'; import { getPattern } from './pattern.js'; import { getRoutePrerenderOption } from './prerender.js'; +import { runHookRoutesResolved } from '../../../integrations/hooks.js'; const require = createRequire(import.meta.url); interface Item { @@ -255,6 +256,7 @@ function createFileBasedRoutes( prerender, fallbackRoutes: [], distURL: [], + origin: 'project', }); } } @@ -280,7 +282,7 @@ function createInjectedRoutes({ settings, cwd }: CreateRouteManifestParams): Rou const routes: RouteData[] = []; for (const injectedRoute of settings.injectedRoutes) { - const { pattern: name, entrypoint, prerender: prerenderInjected } = injectedRoute; + const { pattern: name, entrypoint, prerender: prerenderInjected, origin } = injectedRoute; const { resolved, component } = resolveInjectedRoute(entrypoint.toString(), config.root, cwd); const segments = removeLeadingForwardSlash(name) @@ -320,6 +322,7 @@ function createInjectedRoutes({ settings, cwd }: CreateRouteManifestParams): Rou prerender: prerenderInjected ?? prerender, fallbackRoutes: [], distURL: [], + origin, }); } @@ -389,6 +392,7 @@ function createRedirectRoutes( redirectRoute: routeMap.get(destination), fallbackRoutes: [], distURL: [], + origin: 'project', }); } @@ -480,6 +484,7 @@ function detectRouteCollision(a: RouteData, b: RouteData, _config: AstroConfig, export async function createRouteManifest( params: CreateRouteManifestParams, logger: Logger, + { dev = false }: { dev?: boolean } = {}, ): Promise { const { settings } = params; const { config } = settings; @@ -727,6 +732,10 @@ export async function createRouteManifest( } } + if (!dev) { + await runHookRoutesResolved({ routes, settings, logger }); + } + return { routes, }; diff --git a/packages/astro/src/core/routing/manifest/serialization.ts b/packages/astro/src/core/routing/manifest/serialization.ts index c0cf600f0b..3d6214876c 100644 --- a/packages/astro/src/core/routing/manifest/serialization.ts +++ b/packages/astro/src/core/routing/manifest/serialization.ts @@ -41,5 +41,6 @@ export function deserializeRouteData(rawRouteData: SerializedRouteData): RouteDa return deserializeRouteData(fallback); }), isIndex: rawRouteData.isIndex, + origin: rawRouteData.origin, }; } diff --git a/packages/astro/src/core/server-islands/endpoint.ts b/packages/astro/src/core/server-islands/endpoint.ts index 540f75b843..999826a6f8 100644 --- a/packages/astro/src/core/server-islands/endpoint.ts +++ b/packages/astro/src/core/server-islands/endpoint.ts @@ -31,6 +31,7 @@ export function getServerIslandRouteData(config: ConfigFields) { isIndex: false, fallbackRoutes: [], route: SERVER_ISLAND_ROUTE, + origin: 'internal', }; return route; } diff --git a/packages/astro/src/integrations/hooks.ts b/packages/astro/src/integrations/hooks.ts index 4c1d4a1ae2..5a4b723b20 100644 --- a/packages/astro/src/integrations/hooks.ts +++ b/packages/astro/src/integrations/hooks.ts @@ -24,7 +24,9 @@ import type { import type { AstroIntegration, AstroRenderer, + BaseIntegrationHooks, HookParameters, + IntegrationResolvedRoute, IntegrationRouteData, RouteOptions, } from '../types/public/integrations.js'; @@ -39,7 +41,7 @@ async function withTakingALongTimeMsg({ logger, }: { name: string; - hookName: string; + hookName: keyof BaseIntegrationHooks; hookResult: T | Promise; timeoutMs?: number; logger: Logger; @@ -204,7 +206,7 @@ export async function runHookConfigSetup({ ); injectRoute.entrypoint = injectRoute.entryPoint as string; } - updatedSettings.injectedRoutes.push(injectRoute); + updatedSettings.injectedRoutes.push({ ...injectRoute, origin: 'external' }); }, addWatchFile: (path) => { updatedSettings.watchFiles.push(path instanceof URL ? fileURLToPath(path) : path); @@ -599,6 +601,9 @@ export async function runHookBuildDone({ settings, pages, routes, logging }: Run pages: pages.map((p) => ({ pathname: p })), dir, routes: integrationRoutes, + assets: new Map( + routes.filter((r) => r.distURL !== undefined).map((r) => [r.route, r.distURL!]), + ), logger, }), logger: logging, @@ -648,6 +653,47 @@ export async function runHookRouteSetup({ } } +export async function runHookRoutesResolved({ + routes, + settings, + logger, +}: { routes: Array; settings: AstroSettings; logger: Logger }) { + for (const integration of settings.config.integrations) { + if (integration?.hooks?.['astro:routes:resolved']) { + const integrationLogger = getLogger(integration, logger); + + await withTakingALongTimeMsg({ + name: integration.name, + hookName: 'astro:routes:resolved', + hookResult: integration.hooks['astro:routes:resolved']({ + routes: routes.map((route) => toIntegrationResolvedRoute(route)), + logger: integrationLogger, + }), + logger, + }); + } + } +} + +function toIntegrationResolvedRoute(route: RouteData): IntegrationResolvedRoute { + return { + isPrerendered: route.prerender, + entrypoint: route.component, + pattern: route.route, + params: route.params, + origin: route.origin, + generate: route.generate, + patternRegex: route.pattern, + segments: route.segments, + type: route.type, + pathname: route.pathname, + redirect: route.redirect, + redirectRoute: route.redirectRoute + ? toIntegrationResolvedRoute(route.redirectRoute) + : undefined, + }; +} + function toIntegrationRouteData(route: RouteData): IntegrationRouteData { return { route: route.route, diff --git a/packages/astro/src/types/astro.ts b/packages/astro/src/types/astro.ts index 7e2f2af7e0..654652c422 100644 --- a/packages/astro/src/types/astro.ts +++ b/packages/astro/src/types/astro.ts @@ -10,12 +10,10 @@ import type { ContentEntryType, DataEntryType } from './public/content.js'; import type { AstroAdapter, AstroRenderer, - InjectedRoute, InjectedScriptStage, InjectedType, - ResolvedInjectedRoute, } from './public/integrations.js'; -import type { RouteData } from './public/internal.js'; +import type { InternalInjectedRoute, RouteData, ResolvedInjectedRoute } from './public/internal.js'; import type { DevToolbarAppEntry } from './public/toolbar.js'; export type SerializedRouteData = Omit< @@ -35,7 +33,7 @@ export interface AstroSettings { config: AstroConfig; adapter: AstroAdapter | undefined; preferences: AstroPreferences; - injectedRoutes: InjectedRoute[]; + injectedRoutes: InternalInjectedRoute[]; resolvedInjectedRoutes: ResolvedInjectedRoute[]; pageExtensions: string[]; contentEntryTypes: ContentEntryType[]; diff --git a/packages/astro/src/types/public/integrations.ts b/packages/astro/src/types/public/integrations.ts index 4d0709fab4..2d0b13e963 100644 --- a/packages/astro/src/types/public/integrations.ts +++ b/packages/astro/src/types/public/integrations.ts @@ -8,7 +8,7 @@ import type { getToolbarServerCommunicationHelpers } from '../../integrations/ho import type { DeepPartial } from '../../type-utils.js'; import type { AstroConfig } from './config.js'; import type { RefreshContentOptions } from './content.js'; -import type { RouteData } from './internal.js'; +import type { InternalInjectedRoute, RouteData } from './internal.js'; import type { DevToolbarAppEntry } from './toolbar.js'; export interface RouteOptions { @@ -138,15 +138,7 @@ export type AstroAdapterFeatureMap = { */ export type InjectedScriptStage = 'before-hydration' | 'head-inline' | 'page' | 'page-ssr'; -export interface InjectedRoute { - pattern: string; - entrypoint: string | URL; - prerender?: boolean; -} - -export interface ResolvedInjectedRoute extends InjectedRoute { - resolvedEntryPoint?: URL; -} +export type InjectedRoute = Omit; export interface InjectedType { filename: string; @@ -225,13 +217,19 @@ export interface BaseIntegrationHooks { 'astro:build:done': (options: { pages: { pathname: string }[]; dir: URL; + /** @deprecated Use the `assets` map and the new `astro:routes:resolved` hook */ routes: IntegrationRouteData[]; + assets: Map; logger: AstroIntegrationLogger; }) => void | Promise; 'astro:route:setup': (options: { route: RouteOptions; logger: AstroIntegrationLogger; }) => void | Promise; + 'astro:routes:resolved': (options: { + routes: IntegrationResolvedRoute[]; + logger: AstroIntegrationLogger; + }) => void | Promise; } export interface AstroIntegration { @@ -245,13 +243,45 @@ export interface AstroIntegration { /** * A smaller version of the {@link RouteData} that is used in the integrations. + * @deprecated Use {@link IntegrationResolvedRoute} */ export type IntegrationRouteData = Omit< RouteData, - 'isIndex' | 'fallbackRoutes' | 'redirectRoute' + 'isIndex' | 'fallbackRoutes' | 'redirectRoute' | 'origin' > & { /** * {@link RouteData.redirectRoute} */ redirectRoute?: IntegrationRouteData; }; + +export interface IntegrationResolvedRoute + extends Pick< + RouteData, + 'generate' | 'params' | 'pathname' | 'segments' | 'type' | 'redirect' | 'origin' + > { + /** + * {@link RouteData.route} + */ + pattern: RouteData['route']; + + /** + * {@link RouteData.pattern} + */ + patternRegex: RouteData['pattern']; + + /** + * {@link RouteData.component} + */ + entrypoint: RouteData['component']; + + /** + * {@link RouteData.prerender} + */ + isPrerendered: RouteData['prerender']; + + /** + * {@link RouteData.redirectRoute} + */ + redirectRoute?: IntegrationResolvedRoute; +} diff --git a/packages/astro/src/types/public/internal.ts b/packages/astro/src/types/public/internal.ts index c970ab3d18..a17ee76506 100644 --- a/packages/astro/src/types/public/internal.ts +++ b/packages/astro/src/types/public/internal.ts @@ -136,6 +136,11 @@ export interface RouteData { * - src/pages/blog/index.astro */ isIndex: boolean; + + /** + * Whether the route comes from Astro core, an integration or the user's project + */ + origin: 'internal' | 'external' | 'project'; } /** @@ -284,3 +289,16 @@ export interface SSRMetadata { } export type SSRError = Error & ViteErrorPayload['err']; + +// `origin` is set within the hook, but the user doesn't have access to this property. That's why +// we need an intermediary interface +export interface InternalInjectedRoute { + pattern: string; + entrypoint: string | URL; + prerender?: boolean; + origin: RouteData['origin']; +} + +export interface ResolvedInjectedRoute extends InternalInjectedRoute { + resolvedEntryPoint?: URL; +} diff --git a/packages/astro/src/vite-plugin-astro-server/plugin.ts b/packages/astro/src/vite-plugin-astro-server/plugin.ts index 2a22db6c77..642565161b 100644 --- a/packages/astro/src/vite-plugin-astro-server/plugin.ts +++ b/packages/astro/src/vite-plugin-astro-server/plugin.ts @@ -2,6 +2,7 @@ import { AsyncLocalStorage } from 'node:async_hooks'; import type fs from 'node:fs'; import { IncomingMessage } from 'node:http'; import type * as vite from 'vite'; +import { normalizePath } from 'vite'; import type { SSRManifest, SSRManifestI18n } from '../core/app/types.js'; import { warnMissingAdapter } from '../core/dev/adapter-validation.js'; import { createKey } from '../core/encryption.js'; @@ -21,6 +22,9 @@ import { recordServerError } from './error.js'; import { DevPipeline } from './pipeline.js'; import { handleRequest } from './request.js'; import { setRouteError } from './server-state.js'; +import { fileURLToPath } from 'node:url'; +import { getRoutePrerenderOption } from '../core/routing/manifest/prerender.js'; +import { runHookRoutesResolved } from '../integrations/hooks.js'; export interface AstroPluginOptions { settings: AstroSettings; @@ -50,26 +54,46 @@ export default function createVitePluginAstroServer({ const controller = createController({ loader }); const localStorage = new AsyncLocalStorage(); - /** rebuild the route cache + manifest, as needed. */ - async function rebuildManifest(needsManifestRebuild: boolean) { + /** rebuild the route cache + manifest */ + async function rebuildManifest(path: string | null = null) { pipeline.clearRouteCache(); - if (needsManifestRebuild) { + + // If a route changes, we check if it's part of the manifest and check for its prerender value + if (path !== null) { + const route = routeManifest.routes.find( + (r) => + normalizePath(path) === + normalizePath(fileURLToPath(new URL(r.component, settings.config.root))), + ); + if (!route) { + return; + } + if (route.type !== 'page' && route.type !== 'endpoint') return; + + const routePath = fileURLToPath(new URL(route.component, settings.config.root)); + try { + const content = await fsMod.promises.readFile(routePath, 'utf-8'); + await getRoutePrerenderOption(content, route, settings, logger); + } catch (_) {} + } else { routeManifest = injectDefaultDevRoutes( settings, devSSRManifest, - await createRouteManifest({ settings, fsMod }, logger), // TODO: Handle partial updates to the manifest + await createRouteManifest({ settings, fsMod }, logger, { dev: true }), ); - warnMissingAdapter(logger, settings); - pipeline.manifest.checkOrigin = - settings.config.security.checkOrigin && settings.buildOutput === 'server'; - pipeline.setManifestData(routeManifest); } + await runHookRoutesResolved({ routes: routeManifest.routes, settings, logger }); + + warnMissingAdapter(logger, settings); + pipeline.manifest.checkOrigin = + settings.config.security.checkOrigin && settings.buildOutput === 'server'; + pipeline.setManifestData(routeManifest); } - // Rebuild route manifest on file change, if needed. - viteServer.watcher.on('add', rebuildManifest.bind(null, true)); - viteServer.watcher.on('unlink', rebuildManifest.bind(null, true)); - viteServer.watcher.on('change', rebuildManifest.bind(null, false)); + // Rebuild route manifest on file change + viteServer.watcher.on('add', rebuildManifest.bind(null, null)); + viteServer.watcher.on('unlink', rebuildManifest.bind(null, null)); + viteServer.watcher.on('change', rebuildManifest); function handleUnhandledRejection(rejection: any) { const error = new AstroError({ diff --git a/packages/astro/src/vite-plugin-integrations-container/index.ts b/packages/astro/src/vite-plugin-integrations-container/index.ts index 0af181e39c..81b720aef1 100644 --- a/packages/astro/src/vite-plugin-integrations-container/index.ts +++ b/packages/astro/src/vite-plugin-integrations-container/index.ts @@ -5,7 +5,7 @@ import type { AstroSettings } from '../types/astro.js'; import { normalizePath } from 'vite'; import { runHookServerSetup } from '../integrations/hooks.js'; -import type { InjectedRoute, ResolvedInjectedRoute } from '../types/public/integrations.js'; +import type { InternalInjectedRoute, ResolvedInjectedRoute } from '../types/public/internal.js'; /** Connect Astro integrations into Vite, as needed. */ export default function astroIntegrationsContainerPlugin({ @@ -33,7 +33,7 @@ export default function astroIntegrationsContainerPlugin({ async function resolveEntryPoint( this: PluginContext, - route: InjectedRoute, + route: InternalInjectedRoute, ): Promise { const resolvedId = await this.resolve(route.entrypoint.toString()) .then((res) => res?.id) diff --git a/packages/astro/test/units/integrations/api.test.js b/packages/astro/test/units/integrations/api.test.js index f2365c006b..97da20c193 100644 --- a/packages/astro/test/units/integrations/api.test.js +++ b/packages/astro/test/units/integrations/api.test.js @@ -7,7 +7,7 @@ import { runHookBuildSetup, runHookConfigSetup, } from '../../../dist/integrations/hooks.js'; -import { defaultLogger } from '../test-utils.js'; +import { createFixture, defaultLogger, runInContainer } from '../test-utils.js'; const defaultConfig = { root: new URL('./', import.meta.url), @@ -131,6 +131,221 @@ describe('Integration API', () => { assert.equal(updatedSettings.config.site, site); assert.equal(updatedSettings.config.integrations.length, 2); }); + + describe('Routes resolved hooks', () => { + it('should work in dev', async () => { + let routes = []; + const fixture = await createFixture({ + '/src/pages/about.astro': '', + '/src/actions.ts': 'export const server = {}', + '/src/foo.astro': '', + }); + + await runInContainer( + { + inlineConfig: { + root: fixture.path, + integrations: [ + { + name: 'test', + hooks: { + 'astro:config:setup': (params) => { + params.injectRoute({ + entrypoint: './src/foo.astro', + pattern: '/foo', + }); + }, + 'astro:routes:resolved': (params) => { + routes = params.routes.map((r) => ({ + isPrerendered: r.isPrerendered, + entrypoint: r.entrypoint, + pattern: r.pattern, + params: r.params, + origin: r.origin, + })); + routes.sort((a, b) => a.pattern.localeCompare(b.pattern)); + }, + }, + }, + ], + }, + }, + async (container) => { + assert.deepEqual( + routes, + [ + { + isPrerendered: false, + entrypoint: '_server-islands.astro', + pattern: '/_server-islands/[name]', + params: ['name'], + origin: 'internal', + }, + { + isPrerendered: false, + entrypoint: '../../../../dist/actions/runtime/route.js', + pattern: '/_actions/[...path]', + params: ['...path'], + origin: 'internal', + }, + { + isPrerendered: true, + entrypoint: 'src/pages/about.astro', + pattern: '/about', + params: [], + origin: 'project', + }, + { + isPrerendered: true, + entrypoint: 'src/foo.astro', + pattern: '/foo', + params: [], + origin: 'external', + }, + { + isPrerendered: false, + entrypoint: '../../../../dist/assets/endpoint/node.js', + pattern: '/_image', + params: [], + origin: 'internal', + }, + { + isPrerendered: false, + entrypoint: 'astro-default-404.astro', + pattern: '/404', + params: [], + origin: 'internal', + }, + ].sort((a, b) => a.pattern.localeCompare(b.pattern)), + ); + + await fixture.writeFile('/src/pages/bar.astro', ''); + container.viteServer.watcher.emit( + 'add', + fixture.getPath('/src/pages/bar.astro').replace(/\\/g, '/'), + ); + await new Promise((r) => setTimeout(r, 100)); + + assert.deepEqual( + routes, + [ + { + isPrerendered: false, + entrypoint: '_server-islands.astro', + pattern: '/_server-islands/[name]', + params: ['name'], + origin: 'internal', + }, + { + isPrerendered: false, + entrypoint: '../../../../dist/actions/runtime/route.js', + pattern: '/_actions/[...path]', + params: ['...path'], + origin: 'internal', + }, + { + isPrerendered: true, + entrypoint: 'src/pages/about.astro', + pattern: '/about', + params: [], + origin: 'project', + }, + { + isPrerendered: true, + entrypoint: 'src/pages/bar.astro', + pattern: '/bar', + params: [], + origin: 'project', + }, + { + isPrerendered: true, + entrypoint: 'src/foo.astro', + pattern: '/foo', + params: [], + origin: 'external', + }, + { + isPrerendered: false, + entrypoint: '../../../../dist/assets/endpoint/node.js', + pattern: '/_image', + params: [], + origin: 'internal', + }, + { + isPrerendered: false, + entrypoint: 'astro-default-404.astro', + pattern: '/404', + params: [], + origin: 'internal', + }, + ].sort((a, b) => a.pattern.localeCompare(b.pattern)), + ); + + await fixture.writeFile('/src/pages/about.astro', '---\nexport const prerender=false\n'); + container.viteServer.watcher.emit( + 'change', + fixture.getPath('/src/pages/about.astro').replace(/\\/g, '/'), + ); + await new Promise((r) => setTimeout(r, 100)); + + assert.deepEqual( + routes, + [ + { + isPrerendered: false, + entrypoint: '_server-islands.astro', + pattern: '/_server-islands/[name]', + params: ['name'], + origin: 'internal', + }, + { + isPrerendered: false, + entrypoint: '../../../../dist/actions/runtime/route.js', + pattern: '/_actions/[...path]', + params: ['...path'], + origin: 'internal', + }, + { + isPrerendered: false, + entrypoint: 'src/pages/about.astro', + pattern: '/about', + params: [], + origin: 'project', + }, + { + isPrerendered: true, + entrypoint: 'src/pages/bar.astro', + pattern: '/bar', + params: [], + origin: 'project', + }, + { + isPrerendered: true, + entrypoint: 'src/foo.astro', + pattern: '/foo', + params: [], + origin: 'external', + }, + { + isPrerendered: false, + entrypoint: '../../../../dist/assets/endpoint/node.js', + pattern: '/_image', + params: [], + origin: 'internal', + }, + { + isPrerendered: false, + entrypoint: 'astro-default-404.astro', + pattern: '/404', + params: [], + origin: 'internal', + }, + ].sort((a, b) => a.pattern.localeCompare(b.pattern)), + ); + }, + ); + }); + }); }); describe('Astro feature map', function () { From a9ce785146d78595fb4d52e1d39dc6ed01d04d66 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 21 Nov 2024 04:45:51 -0800 Subject: [PATCH 24/27] [ci] release (beta) (#12430) Co-authored-by: github-actions[bot] --- .changeset/pre.json | 7 + examples/basics/package.json | 2 +- examples/blog/package.json | 2 +- examples/component/package.json | 2 +- examples/container-with-vitest/package.json | 4 +- examples/framework-alpine/package.json | 2 +- examples/framework-multiple/package.json | 12 +- examples/framework-preact/package.json | 4 +- examples/framework-react/package.json | 4 +- examples/framework-solid/package.json | 4 +- examples/framework-svelte/package.json | 4 +- examples/framework-vue/package.json | 4 +- examples/hackernews/package.json | 2 +- examples/integration/package.json | 2 +- examples/minimal/package.json | 2 +- examples/portfolio/package.json | 2 +- examples/ssr/package.json | 4 +- examples/starlog/package.json | 2 +- examples/toolbar-app/package.json | 2 +- examples/with-markdoc/package.json | 2 +- examples/with-mdx/package.json | 4 +- examples/with-nanostores/package.json | 4 +- examples/with-tailwindcss/package.json | 2 +- examples/with-vitest/package.json | 2 +- packages/astro/CHANGELOG.md | 190 ++++++++++++++++++ packages/astro/client.d.ts | 8 +- packages/astro/package.json | 2 +- packages/astro/src/assets/utils/index.ts | 2 +- packages/astro/src/assets/utils/svg.ts | 8 +- .../astro/src/assets/vite-plugin-assets.ts | 6 +- packages/astro/src/core/config/schema.ts | 20 +- .../astro/src/core/routing/manifest/create.ts | 2 +- packages/astro/src/core/sync/index.ts | 10 +- packages/astro/src/types/astro.ts | 2 +- packages/astro/src/types/public/config.ts | 42 ++-- .../src/vite-plugin-astro-server/plugin.ts | 6 +- packages/astro/test/core-image-svg.test.js | 47 ++--- .../test/data-collections-schema.test.js | 2 +- packages/integrations/preact/CHANGELOG.md | 6 + packages/integrations/preact/package.json | 2 +- packages/integrations/react/CHANGELOG.md | 6 + packages/integrations/react/package.json | 2 +- packages/integrations/solid/CHANGELOG.md | 6 + packages/integrations/solid/package.json | 2 +- packages/integrations/svelte/CHANGELOG.md | 9 + packages/integrations/svelte/package.json | 4 +- packages/integrations/vue/CHANGELOG.md | 6 + packages/integrations/vue/package.json | 2 +- pnpm-lock.yaml | 182 ++++++----------- scripts/cmd/build.js | 2 +- 50 files changed, 416 insertions(+), 241 deletions(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index a08df62b1c..fa0e79b5c0 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -34,12 +34,15 @@ "afraid-apricots-buy", "blue-boats-relax", "blue-sloths-stare", + "blue-socks-doubt", "brave-elephants-fly", "breezy-colts-promise", + "brown-bulldogs-share", "chatty-teachers-sit", "chilly-terms-know", "clean-camels-drive", "clean-donuts-walk", + "clean-moles-rest", "cold-bananas-hear", "cool-mangos-shop", "cuddly-shoes-press", @@ -61,6 +64,7 @@ "funny-wolves-dream", "fuzzy-pugs-live", "gentle-scissors-bow", + "giant-ravens-look", "giant-rocks-thank", "gorgeous-foxes-divide", "healthy-ads-scream", @@ -95,6 +99,7 @@ "poor-seals-clap", "pretty-walls-camp", "proud-games-repair", + "proud-terms-swim", "quick-ads-exercise", "quick-onions-leave", "rotten-phones-scream", @@ -110,12 +115,14 @@ "spotty-garlics-cheat", "strange-sheep-film", "strong-months-grab", + "strong-stingrays-provide", "sweet-timers-smash", "tall-waves-impress", "tame-pumpkins-swim", "tame-rats-cross", "ten-students-repair", "ten-walls-tap", + "thirty-clocks-jump", "three-days-cough", "three-olives-reflect", "tough-planets-dress", diff --git a/examples/basics/package.json b/examples/basics/package.json index 7073ff822a..dbedbb0e99 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -10,6 +10,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^5.0.0-beta.8" + "astro": "^5.0.0-beta.9" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 0e13ddef6d..0ae87a1117 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -13,6 +13,6 @@ "@astrojs/mdx": "^4.0.0-beta.3", "@astrojs/rss": "^4.0.9", "@astrojs/sitemap": "^3.2.1", - "astro": "^5.0.0-beta.8" + "astro": "^5.0.0-beta.9" } } diff --git a/examples/component/package.json b/examples/component/package.json index 27c20d0592..df329888a1 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^5.0.0-beta.8" + "astro": "^5.0.0-beta.9" }, "peerDependencies": { "astro": "^4.0.0 || ^5.0.0" diff --git a/examples/container-with-vitest/package.json b/examples/container-with-vitest/package.json index 5cb0084ac1..40a5ad19e7 100644 --- a/examples/container-with-vitest/package.json +++ b/examples/container-with-vitest/package.json @@ -11,8 +11,8 @@ "test": "vitest run" }, "dependencies": { - "astro": "^5.0.0-beta.8", - "@astrojs/react": "^3.6.2", + "astro": "^5.0.0-beta.9", + "@astrojs/react": "^3.6.3-beta.0", "react": "^18.3.1", "react-dom": "^18.3.1", "vitest": "^2.1.4" diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index 698088fcfe..82296fd493 100644 --- a/examples/framework-alpine/package.json +++ b/examples/framework-alpine/package.json @@ -13,6 +13,6 @@ "@astrojs/alpinejs": "^0.4.0", "@types/alpinejs": "^3.13.10", "alpinejs": "^3.14.3", - "astro": "^5.0.0-beta.8" + "astro": "^5.0.0-beta.9" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index bca3430009..8756e8786f 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -10,14 +10,14 @@ "astro": "astro" }, "dependencies": { - "@astrojs/preact": "^3.5.3", - "@astrojs/react": "^3.6.2", - "@astrojs/solid-js": "^4.4.3", - "@astrojs/svelte": "^6.0.0-beta.2", - "@astrojs/vue": "^5.0.0-beta.1", + "@astrojs/preact": "^3.5.4-beta.0", + "@astrojs/react": "^3.6.3-beta.0", + "@astrojs/solid-js": "^4.4.4-beta.0", + "@astrojs/svelte": "^6.0.2-beta.0", + "@astrojs/vue": "^5.0.0-beta.2", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", - "astro": "^5.0.0-beta.8", + "astro": "^5.0.0-beta.9", "preact": "^10.24.3", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index 445c836fcf..6d0e701040 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -10,9 +10,9 @@ "astro": "astro" }, "dependencies": { - "@astrojs/preact": "^3.5.3", + "@astrojs/preact": "^3.5.4-beta.0", "@preact/signals": "^1.3.0", - "astro": "^5.0.0-beta.8", + "astro": "^5.0.0-beta.9", "preact": "^10.24.3" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index b0541cba7c..da22ea8806 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -10,10 +10,10 @@ "astro": "astro" }, "dependencies": { - "@astrojs/react": "^3.6.2", + "@astrojs/react": "^3.6.3-beta.0", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", - "astro": "^5.0.0-beta.8", + "astro": "^5.0.0-beta.9", "react": "^18.3.1", "react-dom": "^18.3.1" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index da283570d9..6eef341613 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -10,8 +10,8 @@ "astro": "astro" }, "dependencies": { - "@astrojs/solid-js": "^4.4.3", - "astro": "^5.0.0-beta.8", + "@astrojs/solid-js": "^4.4.4-beta.0", + "astro": "^5.0.0-beta.9", "solid-js": "^1.9.2" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index 56e22f6be5..22c8b22ba3 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -10,8 +10,8 @@ "astro": "astro" }, "dependencies": { - "@astrojs/svelte": "^6.0.0", - "astro": "^5.0.0-beta.8", + "@astrojs/svelte": "^6.0.2-beta.0", + "astro": "^5.0.0-beta.9", "svelte": "^5.1.16" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index ae8a1403f3..d552611897 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -10,8 +10,8 @@ "astro": "astro" }, "dependencies": { - "@astrojs/vue": "^5.0.0-beta.1", - "astro": "^5.0.0-beta.8", + "@astrojs/vue": "^5.0.0-beta.2", + "astro": "^5.0.0-beta.9", "vue": "^3.5.12" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 71bdd46ea7..04330f9699 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -11,6 +11,6 @@ }, "dependencies": { "@astrojs/node": "^9.0.0-alpha.1", - "astro": "^5.0.0-beta.8" + "astro": "^5.0.0-beta.9" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index b591fedb58..e2c6d1b827 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^5.0.0-beta.8" + "astro": "^5.0.0-beta.9" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/minimal/package.json b/examples/minimal/package.json index f792c9b96a..2fa61a582e 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -10,6 +10,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^5.0.0-beta.8" + "astro": "^5.0.0-beta.9" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index fe41095bdd..54426be0e3 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -10,6 +10,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^5.0.0-beta.8" + "astro": "^5.0.0-beta.9" } } diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 1a468ec123..8d70ee57ce 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -12,8 +12,8 @@ }, "dependencies": { "@astrojs/node": "^9.0.0-alpha.1", - "@astrojs/svelte": "^6.0.0", - "astro": "^5.0.0-beta.8", + "@astrojs/svelte": "^6.0.2-beta.0", + "astro": "^5.0.0-beta.9", "svelte": "^5.1.16" } } diff --git a/examples/starlog/package.json b/examples/starlog/package.json index ffcae20cca..4c45287840 100644 --- a/examples/starlog/package.json +++ b/examples/starlog/package.json @@ -9,7 +9,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^5.0.0-beta.8", + "astro": "^5.0.0-beta.9", "sass": "^1.80.6", "sharp": "^0.33.3" } diff --git a/examples/toolbar-app/package.json b/examples/toolbar-app/package.json index 5b03d6f85e..f2b13f2874 100644 --- a/examples/toolbar-app/package.json +++ b/examples/toolbar-app/package.json @@ -15,6 +15,6 @@ "./app": "./dist/app.js" }, "devDependencies": { - "astro": "^5.0.0-beta.8" + "astro": "^5.0.0-beta.9" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index 9916a48510..2cc4378a65 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -11,6 +11,6 @@ }, "dependencies": { "@astrojs/markdoc": "^0.12.0-beta.0", - "astro": "^5.0.0-beta.8" + "astro": "^5.0.0-beta.9" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index 4642aa9ef4..ab172bc1ee 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -11,8 +11,8 @@ }, "dependencies": { "@astrojs/mdx": "^4.0.0-beta.3", - "@astrojs/preact": "^3.5.3", - "astro": "^5.0.0-beta.8", + "@astrojs/preact": "^3.5.4-beta.0", + "astro": "^5.0.0-beta.9", "preact": "^10.24.3" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 19cd884f95..7ad15fd506 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -10,9 +10,9 @@ "astro": "astro" }, "dependencies": { - "@astrojs/preact": "^3.5.3", + "@astrojs/preact": "^3.5.4-beta.0", "@nanostores/preact": "^0.5.2", - "astro": "^5.0.0-beta.8", + "astro": "^5.0.0-beta.9", "nanostores": "^0.11.3", "preact": "^10.24.3" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index fcfe676f17..dbc2816093 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -13,7 +13,7 @@ "@astrojs/mdx": "^4.0.0-beta.3", "@astrojs/tailwind": "^5.1.2", "@types/canvas-confetti": "^1.6.4", - "astro": "^5.0.0-beta.8", + "astro": "^5.0.0-beta.9", "autoprefixer": "^10.4.20", "canvas-confetti": "^1.9.3", "postcss": "^8.4.47", diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index 24c9cb1b02..c5d1d95295 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -11,7 +11,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^5.0.0-beta.8", + "astro": "^5.0.0-beta.9", "vitest": "^2.1.4" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 178d2d9c1b..c943918115 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,195 @@ # astro +## 5.0.0-beta.9 + +### Minor Changes + +- [#12067](https://github.com/withastro/astro/pull/12067) [`c48916c`](https://github.com/withastro/astro/commit/c48916cc4e6f7c31e3563d04b68a8698d8775b65) Thanks [@stramel](https://github.com/stramel)! - Adds experimental support for built-in SVG components. + + This feature allows you to import SVG files directly into your Astro project as components. By default, Astro will inline the SVG content into your HTML output. + + To enable this feature, set `experimental.svg` to `true` in your Astro config: + + ```js + { + experimental: { + svg: true, + }, + } + ``` + + To use this feature, import an SVG file in your Astro project, passing any common SVG attributes to the imported component. Astro also provides a `size` attribute to set equal `height` and `width` properties: + + ```astro + --- + import Logo from './path/to/svg/file.svg'; + --- + + + ``` + + For a complete overview, and to give feedback on this experimental API, see the [Feature RFC](https://github.com/withastro/roadmap/pull/1035). + +- [#12329](https://github.com/withastro/astro/pull/12329) [`8309c61`](https://github.com/withastro/astro/commit/8309c61f0dfa5991d3f6c5c5fca4403794d6fda2) Thanks [@florian-lefebvre](https://github.com/florian-lefebvre)! - Adds a new `astro:routes:resolved` hook to the Integration API. Also update the `astro:build:done` hook by deprecating `routes` and adding a new `assets` map. + + When building an integration, you can now get access to routes inside the `astro:routes:resolved` hook: + + ```js + const integration = () => { + return { + name: 'my-integration', + hooks: { + 'astro:routes:resolved': ({ routes }) => { + console.log(routes); + }, + }, + }; + }; + ``` + + This hook runs before `astro:config:done`, and whenever a route changes in development. + + The `routes` array from `astro:build:done` is now deprecated, and exposed properties are now available on `astro:routes:resolved`, except for `distURL`. For this, you can use the newly exposed `assets` map: + + ```diff + const integration = () => { + + let routes + return { + name: 'my-integration', + hooks: { + + 'astro:routes:resolved': (params) => { + + routes = params.routes + + }, + 'astro:build:done': ({ + - routes + + assets + }) => { + + for (const route of routes) { + + const distURL = assets.get(route.pattern) + + if (distURL) { + + Object.assign(route, { distURL }) + + } + + } + console.log(routes) + } + } + } + } + ``` + +- [#12377](https://github.com/withastro/astro/pull/12377) [`af867f3`](https://github.com/withastro/astro/commit/af867f3910ecd8fc04a5337f591d84f03192e3fa) Thanks [@ascorbic](https://github.com/ascorbic)! - Adds experimental support for automatic responsive images + + This feature is experimental and may change in future versions. To enable it, set `experimental.responsiveImages` to `true` in your `astro.config.mjs` file. + + ```js title=astro.config.mjs + { + experimental: { + responsiveImages: true, + }, + } + ``` + + When this flag is enabled, you can pass a `layout` prop to any `` or `` component to create a responsive image. When a layout is set, images have automatically generated `srcset` and `sizes` attributes based on the image's dimensions and the layout type. Images with `responsive` and `full-width` layouts will have styles applied to ensure they resize according to their container. + + ```astro + --- + import { Image, Picture } from 'astro:assets'; + import myImage from '../assets/my_image.png'; + --- + + A description of my image. + + ``` + + This `` component will generate the following HTML output: + + ```html title=Output + A description of my image + ``` + + #### Responsive image properties + + These are additional properties available to the `` and `` components when responsive images are enabled: + + - `layout`: The layout type for the image. Can be `responsive`, `fixed`, `full-width` or `none`. Defaults to value of `image.experimentalLayout`. + - `fit`: Defines how the image should be cropped if the aspect ratio is changed. Values match those of CSS `object-fit`. Defaults to `cover`, or the value of `image.experimentalObjectFit` if set. + - `position`: Defines the position of the image crop if the aspect ratio is changed. Values match those of CSS `object-position`. Defaults to `center`, or the value of `image.experimentalObjectPosition` if set. + - `priority`: If set, eagerly loads the image. Otherwise images will be lazy-loaded. Use this for your largest above-the-fold image. Defaults to `false`. + + #### Default responsive image settings + + You can enable responsive images for all `` and `` components by setting `image.experimentalLayout` with a default value. This can be overridden by the `layout` prop on each component. + + **Example:** + + ```js title=astro.config.mjs + { + image: { + // Used for all `` and `` components unless overridden + experimentalLayout: 'responsive', + }, + experimental: { + responsiveImages: true, + }, + } + ``` + + ```astro + --- + import { Image } from 'astro:assets'; + import myImage from '../assets/my_image.png'; + --- + + This will use responsive layout + + This will use full-width layout + + This will disable responsive images + ``` + + For a complete overview, and to give feedback on this experimental API, see the [Responsive Images RFC](https://github.com/withastro/roadmap/blob/responsive-images/proposals/0053-responsive-images.md). + +- [#12475](https://github.com/withastro/astro/pull/12475) [`3f02d5f`](https://github.com/withastro/astro/commit/3f02d5f12b167514fff6eb9693b4e25c668e7a31) Thanks [@ascorbic](https://github.com/ascorbic)! - Changes the default content config location from `src/content/config.*` to `src/content.config.*`. + + The previous location is still supported, and is required if the `legacy.collections` flag is enabled. + +### Patch Changes + +- [#12424](https://github.com/withastro/astro/pull/12424) [`4364bff`](https://github.com/withastro/astro/commit/4364bff27332e52f92da72392620a36110daee42) Thanks [@ematipico](https://github.com/ematipico)! - Fixes an issue where an incorrect usage of Astro actions was lost when porting the fix from v4 to v5 + +- [#12438](https://github.com/withastro/astro/pull/12438) [`c8f877c`](https://github.com/withastro/astro/commit/c8f877cad2d8f1780f70045413872d5b9d32ebed) Thanks [@ascorbic](https://github.com/ascorbic)! - Fixes a bug where legacy content types were generated for content layer collections if they were in the content directory + ## 5.0.0-beta.8 ### Minor Changes diff --git a/packages/astro/client.d.ts b/packages/astro/client.d.ts index f9badff245..0832344b4f 100644 --- a/packages/astro/client.d.ts +++ b/packages/astro/client.d.ts @@ -111,7 +111,7 @@ declare module '*.svg' { type Props = { /** * Accesible, short-text description - * + * * {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Element/title|MDN Reference} */ title?: string; @@ -122,9 +122,9 @@ declare module '*.svg' { /** * Override the default rendering mode for SVGs */ - mode?: import('./dist/assets/utils/svg.js').SvgRenderMode - } & astroHTML.JSX.SVGAttributes - + mode?: import('./dist/assets/utils/svg.js').SvgRenderMode; + } & astroHTML.JSX.SVGAttributes; + const Component: ((_props: Props) => any) & ImageMetadata; export default Component; } diff --git a/packages/astro/package.json b/packages/astro/package.json index 3ca98a18a5..67c68dab2c 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "5.0.0-beta.8", + "version": "5.0.0-beta.9", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", diff --git a/packages/astro/src/assets/utils/index.ts b/packages/astro/src/assets/utils/index.ts index 98044ac9fa..3fae182000 100644 --- a/packages/astro/src/assets/utils/index.ts +++ b/packages/astro/src/assets/utils/index.ts @@ -13,4 +13,4 @@ export { } from './remotePattern.js'; export { hashTransform, propsToFilename } from './transformToPath.js'; export { inferRemoteSize } from './remoteProbe.js'; -export { makeSvgComponent } from './svg.js' +export { makeSvgComponent } from './svg.js'; diff --git a/packages/astro/src/assets/utils/svg.ts b/packages/astro/src/assets/utils/svg.ts index 70088ba64a..6f9c54381c 100644 --- a/packages/astro/src/assets/utils/svg.ts +++ b/packages/astro/src/assets/utils/svg.ts @@ -1,7 +1,7 @@ import { parse, renderSync } from 'ultrahtml'; -import type { ImageMetadata } from '../types.js'; import type { SvgComponentProps } from '../runtime.js'; import { dropAttributes } from '../runtime.js'; +import type { ImageMetadata } from '../types.js'; function parseSvg(contents: string) { const root = parse(contents); @@ -13,7 +13,11 @@ function parseSvg(contents: string) { export type SvgRenderMode = 'inline' | 'sprite'; -export function makeSvgComponent(meta: ImageMetadata, contents: Buffer | string, options?: { mode?: SvgRenderMode }) { +export function makeSvgComponent( + meta: ImageMetadata, + contents: Buffer | string, + options?: { mode?: SvgRenderMode }, +) { const file = typeof contents === 'string' ? contents : contents.toString('utf-8'); const { attributes, body: children } = parseSvg(file); const props: SvgComponentProps = { diff --git a/packages/astro/src/assets/vite-plugin-assets.ts b/packages/astro/src/assets/vite-plugin-assets.ts index 7cb04c1bde..e09fc15975 100644 --- a/packages/astro/src/assets/vite-plugin-assets.ts +++ b/packages/astro/src/assets/vite-plugin-assets.ts @@ -17,8 +17,8 @@ import { getAssetsPrefix } from './utils/getAssetsPrefix.js'; import { isESMImportedImage } from './utils/imageKind.js'; import { emitESMImage } from './utils/node/emitAsset.js'; import { getProxyCode } from './utils/proxy.js'; -import { hashTransform, propsToFilename } from './utils/transformToPath.js'; import { makeSvgComponent } from './utils/svg.js'; +import { hashTransform, propsToFilename } from './utils/transformToPath.js'; const resolvedVirtualModuleId = '\0' + VIRTUAL_MODULE_ID; @@ -217,7 +217,9 @@ export default function assets({ settings }: { settings: AstroSettings }): vite. if (settings.config.experimental.svg && /\.svg$/.test(id)) { const { contents, ...metadata } = imageMetadata; // We know that the contents are present, as we only emit this property for SVG files - return makeSvgComponent(metadata, contents!, { mode: settings.config.experimental.svg.mode }); + return makeSvgComponent(metadata, contents!, { + mode: settings.config.experimental.svg.mode, + }); } // We can only reliably determine if an image is used on the server, as we need to track its usage throughout the entire build. diff --git a/packages/astro/src/core/config/schema.ts b/packages/astro/src/core/config/schema.ts index af3dd82ea4..3ddaf3e0c2 100644 --- a/packages/astro/src/core/config/schema.ts +++ b/packages/astro/src/core/config/schema.ts @@ -537,16 +537,16 @@ export const AstroConfigSchema = z.object({ .boolean() .optional() .default(ASTRO_CONFIG_DEFAULTS.experimental.responsiveImages), - svg: z.union([ - z.boolean(), - z - .object({ - mode: z - .union([z.literal('inline'), z.literal('sprite')]) - .optional() - .default(ASTRO_CONFIG_DEFAULTS.experimental.svg.mode), - }) - ]) + svg: z + .union([ + z.boolean(), + z.object({ + mode: z + .union([z.literal('inline'), z.literal('sprite')]) + .optional() + .default(ASTRO_CONFIG_DEFAULTS.experimental.svg.mode), + }), + ]) .optional() .transform((svgConfig) => { // Handle normalization of `experimental.svg` config boolean values diff --git a/packages/astro/src/core/routing/manifest/create.ts b/packages/astro/src/core/routing/manifest/create.ts index 621164084e..6dbcf18aee 100644 --- a/packages/astro/src/core/routing/manifest/create.ts +++ b/packages/astro/src/core/routing/manifest/create.ts @@ -8,6 +8,7 @@ import { fileURLToPath } from 'node:url'; import { bold } from 'kleur/colors'; import pLimit from 'p-limit'; import { toRoutingStrategy } from '../../../i18n/utils.js'; +import { runHookRoutesResolved } from '../../../integrations/hooks.js'; import { getPrerenderDefault } from '../../../prerender/utils.js'; import type { AstroConfig } from '../../../types/public/config.js'; import type { RouteData, RoutePart } from '../../../types/public/internal.js'; @@ -20,7 +21,6 @@ import { routeComparator } from '../priority.js'; import { getRouteGenerator } from './generator.js'; import { getPattern } from './pattern.js'; import { getRoutePrerenderOption } from './prerender.js'; -import { runHookRoutesResolved } from '../../../integrations/hooks.js'; const require = createRequire(import.meta.url); interface Item { diff --git a/packages/astro/src/core/sync/index.ts b/packages/astro/src/core/sync/index.ts index 832a55b282..67fdccc543 100644 --- a/packages/astro/src/core/sync/index.ts +++ b/packages/astro/src/core/sync/index.ts @@ -253,20 +253,22 @@ async function syncContentCollections( if (isAstroError(e)) { throw e; } - let configFile + let configFile; try { const contentPaths = getContentPaths(settings.config, fs); - if(contentPaths.config.exists) { + if (contentPaths.config.exists) { const matches = /\/(src\/.+)/.exec(contentPaths.config.url.href); if (matches) { - configFile = matches[1] + configFile = matches[1]; } } } catch { // ignore } - const hint = AstroUserError.is(e) ? e.hint : AstroErrorData.GenerateContentTypesError.hint(configFile); + const hint = AstroUserError.is(e) + ? e.hint + : AstroErrorData.GenerateContentTypesError.hint(configFile); throw new AstroError( { ...AstroErrorData.GenerateContentTypesError, diff --git a/packages/astro/src/types/astro.ts b/packages/astro/src/types/astro.ts index 654652c422..1227ed381a 100644 --- a/packages/astro/src/types/astro.ts +++ b/packages/astro/src/types/astro.ts @@ -13,7 +13,7 @@ import type { InjectedScriptStage, InjectedType, } from './public/integrations.js'; -import type { InternalInjectedRoute, RouteData, ResolvedInjectedRoute } from './public/internal.js'; +import type { InternalInjectedRoute, ResolvedInjectedRoute, RouteData } from './public/internal.js'; import type { DevToolbarAppEntry } from './public/toolbar.js'; export type SerializedRouteData = Omit< diff --git a/packages/astro/src/types/public/config.ts b/packages/astro/src/types/public/config.ts index a01dc42cd7..16261cd759 100644 --- a/packages/astro/src/types/public/config.ts +++ b/packages/astro/src/types/public/config.ts @@ -1130,11 +1130,11 @@ export interface ViteUserConfig extends OriginalViteUserConfig { * @name markdown.shikiConfig * @typeraw {Partial} * @description - * - * Shiki is our default syntax highlighter. You can configure all options via the `markdown.shikiConfig` object: - * - * ```js title="astro.config.mjs" - * import { defineConfig } from 'astro/config'; + * + * Shiki is our default syntax highlighter. You can configure all options via the `markdown.shikiConfig` object: + * + * ```js title="astro.config.mjs" + * import { defineConfig } from 'astro/config'; * * export default defineConfig({ * markdown: { @@ -1146,7 +1146,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig { * // See note below for using dual light/dark themes * themes: { * light: 'github-light', - * dark: 'github-dark', + * dark: 'github-dark', * }, * // Disable the default colors * // https://shiki.style/guide/dual-themes#without-default-color @@ -1770,7 +1770,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig { * @name experimental.contentIntellisense * @type {boolean} * @default `false` - * @version 5.x + * @version 5.x * @description * * Enables Intellisense features (e.g. code completion, quick hints) for your content collection entries in compatible editors. @@ -1901,7 +1901,7 @@ export interface ViteUserConfig extends OriginalViteUserConfig { * * The `widths` and `sizes` attributes are automatically generated based on the image's dimensions and the layout type, and in most cases should not be set manually. The generated `sizes` attribute for `responsive` and `full-width` images * is based on the assumption that the image is displayed at close to the full width of the screen when the viewport is smaller than the image's width. If it is significantly different (e.g. if it's in a multi-column layout on small screens) you may need to adjust the `sizes` attribute manually for best results. - * + * * The `densities` attribute is not compatible with responsive images and will be ignored if set. */ @@ -1912,13 +1912,13 @@ export interface ViteUserConfig extends OriginalViteUserConfig { * @name experimental.svg * @type {boolean|object} * @default `undefined` - * @version 5.x + * @version 5.x * @description - * + * * This feature allows you to import SVG files directly into your Astro project. By default, Astro will inline the SVG content into your HTML output. - * + * * To enable this feature, set `experimental.svg` to `true` in your Astro config: - * + * * ```js * { * experimental: { @@ -1926,20 +1926,20 @@ export interface ViteUserConfig extends OriginalViteUserConfig { * }, * } * ``` - * + * * To use this feature, import an SVG file in your Astro project, passing any common SVG attributes to the imported component. * Astro also provides a `size` attribute to set equal `height` and `width` properties: - * + * * ```astro * --- * import Logo from './path/to/svg/file.svg'; * --- - * + * * * ``` - * + * * For a complete overview, and to give feedback on this experimental API, - * see the [Feature RFC](https://github.com/withastro/roadmap/pull/1035). + * see the [Feature RFC](https://github.com/withastro/roadmap/pull/1035). */ svg?: { /** @@ -1947,17 +1947,17 @@ export interface ViteUserConfig extends OriginalViteUserConfig { * @name experimental.svg.mode * @type {string} * @default 'inline' - * + * * The default technique for handling imported SVG files. Astro will inline the SVG content into your HTML output if not specified. - * + * * - `inline`: Astro will inline the SVG content into your HTML output. * - `sprite`: Astro will generate a sprite sheet with all imported SVG files. - * + * * ```astro * --- * import Logo from './path/to/svg/file.svg'; * --- - * + * * * ``` */ diff --git a/packages/astro/src/vite-plugin-astro-server/plugin.ts b/packages/astro/src/vite-plugin-astro-server/plugin.ts index 642565161b..ab90021b32 100644 --- a/packages/astro/src/vite-plugin-astro-server/plugin.ts +++ b/packages/astro/src/vite-plugin-astro-server/plugin.ts @@ -1,6 +1,7 @@ import { AsyncLocalStorage } from 'node:async_hooks'; import type fs from 'node:fs'; import { IncomingMessage } from 'node:http'; +import { fileURLToPath } from 'node:url'; import type * as vite from 'vite'; import { normalizePath } from 'vite'; import type { SSRManifest, SSRManifestI18n } from '../core/app/types.js'; @@ -14,7 +15,9 @@ import { NOOP_MIDDLEWARE_FN } from '../core/middleware/noop-middleware.js'; import { createViteLoader } from '../core/module-loader/index.js'; import { injectDefaultDevRoutes } from '../core/routing/dev-default.js'; import { createRouteManifest } from '../core/routing/index.js'; +import { getRoutePrerenderOption } from '../core/routing/manifest/prerender.js'; import { toFallbackType, toRoutingStrategy } from '../i18n/utils.js'; +import { runHookRoutesResolved } from '../integrations/hooks.js'; import type { AstroSettings, ManifestData } from '../types/astro.js'; import { baseMiddleware } from './base.js'; import { createController } from './controller.js'; @@ -22,9 +25,6 @@ import { recordServerError } from './error.js'; import { DevPipeline } from './pipeline.js'; import { handleRequest } from './request.js'; import { setRouteError } from './server-state.js'; -import { fileURLToPath } from 'node:url'; -import { getRoutePrerenderOption } from '../core/routing/manifest/prerender.js'; -import { runHookRoutesResolved } from '../integrations/hooks.js'; export interface AstroPluginOptions { settings: AstroSettings; diff --git a/packages/astro/test/core-image-svg.test.js b/packages/astro/test/core-image-svg.test.js index d6134aaf77..e346cb6a72 100644 --- a/packages/astro/test/core-image-svg.test.js +++ b/packages/astro/test/core-image-svg.test.js @@ -53,7 +53,7 @@ describe('astro:assets - SVG Components', () => { assert.equal(!!$(this).attr('mode'), false); const $use = $(this).children('use'); assert.equal($use.length, 0); - }) + }); }); it('Adds the tag with the definition', () => { @@ -64,7 +64,7 @@ describe('astro:assets - SVG Components', () => { const $symbol = $svg.children('symbol'); assert.equal($symbol.length, 1); assert.equal($symbol.attr('id').startsWith('a:'), true); - + const $use = $svg.children('use'); assert.equal($use.length, 1); assert.equal($use.attr('href').startsWith('#a:'), true); @@ -78,7 +78,7 @@ describe('astro:assets - SVG Components', () => { const $symbol = $svg.children('symbol'); assert.equal($symbol.length, 0); - const definitionId = $('#definition svg symbol').attr('id') + const definitionId = $('#definition svg symbol').attr('id'); const $use = $svg.children('use'); assert.equal($use.length, 1); assert.equal($use.attr('href').startsWith('#a:'), true); @@ -167,13 +167,13 @@ describe('astro:assets - SVG Components', () => { assert.equal($svg.attr('role'), 'img'); assert.equal(!!$svg.attr('mode'), false); - const $symbol = $svg.children('symbol') + const $symbol = $svg.children('symbol'); assert.equal($symbol.length, 0); - const $use = $svg.children('use') + const $use = $svg.children('use'); assert.equal($use.length, 0); const $path = $svg.children('path'); assert.equal($path.length, 1); - }) + }); it('adds the svg into the document directly', () => { let $svg = $('#inline svg'); assert.equal($svg.length, 1); @@ -183,9 +183,9 @@ describe('astro:assets - SVG Components', () => { assert.equal($svg.attr('role'), 'img'); assert.equal(!!$svg.attr('mode'), false); - const $symbol = $svg.children('symbol') + const $symbol = $svg.children('symbol'); assert.equal($symbol.length, 0); - const $use = $svg.children('use') + const $use = $svg.children('use'); assert.equal($use.length, 0); const $path = $svg.children('path'); assert.equal($path.length, 1); @@ -199,13 +199,13 @@ describe('astro:assets - SVG Components', () => { assert.equal($svg.attr('role'), 'img'); assert.equal(!!$svg.attr('mode'), false); - const $symbol = $svg.children('symbol') + const $symbol = $svg.children('symbol'); assert.equal($symbol.length, 0); - const $use = $svg.children('use') + const $use = $svg.children('use'); assert.equal($use.length, 0); const $path = $svg.children('path'); assert.equal($path.length, 1); - }) + }); it('adds the svg into the document as a sprite, overridding the default', () => { let $svg = $('#definition svg'); assert.equal($svg.length, 1); @@ -215,10 +215,10 @@ describe('astro:assets - SVG Components', () => { assert.equal($svg.attr('role'), 'img'); assert.equal(!!$svg.attr('mode'), false); - let $symbol = $svg.children('symbol') + let $symbol = $svg.children('symbol'); assert.equal($symbol.length, 1); assert.equal(!!$symbol.attr('viewBox'), true); - let $use = $svg.children('use') + let $use = $svg.children('use'); assert.equal($use.length, 1); let $path = $svg.children('path'); assert.equal($path.length, 0); @@ -231,14 +231,14 @@ describe('astro:assets - SVG Components', () => { assert.equal($svg.attr('role'), 'img'); assert.equal(!!$svg.attr('mode'), false); - $symbol = $svg.children('symbol') + $symbol = $svg.children('symbol'); assert.equal($symbol.length, 0); assert.equal(!!$symbol.attr('viewBox'), false); - $use = $svg.children('use') + $use = $svg.children('use'); assert.equal($use.length, 1); $path = $svg.children('path'); assert.equal($path.length, 0); - }) + }); }); describe('title', () => { let $; @@ -255,7 +255,7 @@ describe('astro:assets - SVG Components', () => { const $title = $('#base svg > title'); assert.equal($title.length, 1); - assert.equal($title.text(), 'GitHub Logo') + assert.equal($title.text(), 'GitHub Logo'); }); }); describe('strip', () => { @@ -291,11 +291,11 @@ describe('astro:assets - SVG Components', () => { assert.equal($svg.attr('class'), 'foobar'); assert.equal($svg.attr('data-state'), 'open'); - const $symbol = $svg.children('symbol') + const $symbol = $svg.children('symbol'); assert.equal($symbol.length, 0); - const $use = $svg.children('use') + const $use = $svg.children('use'); assert.equal($use.length, 0); - const $path = $svg.children('path') + const $path = $svg.children('path'); assert.equal($path.length, 1); }); it('allows overriding the role attribute', () => { @@ -337,7 +337,6 @@ describe('astro:assets - SVG Components', () => { useId = $('.two.use svg > use').attr('id'); assert.equal(defId, useId); - // Third SVG $svg = $('.three svg'); assert.equal($svg.length, 1); @@ -372,9 +371,11 @@ describe('astro:assets - SVG Components', () => { const $svg = $('svg'); assert.equal($svg.length, 2); - $svg.each(function() { assert.equal($(this).attr('role'), 'img') }); + $svg.each(function () { + assert.equal($(this).attr('role'), 'img'); + }); - const definitionId = $($svg[0]).children('symbol').attr('id') + const definitionId = $($svg[0]).children('symbol').attr('id'); const $reuse = $($svg[1]); const $symbol = $reuse.children('symbol'); diff --git a/packages/astro/test/data-collections-schema.test.js b/packages/astro/test/data-collections-schema.test.js index 119cf85427..ff405dca47 100644 --- a/packages/astro/test/data-collections-schema.test.js +++ b/packages/astro/test/data-collections-schema.test.js @@ -1,8 +1,8 @@ // @ts-check import assert from 'node:assert/strict'; import { before, describe, it } from 'node:test'; -import { loadFixture } from './test-utils.js'; import { removeDir } from '@astrojs/internal-helpers/fs'; +import { loadFixture } from './test-utils.js'; describe('Content Collections - data collections', () => { let fixture; diff --git a/packages/integrations/preact/CHANGELOG.md b/packages/integrations/preact/CHANGELOG.md index b7138a78d2..1673a84157 100644 --- a/packages/integrations/preact/CHANGELOG.md +++ b/packages/integrations/preact/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/preact +## 3.5.4-beta.0 + +### Patch Changes + +- [#12481](https://github.com/withastro/astro/pull/12481) [`8a46e80`](https://github.com/withastro/astro/commit/8a46e8074d6afb4a23badbd59ed239d526294e8c) Thanks [@marbrex](https://github.com/marbrex)! - Resolve `vite` peer dependency problem for strict package managers like **Yarn in PnP mode**. + ## 3.5.3 ### Patch Changes diff --git a/packages/integrations/preact/package.json b/packages/integrations/preact/package.json index b441bca21a..d039c95ff3 100644 --- a/packages/integrations/preact/package.json +++ b/packages/integrations/preact/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/preact", "description": "Use Preact components within Astro", - "version": "3.5.3", + "version": "3.5.4-beta.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/react/CHANGELOG.md b/packages/integrations/react/CHANGELOG.md index 65eb7056cb..777f6b75ba 100644 --- a/packages/integrations/react/CHANGELOG.md +++ b/packages/integrations/react/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/react +## 3.6.3-beta.0 + +### Patch Changes + +- [#12481](https://github.com/withastro/astro/pull/12481) [`8a46e80`](https://github.com/withastro/astro/commit/8a46e8074d6afb4a23badbd59ed239d526294e8c) Thanks [@marbrex](https://github.com/marbrex)! - Resolve `vite` peer dependency problem for strict package managers like **Yarn in PnP mode**. + ## 3.6.2 ### Patch Changes diff --git a/packages/integrations/react/package.json b/packages/integrations/react/package.json index 0010b7fdf5..1ce3c5032e 100644 --- a/packages/integrations/react/package.json +++ b/packages/integrations/react/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/react", "description": "Use React components within Astro", - "version": "3.6.2", + "version": "3.6.3-beta.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/solid/CHANGELOG.md b/packages/integrations/solid/CHANGELOG.md index 2ded2af1ee..845b016f14 100644 --- a/packages/integrations/solid/CHANGELOG.md +++ b/packages/integrations/solid/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/solid-js +## 4.4.4-beta.0 + +### Patch Changes + +- [#12481](https://github.com/withastro/astro/pull/12481) [`8a46e80`](https://github.com/withastro/astro/commit/8a46e8074d6afb4a23badbd59ed239d526294e8c) Thanks [@marbrex](https://github.com/marbrex)! - Resolve `vite` peer dependency problem for strict package managers like **Yarn in PnP mode**. + ## 4.4.3 ### Patch Changes diff --git a/packages/integrations/solid/package.json b/packages/integrations/solid/package.json index b798a69a0c..f46629d0ff 100644 --- a/packages/integrations/solid/package.json +++ b/packages/integrations/solid/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/solid-js", - "version": "4.4.3", + "version": "4.4.4-beta.0", "description": "Use Solid components within Astro", "type": "module", "types": "./dist/index.d.ts", diff --git a/packages/integrations/svelte/CHANGELOG.md b/packages/integrations/svelte/CHANGELOG.md index 5a8cf53559..f609cdfe05 100644 --- a/packages/integrations/svelte/CHANGELOG.md +++ b/packages/integrations/svelte/CHANGELOG.md @@ -1,5 +1,14 @@ # @astrojs/svelte +## 6.0.2-beta.0 + +### Patch Changes + +- [#12481](https://github.com/withastro/astro/pull/12481) [`8a46e80`](https://github.com/withastro/astro/commit/8a46e8074d6afb4a23badbd59ed239d526294e8c) Thanks [@marbrex](https://github.com/marbrex)! - Resolve `vite` peer dependency problem for strict package managers like **Yarn in PnP mode**. + +- Updated dependencies [[`c48916c`](https://github.com/withastro/astro/commit/c48916cc4e6f7c31e3563d04b68a8698d8775b65), [`4364bff`](https://github.com/withastro/astro/commit/4364bff27332e52f92da72392620a36110daee42), [`c8f877c`](https://github.com/withastro/astro/commit/c8f877cad2d8f1780f70045413872d5b9d32ebed), [`8309c61`](https://github.com/withastro/astro/commit/8309c61f0dfa5991d3f6c5c5fca4403794d6fda2), [`af867f3`](https://github.com/withastro/astro/commit/af867f3910ecd8fc04a5337f591d84f03192e3fa), [`3f02d5f`](https://github.com/withastro/astro/commit/3f02d5f12b167514fff6eb9693b4e25c668e7a31)]: + - astro@5.0.0-beta.9 + ## 6.0.1 ### Patch Changes diff --git a/packages/integrations/svelte/package.json b/packages/integrations/svelte/package.json index e88e6d5e71..2d6aebe34b 100644 --- a/packages/integrations/svelte/package.json +++ b/packages/integrations/svelte/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/svelte", - "version": "6.0.1", + "version": "6.0.2-beta.0", "description": "Use Svelte components within Astro", "type": "module", "types": "./dist/index.d.ts", @@ -49,7 +49,7 @@ "svelte": "^5.1.16" }, "peerDependencies": { - "astro": "^4.0.0", + "astro": "^5.0.0-beta.9", "svelte": "^5.1.16", "typescript": "^5.3.3" }, diff --git a/packages/integrations/vue/CHANGELOG.md b/packages/integrations/vue/CHANGELOG.md index 764f28483d..9763a370e6 100644 --- a/packages/integrations/vue/CHANGELOG.md +++ b/packages/integrations/vue/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/vue +## 5.0.0-beta.2 + +### Patch Changes + +- [#12481](https://github.com/withastro/astro/pull/12481) [`8a46e80`](https://github.com/withastro/astro/commit/8a46e8074d6afb4a23badbd59ed239d526294e8c) Thanks [@marbrex](https://github.com/marbrex)! - Resolve `vite` peer dependency problem for strict package managers like **Yarn in PnP mode**. + ## 5.0.0-beta.1 ### Patch Changes diff --git a/packages/integrations/vue/package.json b/packages/integrations/vue/package.json index 5817fab62d..9b144f83ce 100644 --- a/packages/integrations/vue/package.json +++ b/packages/integrations/vue/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/vue", - "version": "5.0.0-beta.1", + "version": "5.0.0-beta.2", "description": "Use Vue components within Astro", "type": "module", "types": "./dist/index.d.ts", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fd4f684500..860008b248 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -146,7 +146,7 @@ importers: examples/basics: dependencies: astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro examples/blog: @@ -161,22 +161,22 @@ importers: specifier: ^3.2.1 version: link:../../packages/integrations/sitemap astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro examples/component: devDependencies: astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro examples/container-with-vitest: dependencies: '@astrojs/react': - specifier: ^3.6.2 + specifier: ^3.6.3-beta.0 version: link:../../packages/integrations/react astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -207,25 +207,25 @@ importers: specifier: ^3.14.3 version: 3.14.3 astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro examples/framework-multiple: dependencies: '@astrojs/preact': - specifier: ^3.5.3 + specifier: ^3.5.4-beta.0 version: link:../../packages/integrations/preact '@astrojs/react': - specifier: ^3.6.2 + specifier: ^3.6.3-beta.0 version: link:../../packages/integrations/react '@astrojs/solid-js': - specifier: ^4.4.3 + specifier: ^4.4.4-beta.0 version: link:../../packages/integrations/solid '@astrojs/svelte': - specifier: ^6.0.0-beta.2 + specifier: ^6.0.2-beta.0 version: link:../../packages/integrations/svelte '@astrojs/vue': - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/integrations/vue '@types/react': specifier: ^18.3.12 @@ -234,7 +234,7 @@ importers: specifier: ^18.3.1 version: 18.3.1 astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro preact: specifier: ^10.24.3 @@ -258,13 +258,13 @@ importers: examples/framework-preact: dependencies: '@astrojs/preact': - specifier: ^3.5.3 + specifier: ^3.5.4-beta.0 version: link:../../packages/integrations/preact '@preact/signals': specifier: ^1.3.0 version: 1.3.0(preact@10.24.3) astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro preact: specifier: ^10.24.3 @@ -273,7 +273,7 @@ importers: examples/framework-react: dependencies: '@astrojs/react': - specifier: ^3.6.2 + specifier: ^3.6.3-beta.0 version: link:../../packages/integrations/react '@types/react': specifier: ^18.3.12 @@ -282,7 +282,7 @@ importers: specifier: ^18.3.1 version: 18.3.1 astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -294,10 +294,10 @@ importers: examples/framework-solid: dependencies: '@astrojs/solid-js': - specifier: ^4.4.3 + specifier: ^4.4.4-beta.0 version: link:../../packages/integrations/solid astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro solid-js: specifier: ^1.9.2 @@ -306,10 +306,10 @@ importers: examples/framework-svelte: dependencies: '@astrojs/svelte': - specifier: ^6.0.0 + specifier: ^6.0.2-beta.0 version: link:../../packages/integrations/svelte astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro svelte: specifier: ^5.1.16 @@ -318,10 +318,10 @@ importers: examples/framework-vue: dependencies: '@astrojs/vue': - specifier: ^5.0.0-beta.1 + specifier: ^5.0.0-beta.2 version: link:../../packages/integrations/vue astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro vue: specifier: ^3.5.12 @@ -333,25 +333,25 @@ importers: specifier: ^9.0.0-alpha.1 version: 9.0.0-alpha.1(astro@packages+astro) astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro examples/integration: devDependencies: astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro examples/minimal: dependencies: astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro examples/portfolio: dependencies: astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro examples/ssr: @@ -360,10 +360,10 @@ importers: specifier: ^9.0.0-alpha.1 version: 9.0.0-alpha.1(astro@packages+astro) '@astrojs/svelte': - specifier: ^6.0.0 + specifier: ^6.0.2-beta.0 version: link:../../packages/integrations/svelte astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro svelte: specifier: ^5.1.16 @@ -372,7 +372,7 @@ importers: examples/starlog: dependencies: astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro sass: specifier: ^1.80.6 @@ -384,7 +384,7 @@ importers: examples/toolbar-app: devDependencies: astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro examples/with-markdoc: @@ -393,7 +393,7 @@ importers: specifier: ^0.12.0-beta.0 version: link:../../packages/integrations/markdoc astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro examples/with-mdx: @@ -402,10 +402,10 @@ importers: specifier: ^4.0.0-beta.3 version: link:../../packages/integrations/mdx '@astrojs/preact': - specifier: ^3.5.3 + specifier: ^3.5.4-beta.0 version: link:../../packages/integrations/preact astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro preact: specifier: ^10.24.3 @@ -414,13 +414,13 @@ importers: examples/with-nanostores: dependencies: '@astrojs/preact': - specifier: ^3.5.3 + specifier: ^3.5.4-beta.0 version: link:../../packages/integrations/preact '@nanostores/preact': specifier: ^0.5.2 version: 0.5.2(nanostores@0.11.3)(preact@10.24.3) astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro nanostores: specifier: ^0.11.3 @@ -441,7 +441,7 @@ importers: specifier: ^1.6.4 version: 1.6.4 astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro autoprefixer: specifier: ^10.4.20 @@ -459,7 +459,7 @@ importers: examples/with-vitest: dependencies: astro: - specifier: ^5.0.0-beta.8 + specifier: ^5.0.0-beta.9 version: link:../../packages/astro vitest: specifier: ^2.1.4 @@ -4399,7 +4399,7 @@ importers: version: 8.3.4(astro@packages+astro) '@astrojs/react': specifier: ^3.6.2 - version: link:../../../../integrations/react + version: 3.6.2(@types/react-dom@18.3.1)(@types/react@18.3.12)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(vite@6.0.0-beta.6(@types/node@18.19.50)(jiti@1.21.6)(sass@1.81.0)(yaml@2.5.1)) '@types/react': specifier: ^18.3.12 version: 18.3.12 @@ -4490,37 +4490,6 @@ importers: packages/integrations/cloudflare: {} - packages/integrations/lit: - dependencies: - '@lit-labs/ssr': - specifier: ^3.2.2 - version: 3.2.2 - '@lit-labs/ssr-client': - specifier: ^1.1.7 - version: 1.1.7 - '@lit-labs/ssr-dom-shim': - specifier: ^1.2.1 - version: 1.2.1 - parse5: - specifier: ^7.2.1 - version: 7.2.1 - devDependencies: - astro: - specifier: workspace:* - version: link:../../astro - astro-scripts: - specifier: workspace:* - version: link:../../../scripts - cheerio: - specifier: 1.0.0 - version: 1.0.0 - lit: - specifier: ^3.2.1 - version: 3.2.1 - sass: - specifier: ^1.80.6 - version: 1.81.0 - packages/integrations/markdoc: dependencies: '@astrojs/internal-helpers': @@ -5670,6 +5639,15 @@ packages: peerDependencies: astro: ^5.0.0-alpha.0 + '@astrojs/react@3.6.2': + resolution: {integrity: sha512-fK29lYI7zK/KG4ZBy956x4dmauZcZ18osFkuyGa8r3gmmCQa2NZ9XNu9WaVYEUm0j89f4Gii4tbxLoyM8nk2MA==} + engines: {node: ^18.17.1 || ^20.3.0 || >=21.0.0} + peerDependencies: + '@types/react': ^17.0.50 || ^18.0.21 + '@types/react-dom': ^17.0.17 || ^18.0.6 + react: ^17.0.2 || ^18.0.0 || ^19.0.0-beta + react-dom: ^17.0.2 || ^18.0.0 || ^19.0.0-beta + '@astrojs/yaml2ts@0.2.1': resolution: {integrity: sha512-CBaNwDQJz20E5WxzQh4thLVfhB3JEEGz72wRA+oJp6fQR37QLAqXZJU0mHC+yqMOQ6oj0GfRPJrz6hjf+zm6zA==} @@ -6855,16 +6833,9 @@ packages: cpu: [x64] os: [win32] - '@lit-labs/ssr-client@1.1.7': - resolution: {integrity: sha512-VvqhY/iif3FHrlhkzEPsuX/7h/NqnfxLwVf0p8ghNIlKegRyRqgeaJevZ57s/u/LiFyKgqksRP5n+LmNvpxN+A==} - '@lit-labs/ssr-dom-shim@1.2.1': resolution: {integrity: sha512-wx4aBmgeGvFmOKucFKY+8VFJSYZxs9poN3SDNQFF6lT6NrQUnHiPB2PWz2sc4ieEcAaYYzN+1uWahEeTq2aRIQ==} - '@lit-labs/ssr@3.2.2': - resolution: {integrity: sha512-He5TzeNPM9ECmVpgXRYmVlz0UA5YnzHlT43kyLi2Lu6mUidskqJVonk9W5K699+2DKhoXp8Ra4EJmHR6KrcW1Q==} - engines: {node: '>=13.9.0'} - '@lit/reactive-element@2.0.4': resolution: {integrity: sha512-GFn91inaUa2oHLak8awSIigYz0cU0Payr1rcFsrkf5OJ5eSPxElyZfKh0f2p9FsTiZWXQdWGJeXZICEfXXYSXQ==} @@ -6990,9 +6961,6 @@ packages: resolution: {integrity: sha512-HNjmfLQEVRZmHRET336f20H/8kOozUGwk7yajvsonjNxbj2wBTK1WsQuHkD5yYh9RxFGL2EyDHryOihOwUoKDA==} engines: {node: '>= 10.0.0'} - '@parse5/tools@0.3.0': - resolution: {integrity: sha512-zxRyTHkqb7WQMV8kTNBKWb1BeOFUKXBXTBWuxg9H9hfvQB3IwP6Iw2U75Ia5eyRxPNltmY7E8YAlz6zWwUnjKg==} - '@pkgjs/parseargs@0.11.0': resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} engines: {node: '>=14'} @@ -7290,9 +7258,6 @@ packages: '@types/node@12.20.55': resolution: {integrity: sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==} - '@types/node@16.18.119': - resolution: {integrity: sha512-ia7V9a2FnhUFfetng4/sRPBMTwHZUkPFY736rb1cg9AgG7MZdR97q7/nLR9om+sq5f1la9C857E0l/nrI0RiFQ==} - '@types/node@17.0.45': resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==} @@ -8334,10 +8299,6 @@ packages: encoding-sniffer@0.2.0: resolution: {integrity: sha512-ju7Wq1kg04I3HtiYIOrUrdfdDvkyO9s5XM8QAj/bN61Yo/Vb4vgJxy5vi4Yxk01gWHbrofpPtpxM8bKger9jhg==} - enhanced-resolve@5.17.1: - resolution: {integrity: sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==} - engines: {node: '>=10.13.0'} - enquirer@2.4.1: resolution: {integrity: sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==} engines: {node: '>=8.6'} @@ -10637,10 +10598,6 @@ packages: engines: {node: '>=14.0.0'} hasBin: true - tapable@2.2.1: - resolution: {integrity: sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==} - engines: {node: '>=6'} - tar@6.2.1: resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==} engines: {node: '>=10'} @@ -11567,6 +11524,18 @@ snapshots: transitivePeerDependencies: - supports-color + '@astrojs/react@3.6.2(@types/react-dom@18.3.1)(@types/react@18.3.12)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(vite@6.0.0-beta.6(@types/node@18.19.50)(jiti@1.21.6)(sass@1.81.0)(yaml@2.5.1))': + dependencies: + '@types/react': 18.3.12 + '@types/react-dom': 18.3.1 + '@vitejs/plugin-react': 4.3.3(vite@6.0.0-beta.6(@types/node@18.19.50)(jiti@1.21.6)(sass@1.81.0)(yaml@2.5.1)) + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + ultrahtml: 1.5.3 + transitivePeerDependencies: + - supports-color + - vite + '@astrojs/yaml2ts@0.2.1': dependencies: yaml: 2.5.1 @@ -12740,28 +12709,8 @@ snapshots: '@libsql/win32-x64-msvc@0.4.5': optional: true - '@lit-labs/ssr-client@1.1.7': - dependencies: - '@lit/reactive-element': 2.0.4 - lit: 3.2.1 - lit-html: 3.2.0 - '@lit-labs/ssr-dom-shim@1.2.1': {} - '@lit-labs/ssr@3.2.2': - dependencies: - '@lit-labs/ssr-client': 1.1.7 - '@lit-labs/ssr-dom-shim': 1.2.1 - '@lit/reactive-element': 2.0.4 - '@parse5/tools': 0.3.0 - '@types/node': 16.18.119 - enhanced-resolve: 5.17.1 - lit: 3.2.1 - lit-element: 4.1.0 - lit-html: 3.2.0 - node-fetch: 3.3.2 - parse5: 7.2.1 - '@lit/reactive-element@2.0.4': dependencies: '@lit-labs/ssr-dom-shim': 1.2.1 @@ -12896,10 +12845,6 @@ snapshots: '@parcel/watcher-win32-x64': 2.4.1 optional: true - '@parse5/tools@0.3.0': - dependencies: - parse5: 7.2.1 - '@pkgjs/parseargs@0.11.0': optional: true @@ -13186,8 +13131,6 @@ snapshots: '@types/node@12.20.55': {} - '@types/node@16.18.119': {} - '@types/node@17.0.45': {} '@types/node@18.19.50': @@ -14257,11 +14200,6 @@ snapshots: iconv-lite: 0.6.3 whatwg-encoding: 3.1.1 - enhanced-resolve@5.17.1: - dependencies: - graceful-fs: 4.2.11 - tapable: 2.2.1 - enquirer@2.4.1: dependencies: ansi-colors: 4.1.3 @@ -17232,8 +17170,6 @@ snapshots: transitivePeerDependencies: - ts-node - tapable@2.2.1: {} - tar@6.2.1: dependencies: chownr: 2.0.0 diff --git a/scripts/cmd/build.js b/scripts/cmd/build.js index ac1a7b6e85..5de957c5a8 100644 --- a/scripts/cmd/build.js +++ b/scripts/cmd/build.js @@ -73,7 +73,7 @@ export default async function build(...args) { entryPoints, outdir, outExtension: forceCJS ? { '.js': '.cjs' } : {}, - format + format, }); return; } From dc3d842e4c6f3b7e59da8a13447a1450013e10dc Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 21 Nov 2024 08:00:03 -0500 Subject: [PATCH 25/27] Call server island early so it can set headers (#12486) Add changeset Proper fix changeup --- .changeset/rotten-dodos-judge.md | 5 +++++ .../astro/src/core/server-islands/endpoint.ts | 17 +++++++++++++++- .../src/vite-plugin-astro-server/plugin.ts | 4 ++-- .../ssr/src/components/Island.astro | 3 ++- packages/astro/test/server-islands.test.js | 20 +++++++++++++++++++ 5 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 .changeset/rotten-dodos-judge.md diff --git a/.changeset/rotten-dodos-judge.md b/.changeset/rotten-dodos-judge.md new file mode 100644 index 0000000000..cb1cea275e --- /dev/null +++ b/.changeset/rotten-dodos-judge.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Call server island early so it can set headers diff --git a/packages/astro/src/core/server-islands/endpoint.ts b/packages/astro/src/core/server-islands/endpoint.ts index 999826a6f8..cac030409e 100644 --- a/packages/astro/src/core/server-islands/endpoint.ts +++ b/packages/astro/src/core/server-islands/endpoint.ts @@ -4,6 +4,7 @@ import { renderComponent, renderTemplate, } from '../../runtime/server/index.js'; +import { isAstroComponentFactory } from '../../runtime/server/render/astro/factory.js'; import { createSlotValueFromString } from '../../runtime/server/render/slot.js'; import type { ComponentInstance, ManifestData } from '../../types/astro.js'; import type { RouteData, SSRManifest } from '../../types/public/internal.js'; @@ -121,17 +122,31 @@ export function createEndpoint(manifest: SSRManifest) { const key = await manifest.key; const encryptedProps = data.encryptedProps; + const propString = await decryptString(key, encryptedProps); const props = JSON.parse(propString); const componentModule = await imp(); - const Component = (componentModule as any)[data.componentExport]; + let Component = (componentModule as any)[data.componentExport]; const slots: ComponentSlots = {}; for (const prop in data.slots) { slots[prop] = createSlotValueFromString(data.slots[prop]); } + // Wrap Astro components so we can set propagation to + // `self` which is needed to force the runtime to wait + // on the component before sending out the response headers. + // This allows the island to set headers (cookies). + if(isAstroComponentFactory(Component)) { + const ServerIsland = Component; + Component = function(this: typeof ServerIsland, ...args: Parameters) { + return ServerIsland.apply(this, args); + }; + Object.assign(Component, ServerIsland); + Component.propagation = 'self'; + } + return renderTemplate`${renderComponent(result, 'Component', Component, props, slots)}`; }; diff --git a/packages/astro/src/vite-plugin-astro-server/plugin.ts b/packages/astro/src/vite-plugin-astro-server/plugin.ts index ab90021b32..871a123160 100644 --- a/packages/astro/src/vite-plugin-astro-server/plugin.ts +++ b/packages/astro/src/vite-plugin-astro-server/plugin.ts @@ -6,7 +6,7 @@ import type * as vite from 'vite'; import { normalizePath } from 'vite'; import type { SSRManifest, SSRManifestI18n } from '../core/app/types.js'; import { warnMissingAdapter } from '../core/dev/adapter-validation.js'; -import { createKey } from '../core/encryption.js'; +import { createKey, getEnvironmentKey, hasEnvironmentKey } from '../core/encryption.js'; import { getViteErrorPayload } from '../core/errors/dev/index.js'; import { AstroError, AstroErrorData } from '../core/errors/index.js'; import { patchOverlay } from '../core/errors/overlay.js'; @@ -192,7 +192,7 @@ export function createDevelopmentManifest(settings: AstroSettings): SSRManifest checkOrigin: (settings.config.security?.checkOrigin && settings.buildOutput === 'server') ?? false, envGetSecretEnabled: false, - key: createKey(), + key: hasEnvironmentKey() ? getEnvironmentKey() : createKey(), middleware() { return { onRequest: NOOP_MIDDLEWARE_FN, diff --git a/packages/astro/test/fixtures/server-islands/ssr/src/components/Island.astro b/packages/astro/test/fixtures/server-islands/ssr/src/components/Island.astro index 49a5a87ae0..2ed0e02706 100644 --- a/packages/astro/test/fixtures/server-islands/ssr/src/components/Island.astro +++ b/packages/astro/test/fixtures/server-islands/ssr/src/components/Island.astro @@ -1,4 +1,5 @@ --- - +await new Promise(resolve => setTimeout(resolve, 1)); +Astro.response.headers.set('X-Works', 'true'); ---

I'm an island

diff --git a/packages/astro/test/server-islands.test.js b/packages/astro/test/server-islands.test.js index 5055369727..fbc4964b1e 100644 --- a/packages/astro/test/server-islands.test.js +++ b/packages/astro/test/server-islands.test.js @@ -19,11 +19,13 @@ describe('Server islands', () => { let devServer; before(async () => { + process.env.ASTRO_KEY = 'eKBaVEuI7YjfanEXHuJe/pwZKKt3LkAHeMxvTU7aR0M='; devServer = await fixture.startDevServer(); }); after(async () => { await devServer.stop(); + delete process.env.ASTRO_KEY; }); it('omits the islands HTML', async () => { @@ -34,13 +36,31 @@ describe('Server islands', () => { const serverIslandEl = $('h2#island'); assert.equal(serverIslandEl.length, 0); }); + + it('island can set headers', async () => { + const res = await fixture.fetch('/_server-islands/Island', { + method: 'POST', + body: JSON.stringify({ + componentExport: 'default', + encryptedProps: 'FC8337AF072BE5B1641501E1r8mLIhmIME1AV7UO9XmW9OLD', + slots: {}, + }) + }); + const works = res.headers.get('X-Works'); + assert.equal(works, 'true', 'able to set header from server island'); + }); }); describe('prod', () => { before(async () => { + process.env.ASTRO_KEY = 'eKBaVEuI7YjfanEXHuJe/pwZKKt3LkAHeMxvTU7aR0M='; await fixture.build(); }); + after(async () => { + delete process.env.ASTRO_KEY; + }); + it('omits the islands HTML', async () => { const app = await fixture.loadTestAdapterApp(); const request = new Request('http://example.com/'); From 23dc937435e0dc89dee5e74e8870464160efb17c Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 21 Nov 2024 10:51:47 -0500 Subject: [PATCH 26/27] Merge main into next (#12493) * [ci] release (#12490) Co-authored-by: github-actions[bot] * Update solid version * update lockfile * fix vue changelog --------- Co-authored-by: Houston (Bot) <108291165+astrobot-houston@users.noreply.github.com> Co-authored-by: github-actions[bot] --- .changeset/strong-stingrays-provide.md | 9 --------- examples/framework-solid/package.json | 2 +- packages/integrations/preact/CHANGELOG.md | 2 +- packages/integrations/react/CHANGELOG.md | 2 +- packages/integrations/solid/CHANGELOG.md | 2 +- packages/integrations/svelte/CHANGELOG.md | 2 +- packages/integrations/vue/CHANGELOG.md | 12 ++++++------ pnpm-lock.yaml | 13 ++----------- 8 files changed, 13 insertions(+), 31 deletions(-) delete mode 100644 .changeset/strong-stingrays-provide.md diff --git a/.changeset/strong-stingrays-provide.md b/.changeset/strong-stingrays-provide.md deleted file mode 100644 index a98fea0f8d..0000000000 --- a/.changeset/strong-stingrays-provide.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -'@astrojs/solid-js': patch -'@astrojs/vue': patch -'@astrojs/svelte': patch -'@astrojs/react': patch -'@astrojs/preact': patch ---- - -Resolve `vite` peer dependency problem for strict package managers like **Yarn in PnP mode**. diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index 6eef341613..c32d501659 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -12,6 +12,6 @@ "dependencies": { "@astrojs/solid-js": "^4.4.4-beta.0", "astro": "^5.0.0-beta.9", - "solid-js": "^1.9.2" + "solid-js": "^1.9.3" } } diff --git a/packages/integrations/preact/CHANGELOG.md b/packages/integrations/preact/CHANGELOG.md index 1673a84157..e99ca01e38 100644 --- a/packages/integrations/preact/CHANGELOG.md +++ b/packages/integrations/preact/CHANGELOG.md @@ -1,6 +1,6 @@ # @astrojs/preact -## 3.5.4-beta.0 +## 3.5.4 ### Patch Changes diff --git a/packages/integrations/react/CHANGELOG.md b/packages/integrations/react/CHANGELOG.md index 777f6b75ba..45f9ffaebe 100644 --- a/packages/integrations/react/CHANGELOG.md +++ b/packages/integrations/react/CHANGELOG.md @@ -1,6 +1,6 @@ # @astrojs/react -## 3.6.3-beta.0 +## 3.6.3 ### Patch Changes diff --git a/packages/integrations/solid/CHANGELOG.md b/packages/integrations/solid/CHANGELOG.md index 845b016f14..3cca257571 100644 --- a/packages/integrations/solid/CHANGELOG.md +++ b/packages/integrations/solid/CHANGELOG.md @@ -1,6 +1,6 @@ # @astrojs/solid-js -## 4.4.4-beta.0 +## 4.4.4 ### Patch Changes diff --git a/packages/integrations/svelte/CHANGELOG.md b/packages/integrations/svelte/CHANGELOG.md index f609cdfe05..76b1bbff51 100644 --- a/packages/integrations/svelte/CHANGELOG.md +++ b/packages/integrations/svelte/CHANGELOG.md @@ -1,6 +1,6 @@ # @astrojs/svelte -## 6.0.2-beta.0 +## 6.0.2 ### Patch Changes diff --git a/packages/integrations/vue/CHANGELOG.md b/packages/integrations/vue/CHANGELOG.md index 9763a370e6..71f28ed6c9 100644 --- a/packages/integrations/vue/CHANGELOG.md +++ b/packages/integrations/vue/CHANGELOG.md @@ -1,11 +1,5 @@ # @astrojs/vue -## 5.0.0-beta.2 - -### Patch Changes - -- [#12481](https://github.com/withastro/astro/pull/12481) [`8a46e80`](https://github.com/withastro/astro/commit/8a46e8074d6afb4a23badbd59ed239d526294e8c) Thanks [@marbrex](https://github.com/marbrex)! - Resolve `vite` peer dependency problem for strict package managers like **Yarn in PnP mode**. - ## 5.0.0-beta.1 ### Patch Changes @@ -25,6 +19,12 @@ - Updated dependencies [[`b6fbdaa`](https://github.com/withastro/astro/commit/b6fbdaa94a9ecec706a99e1938fbf5cd028c72e0), [`89bab1e`](https://github.com/withastro/astro/commit/89bab1e70786123fbe933a9d7a1b80c9334dcc5f), [`d74617c`](https://github.com/withastro/astro/commit/d74617cbd3278feba05909ec83db2d73d57a153e), [`e90f559`](https://github.com/withastro/astro/commit/e90f5593d23043579611452a84b9e18ad2407ef9), [`2df49a6`](https://github.com/withastro/astro/commit/2df49a6fb4f6d92fe45f7429430abe63defeacd6), [`8a53517`](https://github.com/withastro/astro/commit/8a5351737d6a14fc55f1dafad8f3b04079e81af6)]: - astro@5.0.0-alpha.0 +## 4.5.3 + +### Patch Changes + +- [#12481](https://github.com/withastro/astro/pull/12481) [`8a46e80`](https://github.com/withastro/astro/commit/8a46e8074d6afb4a23badbd59ed239d526294e8c) Thanks [@marbrex](https://github.com/marbrex)! - Resolve `vite` peer dependency problem for strict package managers like **Yarn in PnP mode**. + ## 4.5.2 ### Patch Changes diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 860008b248..8aa11a36d2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -300,8 +300,8 @@ importers: specifier: ^5.0.0-beta.9 version: link:../../packages/astro solid-js: - specifier: ^1.9.2 - version: 1.9.2 + specifier: ^1.9.3 + version: 1.9.3 examples/framework-svelte: dependencies: @@ -10433,9 +10433,6 @@ packages: resolution: {integrity: sha512-TzobUYoEft/xBtb2voRPryAUIvYguG0V7Tt3de79I1WfXgCwelqVsGuZSnu3GFGRZhXR90AeEYIM+icuB/S06Q==} hasBin: true - solid-js@1.9.2: - resolution: {integrity: sha512-fe/K03nV+kMFJYhAOE8AIQHcGxB4rMIEoEyrulbtmf217NffbbwBqJnJI4ovt16e+kaIt0czE2WA7mP/pYN9yg==} - solid-js@1.9.3: resolution: {integrity: sha512-5ba3taPoZGt9GY3YlsCB24kCg0Lv/rie/HTD4kG6h4daZZz7+yK02xn8Vx8dLYBc9i6Ps5JwAbEiqjmKaLB3Ag==} @@ -16964,12 +16961,6 @@ snapshots: smartypants@0.2.2: {} - solid-js@1.9.2: - dependencies: - csstype: 3.1.3 - seroval: 1.1.1 - seroval-plugins: 1.1.1(seroval@1.1.1) - solid-js@1.9.3: dependencies: csstype: 3.1.3 From 10beb174e5d0a2747f3a30289f42782892d0dbd5 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 21 Nov 2024 08:12:29 -0800 Subject: [PATCH 27/27] [ci] release (beta) (#12491) Co-authored-by: github-actions[bot] --- .changeset/pre.json | 2 +- examples/basics/package.json | 2 +- examples/blog/package.json | 2 +- examples/component/package.json | 2 +- examples/container-with-vitest/package.json | 2 +- examples/framework-alpine/package.json | 2 +- examples/framework-multiple/package.json | 2 +- examples/framework-preact/package.json | 2 +- examples/framework-react/package.json | 2 +- examples/framework-solid/package.json | 2 +- examples/framework-svelte/package.json | 2 +- examples/framework-vue/package.json | 2 +- examples/hackernews/package.json | 2 +- examples/integration/package.json | 2 +- examples/minimal/package.json | 2 +- examples/portfolio/package.json | 2 +- examples/ssr/package.json | 2 +- examples/starlog/package.json | 2 +- examples/toolbar-app/package.json | 2 +- examples/with-markdoc/package.json | 2 +- examples/with-mdx/package.json | 2 +- examples/with-nanostores/package.json | 2 +- examples/with-tailwindcss/package.json | 2 +- examples/with-vitest/package.json | 2 +- packages/astro/CHANGELOG.md | 6 +++ packages/astro/package.json | 2 +- .../astro/src/core/server-islands/endpoint.ts | 4 +- packages/astro/test/server-islands.test.js | 8 ++-- pnpm-lock.yaml | 46 +++++++++---------- 29 files changed, 60 insertions(+), 54 deletions(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index fa0e79b5c0..f49826835c 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -102,6 +102,7 @@ "proud-terms-swim", "quick-ads-exercise", "quick-onions-leave", + "rotten-dodos-judge", "rotten-phones-scream", "selfish-cats-crash", "selfish-impalas-grin", @@ -115,7 +116,6 @@ "spotty-garlics-cheat", "strange-sheep-film", "strong-months-grab", - "strong-stingrays-provide", "sweet-timers-smash", "tall-waves-impress", "tame-pumpkins-swim", diff --git a/examples/basics/package.json b/examples/basics/package.json index dbedbb0e99..10076e7c54 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -10,6 +10,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^5.0.0-beta.9" + "astro": "^5.0.0-beta.10" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 0ae87a1117..55c4c8e974 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -13,6 +13,6 @@ "@astrojs/mdx": "^4.0.0-beta.3", "@astrojs/rss": "^4.0.9", "@astrojs/sitemap": "^3.2.1", - "astro": "^5.0.0-beta.9" + "astro": "^5.0.0-beta.10" } } diff --git a/examples/component/package.json b/examples/component/package.json index df329888a1..e7d389c998 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^5.0.0-beta.9" + "astro": "^5.0.0-beta.10" }, "peerDependencies": { "astro": "^4.0.0 || ^5.0.0" diff --git a/examples/container-with-vitest/package.json b/examples/container-with-vitest/package.json index 40a5ad19e7..0bf514bab3 100644 --- a/examples/container-with-vitest/package.json +++ b/examples/container-with-vitest/package.json @@ -11,7 +11,7 @@ "test": "vitest run" }, "dependencies": { - "astro": "^5.0.0-beta.9", + "astro": "^5.0.0-beta.10", "@astrojs/react": "^3.6.3-beta.0", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index 82296fd493..3e293ee029 100644 --- a/examples/framework-alpine/package.json +++ b/examples/framework-alpine/package.json @@ -13,6 +13,6 @@ "@astrojs/alpinejs": "^0.4.0", "@types/alpinejs": "^3.13.10", "alpinejs": "^3.14.3", - "astro": "^5.0.0-beta.9" + "astro": "^5.0.0-beta.10" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index 8756e8786f..2dd01dfdf4 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -17,7 +17,7 @@ "@astrojs/vue": "^5.0.0-beta.2", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", - "astro": "^5.0.0-beta.9", + "astro": "^5.0.0-beta.10", "preact": "^10.24.3", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index 6d0e701040..71005811f6 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -12,7 +12,7 @@ "dependencies": { "@astrojs/preact": "^3.5.4-beta.0", "@preact/signals": "^1.3.0", - "astro": "^5.0.0-beta.9", + "astro": "^5.0.0-beta.10", "preact": "^10.24.3" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index da22ea8806..2c1d587d40 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -13,7 +13,7 @@ "@astrojs/react": "^3.6.3-beta.0", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", - "astro": "^5.0.0-beta.9", + "astro": "^5.0.0-beta.10", "react": "^18.3.1", "react-dom": "^18.3.1" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index c32d501659..a77744ba75 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "@astrojs/solid-js": "^4.4.4-beta.0", - "astro": "^5.0.0-beta.9", + "astro": "^5.0.0-beta.10", "solid-js": "^1.9.3" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index 22c8b22ba3..b6ad5c83f6 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "@astrojs/svelte": "^6.0.2-beta.0", - "astro": "^5.0.0-beta.9", + "astro": "^5.0.0-beta.10", "svelte": "^5.1.16" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index d552611897..cd31147fac 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "@astrojs/vue": "^5.0.0-beta.2", - "astro": "^5.0.0-beta.9", + "astro": "^5.0.0-beta.10", "vue": "^3.5.12" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 04330f9699..1b0a167ae3 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -11,6 +11,6 @@ }, "dependencies": { "@astrojs/node": "^9.0.0-alpha.1", - "astro": "^5.0.0-beta.9" + "astro": "^5.0.0-beta.10" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index e2c6d1b827..f6a938729c 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^5.0.0-beta.9" + "astro": "^5.0.0-beta.10" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/minimal/package.json b/examples/minimal/package.json index 2fa61a582e..ede3198ce8 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -10,6 +10,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^5.0.0-beta.9" + "astro": "^5.0.0-beta.10" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index 54426be0e3..c57436a3a7 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -10,6 +10,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^5.0.0-beta.9" + "astro": "^5.0.0-beta.10" } } diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 8d70ee57ce..be337e5e44 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/node": "^9.0.0-alpha.1", "@astrojs/svelte": "^6.0.2-beta.0", - "astro": "^5.0.0-beta.9", + "astro": "^5.0.0-beta.10", "svelte": "^5.1.16" } } diff --git a/examples/starlog/package.json b/examples/starlog/package.json index 4c45287840..3c0188e1a9 100644 --- a/examples/starlog/package.json +++ b/examples/starlog/package.json @@ -9,7 +9,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^5.0.0-beta.9", + "astro": "^5.0.0-beta.10", "sass": "^1.80.6", "sharp": "^0.33.3" } diff --git a/examples/toolbar-app/package.json b/examples/toolbar-app/package.json index f2b13f2874..636be71faa 100644 --- a/examples/toolbar-app/package.json +++ b/examples/toolbar-app/package.json @@ -15,6 +15,6 @@ "./app": "./dist/app.js" }, "devDependencies": { - "astro": "^5.0.0-beta.9" + "astro": "^5.0.0-beta.10" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index 2cc4378a65..3203a63909 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -11,6 +11,6 @@ }, "dependencies": { "@astrojs/markdoc": "^0.12.0-beta.0", - "astro": "^5.0.0-beta.9" + "astro": "^5.0.0-beta.10" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index ab172bc1ee..b2b3071c47 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -12,7 +12,7 @@ "dependencies": { "@astrojs/mdx": "^4.0.0-beta.3", "@astrojs/preact": "^3.5.4-beta.0", - "astro": "^5.0.0-beta.9", + "astro": "^5.0.0-beta.10", "preact": "^10.24.3" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 7ad15fd506..80cd73b77b 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -12,7 +12,7 @@ "dependencies": { "@astrojs/preact": "^3.5.4-beta.0", "@nanostores/preact": "^0.5.2", - "astro": "^5.0.0-beta.9", + "astro": "^5.0.0-beta.10", "nanostores": "^0.11.3", "preact": "^10.24.3" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index dbc2816093..4e5049ceae 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -13,7 +13,7 @@ "@astrojs/mdx": "^4.0.0-beta.3", "@astrojs/tailwind": "^5.1.2", "@types/canvas-confetti": "^1.6.4", - "astro": "^5.0.0-beta.9", + "astro": "^5.0.0-beta.10", "autoprefixer": "^10.4.20", "canvas-confetti": "^1.9.3", "postcss": "^8.4.47", diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index c5d1d95295..912bbbf300 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -11,7 +11,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^5.0.0-beta.9", + "astro": "^5.0.0-beta.10", "vitest": "^2.1.4" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index c943918115..0781972458 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,11 @@ # astro +## 5.0.0-beta.10 + +### Patch Changes + +- [#12486](https://github.com/withastro/astro/pull/12486) [`dc3d842`](https://github.com/withastro/astro/commit/dc3d842e4c6f3b7e59da8a13447a1450013e10dc) Thanks [@matthewp](https://github.com/matthewp)! - Call server island early so it can set headers + ## 5.0.0-beta.9 ### Minor Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index 67c68dab2c..9a4b4e10e3 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "5.0.0-beta.9", + "version": "5.0.0-beta.10", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", diff --git a/packages/astro/src/core/server-islands/endpoint.ts b/packages/astro/src/core/server-islands/endpoint.ts index cac030409e..ca24b54af4 100644 --- a/packages/astro/src/core/server-islands/endpoint.ts +++ b/packages/astro/src/core/server-islands/endpoint.ts @@ -138,9 +138,9 @@ export function createEndpoint(manifest: SSRManifest) { // `self` which is needed to force the runtime to wait // on the component before sending out the response headers. // This allows the island to set headers (cookies). - if(isAstroComponentFactory(Component)) { + if (isAstroComponentFactory(Component)) { const ServerIsland = Component; - Component = function(this: typeof ServerIsland, ...args: Parameters) { + Component = function (this: typeof ServerIsland, ...args: Parameters) { return ServerIsland.apply(this, args); }; Object.assign(Component, ServerIsland); diff --git a/packages/astro/test/server-islands.test.js b/packages/astro/test/server-islands.test.js index fbc4964b1e..913650a950 100644 --- a/packages/astro/test/server-islands.test.js +++ b/packages/astro/test/server-islands.test.js @@ -41,10 +41,10 @@ describe('Server islands', () => { const res = await fixture.fetch('/_server-islands/Island', { method: 'POST', body: JSON.stringify({ - componentExport: 'default', - encryptedProps: 'FC8337AF072BE5B1641501E1r8mLIhmIME1AV7UO9XmW9OLD', - slots: {}, - }) + componentExport: 'default', + encryptedProps: 'FC8337AF072BE5B1641501E1r8mLIhmIME1AV7UO9XmW9OLD', + slots: {}, + }), }); const works = res.headers.get('X-Works'); assert.equal(works, 'true', 'able to set header from server island'); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8aa11a36d2..7ccb9f0bfa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -146,7 +146,7 @@ importers: examples/basics: dependencies: astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro examples/blog: @@ -161,13 +161,13 @@ importers: specifier: ^3.2.1 version: link:../../packages/integrations/sitemap astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro examples/component: devDependencies: astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro examples/container-with-vitest: @@ -176,7 +176,7 @@ importers: specifier: ^3.6.3-beta.0 version: link:../../packages/integrations/react astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -207,7 +207,7 @@ importers: specifier: ^3.14.3 version: 3.14.3 astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro examples/framework-multiple: @@ -234,7 +234,7 @@ importers: specifier: ^18.3.1 version: 18.3.1 astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro preact: specifier: ^10.24.3 @@ -264,7 +264,7 @@ importers: specifier: ^1.3.0 version: 1.3.0(preact@10.24.3) astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro preact: specifier: ^10.24.3 @@ -282,7 +282,7 @@ importers: specifier: ^18.3.1 version: 18.3.1 astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -297,7 +297,7 @@ importers: specifier: ^4.4.4-beta.0 version: link:../../packages/integrations/solid astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro solid-js: specifier: ^1.9.3 @@ -309,7 +309,7 @@ importers: specifier: ^6.0.2-beta.0 version: link:../../packages/integrations/svelte astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro svelte: specifier: ^5.1.16 @@ -321,7 +321,7 @@ importers: specifier: ^5.0.0-beta.2 version: link:../../packages/integrations/vue astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro vue: specifier: ^3.5.12 @@ -333,25 +333,25 @@ importers: specifier: ^9.0.0-alpha.1 version: 9.0.0-alpha.1(astro@packages+astro) astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro examples/integration: devDependencies: astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro examples/minimal: dependencies: astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro examples/portfolio: dependencies: astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro examples/ssr: @@ -363,7 +363,7 @@ importers: specifier: ^6.0.2-beta.0 version: link:../../packages/integrations/svelte astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro svelte: specifier: ^5.1.16 @@ -372,7 +372,7 @@ importers: examples/starlog: dependencies: astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro sass: specifier: ^1.80.6 @@ -384,7 +384,7 @@ importers: examples/toolbar-app: devDependencies: astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro examples/with-markdoc: @@ -393,7 +393,7 @@ importers: specifier: ^0.12.0-beta.0 version: link:../../packages/integrations/markdoc astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro examples/with-mdx: @@ -405,7 +405,7 @@ importers: specifier: ^3.5.4-beta.0 version: link:../../packages/integrations/preact astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro preact: specifier: ^10.24.3 @@ -420,7 +420,7 @@ importers: specifier: ^0.5.2 version: 0.5.2(nanostores@0.11.3)(preact@10.24.3) astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro nanostores: specifier: ^0.11.3 @@ -441,7 +441,7 @@ importers: specifier: ^1.6.4 version: 1.6.4 astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro autoprefixer: specifier: ^10.4.20 @@ -459,7 +459,7 @@ importers: examples/with-vitest: dependencies: astro: - specifier: ^5.0.0-beta.9 + specifier: ^5.0.0-beta.10 version: link:../../packages/astro vitest: specifier: ^2.1.4