diff --git a/.changeset/fair-points-raise.md b/.changeset/fair-points-raise.md new file mode 100644 index 000000000000..aab0298e9d1a --- /dev/null +++ b/.changeset/fair-points-raise.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Avoid a `MaxListenersExceededWarning` during `astro dev` startup by increasing the shared Vite watcher listener limit when attaching content server listeners. diff --git a/.changeset/few-houses-dance.md b/.changeset/few-houses-dance.md new file mode 100644 index 000000000000..d0bf72bde5c0 --- /dev/null +++ b/.changeset/few-houses-dance.md @@ -0,0 +1,5 @@ +--- +'@astrojs/preact': patch +--- + +Fix `useId()` collisions across multiple Astro islands by seeding a unique per-island root mask for Preact SSR and hydration. diff --git a/.changeset/fix-dev-toolbar-optimize-deps.md b/.changeset/fix-dev-toolbar-optimize-deps.md deleted file mode 100644 index 04247b08995d..000000000000 --- a/.changeset/fix-dev-toolbar-optimize-deps.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Prebundle `astro/toolbar` in dev when custom dev toolbar apps are registered, preventing re-optimization reloads that can hide or break the toolbar. diff --git a/.changeset/fix-i18n-redirect-double-slash.md b/.changeset/fix-i18n-redirect-double-slash.md deleted file mode 100644 index 170a821ea40f..000000000000 --- a/.changeset/fix-i18n-redirect-double-slash.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes `redirectToDefaultLocale` producing a protocol-relative URL (`//locale`) instead of an absolute path (`/locale`) when `base` is `'/'`. diff --git a/.changeset/fix-server-islands-prerender.md b/.changeset/fix-server-islands-prerender.md deleted file mode 100644 index fe2c1142fc1d..000000000000 --- a/.changeset/fix-server-islands-prerender.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes server islands (`server:defer`) not working when only used in prerendered pages with `output: 'server'`. diff --git a/.changeset/new-routes-dev-css.md b/.changeset/new-routes-dev-css.md deleted file mode 100644 index 46b7cfbbe188..000000000000 --- a/.changeset/new-routes-dev-css.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fix a dev server bug where newly created pages could miss layout-imported CSS until restart. diff --git a/.changeset/quiet-trains-accept.md b/.changeset/quiet-trains-accept.md deleted file mode 100644 index c523779ced59..000000000000 --- a/.changeset/quiet-trains-accept.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/cloudflare': patch ---- - -Prebundle additional Astro runtime dependencies for Cloudflare development server, speeding up initial start time and preventing required restarts. diff --git a/.changeset/sparkly-peas-mix.md b/.changeset/sparkly-peas-mix.md deleted file mode 100644 index a50932f638be..000000000000 --- a/.changeset/sparkly-peas-mix.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/cloudflare': patch ---- - -Fixes images not working in dev mode when using the `cloudflare` option diff --git a/.changeset/swift-terms-lose.md b/.changeset/swift-terms-lose.md deleted file mode 100644 index 7e47a712e74f..000000000000 --- a/.changeset/swift-terms-lose.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes a warning when using `prefetchAll` diff --git a/.changeset/tame-phones-run.md b/.changeset/tame-phones-run.md new file mode 100644 index 000000000000..138ab8c741bf --- /dev/null +++ b/.changeset/tame-phones-run.md @@ -0,0 +1,5 @@ +--- +'@astrojs/check': patch +--- + +Fixes Astro not being able to find astro check sometimes diff --git a/.changeset/tricky-otters-go.md b/.changeset/tricky-otters-go.md deleted file mode 100644 index 923730522e83..000000000000 --- a/.changeset/tricky-otters-go.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes a bug where a directory at the project root sharing the same name as a page route would cause the dev server to return a 404 instead of serving the page. diff --git a/.changeset/wise-cats-check.md b/.changeset/wise-cats-check.md deleted file mode 100644 index 560fddeb3f07..000000000000 --- a/.changeset/wise-cats-check.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Update the unknown file extension error hint to recommend `vite.resolve.noExternal`, which is the correct Vite 7 config key. diff --git a/.changeset/wise-turkeys-tan.md b/.changeset/wise-turkeys-tan.md deleted file mode 100644 index dfc33b50020b..000000000000 --- a/.changeset/wise-turkeys-tan.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@astrojs/netlify': patch -'@astrojs/node': patch ---- - -Fixes an issue where the adapter would cause a series of warnings during the build. diff --git a/examples/basics/package.json b/examples/basics/package.json index 048ddf3aa22d..f088a3ecf20b 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -13,6 +13,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^6.0.3" + "astro": "^6.0.4" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index bc93678d5a2c..aa255b1411b5 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -16,7 +16,7 @@ "@astrojs/mdx": "^5.0.0", "@astrojs/rss": "^4.0.17", "@astrojs/sitemap": "^3.7.1", - "astro": "^6.0.3", + "astro": "^6.0.4", "sharp": "^0.34.3" } } diff --git a/examples/component/package.json b/examples/component/package.json index 5e7a39d238fd..f23dea398e4d 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -18,7 +18,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^6.0.3" + "astro": "^6.0.4" }, "peerDependencies": { "astro": "^5.0.0 || ^6.0.0" diff --git a/examples/container-with-vitest/package.json b/examples/container-with-vitest/package.json index 04d93ad3cd8f..4679f4ae7ba1 100644 --- a/examples/container-with-vitest/package.json +++ b/examples/container-with-vitest/package.json @@ -15,7 +15,7 @@ }, "dependencies": { "@astrojs/react": "^5.0.0", - "astro": "^6.0.3", + "astro": "^6.0.4", "react": "^18.3.1", "react-dom": "^18.3.1", "vitest": "^3.2.4" diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index 26fa2c98f665..669279fb0ad4 100644 --- a/examples/framework-alpine/package.json +++ b/examples/framework-alpine/package.json @@ -16,6 +16,6 @@ "@astrojs/alpinejs": "^0.5.0", "@types/alpinejs": "^3.13.11", "alpinejs": "^3.15.8", - "astro": "^6.0.3" + "astro": "^6.0.4" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index 843134b2119f..fe4ccf8e8c73 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -20,7 +20,7 @@ "@astrojs/vue": "^6.0.0", "@types/react": "^18.3.28", "@types/react-dom": "^18.3.7", - "astro": "^6.0.3", + "astro": "^6.0.4", "preact": "^10.28.4", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index e070e795aa06..5a814ae159ed 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -15,7 +15,7 @@ "dependencies": { "@astrojs/preact": "^5.0.0", "@preact/signals": "^2.8.1", - "astro": "^6.0.3", + "astro": "^6.0.4", "preact": "^10.28.4" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index 065f84981fb0..e1fdf588ec20 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -16,7 +16,7 @@ "@astrojs/react": "^5.0.0", "@types/react": "^18.3.28", "@types/react-dom": "^18.3.7", - "astro": "^6.0.3", + "astro": "^6.0.4", "react": "^18.3.1", "react-dom": "^18.3.1" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index 1b6543d6f9a6..26d3231ab462 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -14,7 +14,7 @@ }, "dependencies": { "@astrojs/solid-js": "^6.0.0", - "astro": "^6.0.3", + "astro": "^6.0.4", "solid-js": "^1.9.11" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index 55540a70c823..9d2439dc39b4 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -14,7 +14,7 @@ }, "dependencies": { "@astrojs/svelte": "^8.0.0", - "astro": "^6.0.3", + "astro": "^6.0.4", "svelte": "^5.53.5" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index 4901916bbf56..2882907ec483 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -14,7 +14,7 @@ }, "dependencies": { "@astrojs/vue": "^6.0.0", - "astro": "^6.0.3", + "astro": "^6.0.4", "vue": "^3.5.29" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 90d1088fa71f..0ace824df9ba 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -13,7 +13,7 @@ "astro": "astro" }, "dependencies": { - "@astrojs/node": "^10.0.0", - "astro": "^6.0.3" + "@astrojs/node": "^10.0.1", + "astro": "^6.0.4" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index a3cb1a73533c..71847c80e03a 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -18,7 +18,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^6.0.3" + "astro": "^6.0.4" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/minimal/package.json b/examples/minimal/package.json index 46bc9cb45aad..75bbb46ed22c 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -13,6 +13,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^6.0.3" + "astro": "^6.0.4" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index f6ef17cdeb2f..3c11a0c0bd83 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -13,6 +13,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^6.0.3" + "astro": "^6.0.4" } } diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 43f4af177cfd..026ed8ba93ca 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -14,9 +14,9 @@ "server": "node dist/server/entry.mjs" }, "dependencies": { - "@astrojs/node": "^10.0.0", + "@astrojs/node": "^10.0.1", "@astrojs/svelte": "^8.0.0", - "astro": "^6.0.3", + "astro": "^6.0.4", "svelte": "^5.53.5" } } diff --git a/examples/starlog/package.json b/examples/starlog/package.json index dfbc1c6b3ebd..89754a55da07 100644 --- a/examples/starlog/package.json +++ b/examples/starlog/package.json @@ -9,7 +9,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^6.0.3", + "astro": "^6.0.4", "sass": "^1.97.3", "sharp": "^0.34.3" }, diff --git a/examples/toolbar-app/package.json b/examples/toolbar-app/package.json index 85c304d3798c..74229754e697 100644 --- a/examples/toolbar-app/package.json +++ b/examples/toolbar-app/package.json @@ -16,7 +16,7 @@ }, "devDependencies": { "@types/node": "^18.17.8", - "astro": "^6.0.3" + "astro": "^6.0.4" }, "engines": { "node": ">=22.12.0" diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index ab8b7d2db922..2fa47df5dafd 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -14,6 +14,6 @@ }, "dependencies": { "@astrojs/markdoc": "^1.0.0", - "astro": "^6.0.3" + "astro": "^6.0.4" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index fe3a86495b2e..8b1b5c2bde1c 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -15,7 +15,7 @@ "dependencies": { "@astrojs/mdx": "^5.0.0", "@astrojs/preact": "^5.0.0", - "astro": "^6.0.3", + "astro": "^6.0.4", "preact": "^10.28.4" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 3c18a953b0dc..bc5ae95ffdd4 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -15,7 +15,7 @@ "dependencies": { "@astrojs/preact": "^5.0.0", "@nanostores/preact": "^1.0.0", - "astro": "^6.0.3", + "astro": "^6.0.4", "nanostores": "^1.1.1", "preact": "^10.28.4" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index af203918d9c2..d0f49fac0d2f 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -16,7 +16,7 @@ "@astrojs/mdx": "^5.0.0", "@tailwindcss/vite": "^4.2.1", "@types/canvas-confetti": "^1.9.0", - "astro": "^6.0.3", + "astro": "^6.0.4", "canvas-confetti": "^1.9.4", "tailwindcss": "^4.2.1" } diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index 0354f295c730..ff1167715ca3 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -14,7 +14,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^6.0.3", + "astro": "^6.0.4", "vitest": "^3.2.4" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 73feeba6630d..95ad8a961879 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,23 @@ # astro +## 6.0.4 + +### Patch Changes + +- [#15870](https://github.com/withastro/astro/pull/15870) [`920f10b`](https://github.com/withastro/astro/commit/920f10bb3a49da8355967df99c32c43cc9f53b46) Thanks [@matthewp](https://github.com/matthewp)! - Prebundle `astro/toolbar` in dev when custom dev toolbar apps are registered, preventing re-optimization reloads that can hide or break the toolbar. + +- [#15876](https://github.com/withastro/astro/pull/15876) [`f47ac53`](https://github.com/withastro/astro/commit/f47ac5352dcb36daa64ec12b7d4ac193045d10e3) Thanks [@ematipico](https://github.com/ematipico)! - Fixes `redirectToDefaultLocale` producing a protocol-relative URL (`//locale`) instead of an absolute path (`/locale`) when `base` is `'/'`. + +- [#15767](https://github.com/withastro/astro/pull/15767) [`e0042f7`](https://github.com/withastro/astro/commit/e0042f720274d8763907c1d429723192a71d6932) Thanks [@matthewp](https://github.com/matthewp)! - Fixes server islands (`server:defer`) not working when only used in prerendered pages with `output: 'server'`. + +- [#15873](https://github.com/withastro/astro/pull/15873) [`35841ed`](https://github.com/withastro/astro/commit/35841ed273581a567cd726bb2d14d2ed3886bed0) Thanks [@matthewp](https://github.com/matthewp)! - Fix a dev server bug where newly created pages could miss layout-imported CSS until restart. + +- [#15874](https://github.com/withastro/astro/pull/15874) [`ce0669d`](https://github.com/withastro/astro/commit/ce0669d68115c5e2d00238f3e780a2af50f5be11) Thanks [@ematipico](https://github.com/ematipico)! - Fixes a warning when using `prefetchAll` + +- [#15754](https://github.com/withastro/astro/pull/15754) [`58f1d63`](https://github.com/withastro/astro/commit/58f1d63cbcdd351d80cc65ceff4cb1a8d1aa1853) Thanks [@rururux](https://github.com/rururux)! - Fixes a bug where a directory at the project root sharing the same name as a page route would cause the dev server to return a 404 instead of serving the page. + +- [#15869](https://github.com/withastro/astro/pull/15869) [`76b3a5e`](https://github.com/withastro/astro/commit/76b3a5e4bb1e9f2855d4169602295d601d7e7436) Thanks [@matthewp](https://github.com/matthewp)! - Update the unknown file extension error hint to recommend `vite.resolve.noExternal`, which is the correct Vite 7 config key. + ## 6.0.3 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index c0f613f06a4c..6611099a177d 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "6.0.3", + "version": "6.0.4", "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/content/server-listeners.ts b/packages/astro/src/content/server-listeners.ts index 8bae846dddd1..ec6df1e270a3 100644 --- a/packages/astro/src/content/server-listeners.ts +++ b/packages/astro/src/content/server-listeners.ts @@ -18,6 +18,13 @@ export async function attachContentServerListeners({ logger, settings, }: ContentServerListenerParams) { + // The default max listeners is 10, which is easy to exceed in dev when + // integrations and internal features all subscribe to the same watcher. + const maxListeners = viteServer.watcher.getMaxListeners(); + if (maxListeners !== 0 && maxListeners < 50) { + viteServer.watcher.setMaxListeners(50); + } + const contentGenerator = await createContentTypesGenerator({ fs, settings, diff --git a/packages/astro/test/fixtures/preact-component/src/components/UseId.jsx b/packages/astro/test/fixtures/preact-component/src/components/UseId.jsx new file mode 100644 index 000000000000..c61675a68b16 --- /dev/null +++ b/packages/astro/test/fixtures/preact-component/src/components/UseId.jsx @@ -0,0 +1,13 @@ +import { h } from 'preact'; +import { useId } from 'preact/hooks'; + +export default function UseId() { + const id = useId(); + + return ( +
+ + +
+ ); +} diff --git a/packages/astro/test/fixtures/preact-component/src/pages/use-id.astro b/packages/astro/test/fixtures/preact-component/src/pages/use-id.astro new file mode 100644 index 000000000000..980506e95dab --- /dev/null +++ b/packages/astro/test/fixtures/preact-component/src/pages/use-id.astro @@ -0,0 +1,14 @@ +--- +import UseId from '../components/UseId.jsx'; +--- + + + + Preact useId + + + + + + + diff --git a/packages/astro/test/preact-component.test.js b/packages/astro/test/preact-component.test.js index 221245b1c334..c668e1fe60fd 100644 --- a/packages/astro/test/preact-component.test.js +++ b/packages/astro/test/preact-component.test.js @@ -46,6 +46,27 @@ describe('Preact component', () => { assert.equal($('#world').length, 1); }); + it('Can generate unique useId values across islands', async () => { + const html = await fixture.readFile('/use-id/index.html'); + const $ = cheerio.load(html); + + const useIdInputs = $('.use-id-component input'); + assert.equal(useIdInputs.length, 2); + + const firstInputId = $(useIdInputs[0]).attr('id'); + const secondInputId = $(useIdInputs[1]).attr('id'); + assert.notEqual(firstInputId, undefined); + assert.notEqual(secondInputId, undefined); + assert.notEqual(firstInputId, secondInputId); + + const islands = $('astro-island'); + const firstIslandId = $(islands[0]).attr('data-preact-island-id'); + const secondIslandId = $(islands[1]).attr('data-preact-island-id'); + assert.notEqual(firstIslandId, undefined); + assert.notEqual(secondIslandId, undefined); + assert.notEqual(firstIslandId, secondIslandId); + }); + it('Can export a Fragment', async () => { const html = await fixture.readFile('/frag/index.html'); const $ = cheerio.load(html); diff --git a/packages/astro/test/units/content-collections/frontmatter.test.js b/packages/astro/test/units/content-collections/frontmatter.test.js index 098f013c65e7..5db1ede09532 100644 --- a/packages/astro/test/units/content-collections/frontmatter.test.js +++ b/packages/astro/test/units/content-collections/frontmatter.test.js @@ -1,10 +1,11 @@ +import * as assert from 'node:assert/strict'; import { describe, it } from 'node:test'; import { attachContentServerListeners } from '../../../dist/content/index.js'; import { createFixture, runInContainer } from '../test-utils.js'; describe('frontmatter', () => { - it('errors in content/ does not crash server', async () => { - const fixture = await createFixture({ + async function createContentFixture() { + return await createFixture({ '/src/content/posts/blog.md': `\ --- title: One @@ -35,6 +36,10 @@ describe('frontmatter', () => { `, }); + } + + it('errors in content/ does not crash server', async () => { + const fixture = await createContentFixture(); await runInContainer({ inlineConfig: { root: fixture.path } }, async (container) => { await attachContentServerListeners(container); @@ -52,4 +57,17 @@ describe('frontmatter', () => { // Note, if we got here, it didn't crash }); }); + + it('increases watcher max listeners to avoid startup warnings', async () => { + const fixture = await createContentFixture(); + + await runInContainer({ inlineConfig: { root: fixture.path } }, async (container) => { + const watcher = container.viteServer.watcher; + watcher.setMaxListeners(10); + + await attachContentServerListeners(container); + + assert.equal(watcher.getMaxListeners(), 50); + }); + }); }); diff --git a/packages/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index b72378afe7f2..edf7d85600f9 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,16 @@ # @astrojs/cloudflare +## 13.1.1 + +### Patch Changes + +- [#15815](https://github.com/withastro/astro/pull/15815) [`d1872ee`](https://github.com/withastro/astro/commit/d1872ee6456e4a8ed821ee2b357465a116690be1) Thanks [@matthewp](https://github.com/matthewp)! - Prebundle additional Astro runtime dependencies for Cloudflare development server, speeding up initial start time and preventing required restarts. + +- [#15872](https://github.com/withastro/astro/pull/15872) [`3b47b89`](https://github.com/withastro/astro/commit/3b47b898ebc587251d2674e7fae2e6bcc86c7809) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Fixes images not working in dev mode when using the `cloudflare` option + +- Updated dependencies []: + - @astrojs/underscore-redirects@1.0.1 + ## 13.1.0 ### Minor Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index e8e92fb381a9..f5f0eaae21c6 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/cloudflare", "description": "Deploy your site to Cloudflare Workers", - "version": "13.1.0", + "version": "13.1.1", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/netlify/CHANGELOG.md b/packages/integrations/netlify/CHANGELOG.md index bdbd19f17944..3d3406a60305 100644 --- a/packages/integrations/netlify/CHANGELOG.md +++ b/packages/integrations/netlify/CHANGELOG.md @@ -1,5 +1,14 @@ # @astrojs/netlify +## 7.0.2 + +### Patch Changes + +- [#15868](https://github.com/withastro/astro/pull/15868) [`bb2b8f5`](https://github.com/withastro/astro/commit/bb2b8f5cd3c9f3140b4bb0fb5a1d4c62b41883b8) Thanks [@ematipico](https://github.com/ematipico)! - Fixes an issue where the adapter would cause a series of warnings during the build. + +- Updated dependencies []: + - @astrojs/underscore-redirects@1.0.1 + ## 7.0.1 ### Patch Changes diff --git a/packages/integrations/netlify/package.json b/packages/integrations/netlify/package.json index 0f42e3b22430..a9c7a7cac4b8 100644 --- a/packages/integrations/netlify/package.json +++ b/packages/integrations/netlify/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/netlify", "description": "Deploy your site to Netlify", - "version": "7.0.1", + "version": "7.0.2", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/node/CHANGELOG.md b/packages/integrations/node/CHANGELOG.md index cb196bbae323..7476cf961d84 100644 --- a/packages/integrations/node/CHANGELOG.md +++ b/packages/integrations/node/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/node +## 10.0.1 + +### Patch Changes + +- [#15868](https://github.com/withastro/astro/pull/15868) [`bb2b8f5`](https://github.com/withastro/astro/commit/bb2b8f5cd3c9f3140b4bb0fb5a1d4c62b41883b8) Thanks [@ematipico](https://github.com/ematipico)! - Fixes an issue where the adapter would cause a series of warnings during the build. + ## 10.0.0 ### Major Changes diff --git a/packages/integrations/node/package.json b/packages/integrations/node/package.json index 84126b923722..5a2a5e13e319 100644 --- a/packages/integrations/node/package.json +++ b/packages/integrations/node/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/node", "description": "Deploy your site to a Node.js server", - "version": "10.0.0", + "version": "10.0.1", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/preact/src/client.ts b/packages/integrations/preact/src/client.ts index 2eae30d28b47..11fe1a9337fa 100644 --- a/packages/integrations/preact/src/client.ts +++ b/packages/integrations/preact/src/client.ts @@ -4,6 +4,30 @@ import type { SignalLike } from './types.js'; const sharedSignalMap = new Map(); +type MaskId = number | string; + +function getIslandMaskId(element: HTMLElement): MaskId | null { + const islandId = element.getAttribute('data-preact-island-id'); + if (islandId !== null) { + const parsed = Number.parseInt(islandId, 10); + if (!Number.isNaN(parsed)) { + return parsed; + } + } + + return element.getAttribute('uid'); +} + +function setVNodeMask(child: any, maskId: MaskId) { + // Keep hydration/client-only behavior aligned with SSR by seeding the same + // internal root mask that Preact's useId reads (`_mask`/`__m`). + // Without this, each island root can start from the same default and collide. + // Tracked upstream: https://github.com/preactjs/preact/issues/3781 + const mask: [MaskId, number] = [maskId, 0]; + child._mask = mask; + child.__m = mask; +} + export default (element: HTMLElement) => async ( Component: any, @@ -54,6 +78,10 @@ export default (element: HTMLElement) => props, children != null ? h(StaticHtml, { value: children }) : children, ); + const islandMaskId = getIslandMaskId(element); + if (islandMaskId !== null) { + setVNodeMask(child, islandMaskId); + } if (client === 'only') { element.innerHTML = ''; diff --git a/packages/integrations/preact/src/context.ts b/packages/integrations/preact/src/context.ts index 4d2398d288af..a08f13293fa9 100644 --- a/packages/integrations/preact/src/context.ts +++ b/packages/integrations/preact/src/context.ts @@ -3,6 +3,7 @@ import type { PropNameToSignalMap, RendererContext, SignalLike } from './types.j export type Context = { id: string; c: number; + islandCount: number; signals: Map; propsToSignals: Map, PropNameToSignalMap>; }; @@ -15,6 +16,7 @@ export function getContext(result: RendererContext['result']): Context { } let ctx = { c: 0, + islandCount: 0, get id() { return 'p' + this.c.toString(); }, @@ -30,3 +32,9 @@ export function incrementId(ctx: Context): string { ctx.c++; return id; } + +export function incrementIslandId(ctx: Context): number { + const islandId = ctx.islandCount; + ctx.islandCount++; + return islandId; +} diff --git a/packages/integrations/preact/src/server.ts b/packages/integrations/preact/src/server.ts index 35252a528404..2b98fea9b10b 100644 --- a/packages/integrations/preact/src/server.ts +++ b/packages/integrations/preact/src/server.ts @@ -2,7 +2,7 @@ import type { AstroComponentMetadata, NamedSSRLoadedRendererValue } from 'astro' import opts from 'astro:preact:opts'; import { Component as BaseComponent, h, type VNode } from 'preact'; import { renderToStringAsync } from 'preact-render-to-string'; -import { getContext } from './context.js'; +import { getContext, incrementIslandId } from './context.js'; import { restoreSignalsOnProps, serializeSignals } from './signals.js'; import StaticHtml from './static-html.js'; import type { AstroPreactAttrs, RendererContext } from './types.js'; @@ -15,6 +15,15 @@ let consoleFilterRefs = 0; const filter = opts?.include || opts?.exclude ? createFilter(opts.include, opts.exclude) : null; +function setVNodeMask(vNode: VNode, mask: [number, number]) { + // Preact's useId derives IDs from an internal root vnode mask (`_mask`/`__m`). + // Astro renders each island as a separate root, so without seeding a unique + // mask per island, multiple islands can generate colliding IDs. + // Tracked upstream: https://github.com/preactjs/preact/issues/3781 + (vNode as VNode & { _mask?: [number, number]; __m?: [number, number] })._mask = mask; + (vNode as VNode & { _mask?: [number, number]; __m?: [number, number] }).__m = mask; +} + async function check( this: RendererContext, Component: any, @@ -84,6 +93,8 @@ async function renderToStaticMarkup( const attrs: AstroPreactAttrs = {}; serializeSignals(ctx, props, attrs, propsMap); + const islandId = incrementIslandId(ctx); + attrs['data-preact-island-id'] = islandId.toString(); const vNode: VNode = h( Component, @@ -95,6 +106,7 @@ async function renderToStaticMarkup( }) : children, ); + setVNodeMask(vNode, [islandId, 0]); const html = await renderToStringAsync(vNode); return { attrs, html }; diff --git a/packages/integrations/preact/src/types.ts b/packages/integrations/preact/src/types.ts index 29a2f44c223f..7841df8e0e18 100644 --- a/packages/integrations/preact/src/types.ts +++ b/packages/integrations/preact/src/types.ts @@ -17,6 +17,7 @@ export type PropNameToSignalMap = Map