From c7157e69774a1c9eb685285ca21f1cf78f3551c2 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Thu, 28 May 2026 02:56:53 -0700 Subject: [PATCH 1/4] [ci] release (#16870) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .changeset/afraid-sheep-end.md | 5 - .changeset/blue-olives-rule.md | 5 - .changeset/cloudflare-preserve-build-dirs.md | 18 --- .../cloudflare-preview-remote-bindings.md | 5 - .changeset/cloudflare-static-buildoutput.md | 5 - .changeset/funky-peas-exist.md | 5 - .changeset/great-clocks-judge.md | 5 - .changeset/icy-days-sneeze.md | 5 - .../internal-helpers-markdown-modules.md | 5 - .changeset/markdoc-drop-markdown-remark.md | 5 - .changeset/markdown-processor.md | 73 ----------- .changeset/markdown-satteri.md | 24 ---- .changeset/mdx-satteri-support.md | 46 ------- .changeset/silly-coins-wash.md | 45 ------- .changeset/two-views-clean.md | 5 - examples/advanced-routing/package.json | 4 +- examples/basics/package.json | 2 +- examples/blog/package.json | 4 +- examples/component/package.json | 2 +- examples/container-with-vitest/package.json | 4 +- examples/framework-alpine/package.json | 2 +- examples/framework-multiple/package.json | 6 +- examples/framework-preact/package.json | 4 +- examples/framework-react/package.json | 4 +- examples/framework-solid/package.json | 2 +- examples/framework-svelte/package.json | 2 +- examples/framework-vue/package.json | 2 +- examples/hackernews/package.json | 4 +- 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 | 4 +- examples/with-mdx/package.json | 6 +- examples/with-nanostores/package.json | 4 +- examples/with-tailwindcss/package.json | 4 +- examples/with-vitest/package.json | 2 +- packages/astro/CHANGELOG.md | 105 +++++++++++++++ packages/astro/package.json | 2 +- packages/integrations/cloudflare/CHANGELOG.md | 56 ++++++++ packages/integrations/cloudflare/package.json | 2 +- packages/integrations/markdoc/CHANGELOG.md | 9 ++ packages/integrations/markdoc/package.json | 2 +- packages/integrations/mdx/CHANGELOG.md | 124 ++++++++++++++++++ packages/integrations/mdx/package.json | 2 +- packages/integrations/netlify/CHANGELOG.md | 8 ++ packages/integrations/netlify/package.json | 2 +- packages/integrations/node/CHANGELOG.md | 7 + packages/integrations/node/package.json | 2 +- packages/integrations/preact/CHANGELOG.md | 7 + packages/integrations/preact/package.json | 2 +- packages/integrations/react/CHANGELOG.md | 7 + packages/integrations/react/package.json | 2 +- packages/integrations/vercel/CHANGELOG.md | 7 + packages/integrations/vercel/package.json | 2 +- packages/internal-helpers/CHANGELOG.md | 6 + packages/internal-helpers/package.json | 2 +- packages/markdown/remark/CHANGELOG.md | 77 +++++++++++ packages/markdown/remark/package.json | 2 +- packages/markdown/satteri/CHANGELOG.md | 31 +++++ packages/markdown/satteri/package.json | 2 +- pnpm-lock.yaml | 76 +++++------ 64 files changed, 532 insertions(+), 344 deletions(-) delete mode 100644 .changeset/afraid-sheep-end.md delete mode 100644 .changeset/blue-olives-rule.md delete mode 100644 .changeset/cloudflare-preserve-build-dirs.md delete mode 100644 .changeset/cloudflare-preview-remote-bindings.md delete mode 100644 .changeset/cloudflare-static-buildoutput.md delete mode 100644 .changeset/funky-peas-exist.md delete mode 100644 .changeset/great-clocks-judge.md delete mode 100644 .changeset/icy-days-sneeze.md delete mode 100644 .changeset/internal-helpers-markdown-modules.md delete mode 100644 .changeset/markdoc-drop-markdown-remark.md delete mode 100644 .changeset/markdown-processor.md delete mode 100644 .changeset/markdown-satteri.md delete mode 100644 .changeset/mdx-satteri-support.md delete mode 100644 .changeset/silly-coins-wash.md delete mode 100644 .changeset/two-views-clean.md create mode 100644 packages/markdown/satteri/CHANGELOG.md diff --git a/.changeset/afraid-sheep-end.md b/.changeset/afraid-sheep-end.md deleted file mode 100644 index 5d970c40f6f8..000000000000 --- a/.changeset/afraid-sheep-end.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Skips the static preview server when an adapter provides its own `previewEntrypoint`, allowing the adapter to handle both static and dynamic routes diff --git a/.changeset/blue-olives-rule.md b/.changeset/blue-olives-rule.md deleted file mode 100644 index a83fd52351a7..000000000000 --- a/.changeset/blue-olives-rule.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes `X-Forwarded-Host` and `X-Forwarded-Proto` headers being ignored when set in a custom `src/app.ts` fetch handler before creating `FetchState` diff --git a/.changeset/cloudflare-preserve-build-dirs.md b/.changeset/cloudflare-preserve-build-dirs.md deleted file mode 100644 index f922ee13a9c7..000000000000 --- a/.changeset/cloudflare-preserve-build-dirs.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -'astro': minor ---- - -Adds a new `preserveBuildServerDir` adapter feature - -Adapters can now set `preserveBuildServerDir: true` in their adapter features to keep the `dist/server/` directory structure for static builds, mirroring the existing `preserveBuildClientDir` option. This is useful for adapters that require a consistent `dist/client/` and `dist/server/` layout regardless of build output type. - -```js -setAdapter({ - name: 'my-adapter', - adapterFeatures: { - buildOutput, - preserveBuildClientDir: true, - preserveBuildServerDir: true, - }, -}); -``` diff --git a/.changeset/cloudflare-preview-remote-bindings.md b/.changeset/cloudflare-preview-remote-bindings.md deleted file mode 100644 index fb3f5ae176e7..000000000000 --- a/.changeset/cloudflare-preview-remote-bindings.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/cloudflare': patch ---- - -Fixes user options passed to `cloudflare({...})` (`remoteBindings`, `inspectorPort`, `persistState`, `configPath`, `auxiliaryWorkers`) being silently ignored during `astro preview`. The adapter now resolves the full `@cloudflare/vite-plugin` config once at integration setup time and reuses that single resolved value across the dev/build plugin, the prerenderer's preview server, and the `astro preview` entrypoint, so user options can no longer be dropped at one of the call sites. diff --git a/.changeset/cloudflare-static-buildoutput.md b/.changeset/cloudflare-static-buildoutput.md deleted file mode 100644 index 6afb2b6f5a63..000000000000 --- a/.changeset/cloudflare-static-buildoutput.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/cloudflare': patch ---- - -Fixes static Cloudflare builds with server islands or image endpoints that failed at preview time due to mismatched output directories. diff --git a/.changeset/funky-peas-exist.md b/.changeset/funky-peas-exist.md deleted file mode 100644 index 078a0d08b65c..000000000000 --- a/.changeset/funky-peas-exist.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes the static preview server to respect `preserveBuildClientDir`, serving files from `build.client` instead of `outDir` when the adapter requires it diff --git a/.changeset/great-clocks-judge.md b/.changeset/great-clocks-judge.md deleted file mode 100644 index 388b858ea882..000000000000 --- a/.changeset/great-clocks-judge.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes a race condition where the Vite dep optimizer could lose React dependencies in dev mode when using Astro Actions diff --git a/.changeset/icy-days-sneeze.md b/.changeset/icy-days-sneeze.md deleted file mode 100644 index d386c0adf7f5..000000000000 --- a/.changeset/icy-days-sneeze.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Exempts internal routes (e.g. server islands) from `getStaticPaths()` validation, fixing server island rendering on static sites diff --git a/.changeset/internal-helpers-markdown-modules.md b/.changeset/internal-helpers-markdown-modules.md deleted file mode 100644 index 76917f5a26cf..000000000000 --- a/.changeset/internal-helpers-markdown-modules.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/internal-helpers': minor ---- - -Adds `markdown`, `frontmatter`, and `shiki` helper modules, shared by Astro's content pipeline. diff --git a/.changeset/markdoc-drop-markdown-remark.md b/.changeset/markdoc-drop-markdown-remark.md deleted file mode 100644 index 1fbb0f394afc..000000000000 --- a/.changeset/markdoc-drop-markdown-remark.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/markdoc': patch ---- - -Removes `@astrojs/markdown-remark` from `@astrojs/markdoc`'s dependencies in favour of Astro's internal markdown utilities now that Astro's Markdown support is processor agnostic. diff --git a/.changeset/markdown-processor.md b/.changeset/markdown-processor.md deleted file mode 100644 index 621be35a538c..000000000000 --- a/.changeset/markdown-processor.md +++ /dev/null @@ -1,73 +0,0 @@ ---- -'astro': minor -'@astrojs/mdx': major -'@astrojs/markdown-remark': minor ---- - -Adds a new `markdown.processor` configuration option, allowing you to choose an alternative Markdown processor. - -Websites with many Markdown/MDX files tend to be slow to build because the unified ecosystem (e.g., remark, rehype) is slow to process. This feature introduces the ability to replace this part of the build pipeline with another processor. - -The default processor is `unified()`. This means that existing configurations remain unchanged and your remark/rehype plugins continue to work. - -```js -// astro.config.mjs -import { defineConfig } from 'astro/config'; -import { unified } from '@astrojs/markdown-remark'; -import remarkToc from 'remark-toc'; - -export default defineConfig({ - markdown: { - processor: unified({ - remarkPlugins: [remarkToc], - }), - }, -}); -``` - -In addition to this new configuration option, Astro provides a new alternative processor based on Rust: [Sätteri](https://satteri.bruits.org/). You can choose to use it now by installing `@astrojs/markdown-satteri`, importing the `satteri()` processor, and adapting your existing configuration: - -```js -// astro.config.mjs -import { defineConfig } from 'astro/config'; -import { satteri } from '@astrojs/markdown-satteri'; - -export default defineConfig({ - markdown: { - processor: satteri({ - features: { directive: true }, - }), - }, -}); -``` - -This processor does not support the remark and rehype plugins. This means you may need to convert them to [MDAST or HAST plugins](https://satteri.bruits.org/docs/plugins/) to retain your current functionality. - -The existing top-level `markdown.remarkPlugins`, `markdown.rehypePlugins`, `markdown.remarkRehype`, `markdown.gfm`, and `markdown.smartypants` options still work, but are now deprecated and will be removed in a future major update. The matching `remarkPlugins`, `rehypePlugins`, and `remarkRehype` options on the MDX integration are also deprecated for the same reason. To anticipate their removal, move them onto `unified({...})` (or your preferred plugin processor) : - -```diff -// astro.config.mjs -import { defineConfig } from 'astro/config'; -import remarkToc from 'remark-toc'; -import rehypeSlug from 'rehype-slug'; -+ import { unified } from '@astrojs/markdown-remark'; - -export default defineConfig({ - markdown: { -+ processor: unified({ -+ remarkPlugins: [remarkToc], -+ rehypePlugins: [rehypeSlug], -+ remarkRehype: true, -+ gfm: true, -+ smartypants: true, -+ }), -- remarkPlugins: [remarkToc], -- rehypePlugins: [rehypeSlug], -- remarkRehype: true, -- gfm: true, -- smartypants: true, - }, -}); -``` - -For more information on enabling and using this feature in your project, see our [Markdown guide](https://docs.astro.build/en/guides/markdown-content/). To give feedback on this new Rust processor, see the [Native Markdown / MDX parsing and processing RFC](https://github.com/withastro/roadmap/pull/1364). diff --git a/.changeset/markdown-satteri.md b/.changeset/markdown-satteri.md deleted file mode 100644 index 237df7b69014..000000000000 --- a/.changeset/markdown-satteri.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -'@astrojs/markdown-satteri': minor ---- - -Adds `@astrojs/markdown-satteri`, a Markdown processor based on [Sätteri](https://satteri.bruits.org), a fast Markdown pipeline written in Rust. - -Sätteri is much faster than the default Remark-based processor, and supports a wide range of Markdown features out of the box, without requiring additional plugins. In the future, we plan to make this the default Markdown processor in Astro. - -```sh -npm install @astrojs/markdown-satteri -``` - -```js -// astro.config.mjs -import { satteri } from '@astrojs/markdown-satteri'; - -export default defineConfig({ - markdown: { - processor: satteri(), - }, -}); -``` - -Note that this processor currently does not support Prism syntax highlighting, and require using `syntaxHighlight: 'shiki'` or disabling syntax highlighting altogether for now. diff --git a/.changeset/mdx-satteri-support.md b/.changeset/mdx-satteri-support.md deleted file mode 100644 index ea0ff3ec2342..000000000000 --- a/.changeset/mdx-satteri-support.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -'@astrojs/mdx': minor ---- - -Adds support for using [`@astrojs/markdown-satteri`](https://www.npmjs.com/package/@astrojs/markdown-satteri) to parse `.mdx` files. - -```js -// astro.config.mjs -import { defineConfig } from 'astro/config'; -import mdx from '@astrojs/mdx'; -import { satteri } from '@astrojs/markdown-satteri'; - -export default defineConfig({ - markdown: { - processor: satteri({ - features: { directive: true }, - }), - }, - integrations: [mdx()], -}); -``` - -Note that the [`recmaPlugins` option](https://docs.astro.build/en/guides/integrations-guide/mdx/#recmaplugins) is not supported when using Sätteri as your MDX processor. If you would like to use Sätteri for Markdown files, but still use Unified for MDX, you can pass a different Markdown processor to the MDX integration: - -```js -// astro.config.mjs -import { defineConfig } from 'astro/config'; -import mdx from '@astrojs/mdx'; -import { satteri } from '@astrojs/markdown-satteri'; -import { unified } from '@astrojs/markdown-remark'; -import myPlugin from "./my-recma-plugin.js"; - -export default defineConfig({ - markdown: { - processor: satteri({ - features: { directive: true }, - }), - }, - integrations: [ - mdx({ - recmaPlugins: [myPlugin], - processor: unified(), - }), - ], -}); -``` diff --git a/.changeset/silly-coins-wash.md b/.changeset/silly-coins-wash.md deleted file mode 100644 index a021e9cb0e73..000000000000 --- a/.changeset/silly-coins-wash.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -'@astrojs/cloudflare': minor ---- - -Adds `@astrojs/cloudflare/fetch` and `@astrojs/cloudflare/hono` exports for composing Cloudflare-specific setup with Astro's advanced routing handlers. - -#### `@astrojs/cloudflare/fetch` - -For use with `astro/fetch` in a custom fetch handler: - -```ts -import { astro, FetchState } from 'astro/fetch'; -import { cf } from '@astrojs/cloudflare/fetch'; - -export default { - async fetch(request: Request, env: Env, ctx: ExecutionContext) { - const state = new FetchState(request); - const asset = await cf(state, env, ctx); - if (asset) return asset; - return astro(state); - } -} -``` - -#### `@astrojs/cloudflare/hono` - -For use with `astro/hono` as Hono middleware: - -```ts -import { Hono } from 'hono'; -import { actions, middleware, pages, i18n } from 'astro/hono'; -import { cf } from '@astrojs/cloudflare/hono'; - -const app = new Hono<{ Bindings: Env }>(); - -app.use(cf()); -app.use(actions()); -app.use(middleware()); -app.use(pages()); -app.use(i18n()); - -export default app; -``` - -Both handlers configure SESSION KV bindings, static asset serving via the ASSETS binding, `locals.cfContext`, client address, `waitUntil`, and prerendered error page fetch. diff --git a/.changeset/two-views-clean.md b/.changeset/two-views-clean.md deleted file mode 100644 index 42ae2fde33d0..000000000000 --- a/.changeset/two-views-clean.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixes preview for static sites that contain non-prerendered routes. Previously, the preview command ignored SSR routes discovered during route scanning and always used the static preview server. diff --git a/examples/advanced-routing/package.json b/examples/advanced-routing/package.json index abc4450b53c8..6fe5f6109ac7 100644 --- a/examples/advanced-routing/package.json +++ b/examples/advanced-routing/package.json @@ -13,8 +13,8 @@ "astro": "astro" }, "dependencies": { - "@astrojs/node": "^10.1.1", - "astro": "^6.3.8", + "@astrojs/node": "^10.1.2", + "astro": "^6.4.0", "hono": "^4.12.14" } } diff --git a/examples/basics/package.json b/examples/basics/package.json index d2d6cb80065c..2a85a5c9feff 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -13,6 +13,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^6.3.8" + "astro": "^6.4.0" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 559eabc108db..36ec2de45577 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -13,10 +13,10 @@ "astro": "astro" }, "dependencies": { - "@astrojs/mdx": "^5.0.6", + "@astrojs/mdx": "^6.0.0", "@astrojs/rss": "^4.0.18", "@astrojs/sitemap": "^3.7.3", - "astro": "^6.3.8", + "astro": "^6.4.0", "sharp": "^0.34.3" } } diff --git a/examples/component/package.json b/examples/component/package.json index d4a6895cdd99..b281fe71c20b 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -18,7 +18,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^6.3.8" + "astro": "^6.4.0" }, "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 111385880798..b2a8922af540 100644 --- a/examples/container-with-vitest/package.json +++ b/examples/container-with-vitest/package.json @@ -14,8 +14,8 @@ "test": "vitest run" }, "dependencies": { - "@astrojs/react": "^5.0.5", - "astro": "^6.3.8", + "@astrojs/react": "^5.0.6", + "astro": "^6.4.0", "react": "^18.3.1", "react-dom": "^18.3.1", "vitest": "^4.1.0" diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index 4b7d654a67d5..6d807a3b41ce 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.3.8" + "astro": "^6.4.0" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index 04c29ae95aad..50f706f0d3ec 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -13,14 +13,14 @@ "astro": "astro" }, "dependencies": { - "@astrojs/preact": "^5.1.3", - "@astrojs/react": "^5.0.5", + "@astrojs/preact": "^5.1.4", + "@astrojs/react": "^5.0.6", "@astrojs/solid-js": "^6.0.1", "@astrojs/svelte": "^8.1.2", "@astrojs/vue": "^6.0.1", "@types/react": "^18.3.28", "@types/react-dom": "^18.3.7", - "astro": "^6.3.8", + "astro": "^6.4.0", "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 5a775b49b5d8..21ec41229dba 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -13,9 +13,9 @@ "astro": "astro" }, "dependencies": { - "@astrojs/preact": "^5.1.3", + "@astrojs/preact": "^5.1.4", "@preact/signals": "^2.8.1", - "astro": "^6.3.8", + "astro": "^6.4.0", "preact": "^10.28.4" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index 6068198ccfee..d04c595344b2 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -13,10 +13,10 @@ "astro": "astro" }, "dependencies": { - "@astrojs/react": "^5.0.5", + "@astrojs/react": "^5.0.6", "@types/react": "^18.3.28", "@types/react-dom": "^18.3.7", - "astro": "^6.3.8", + "astro": "^6.4.0", "react": "^18.3.1", "react-dom": "^18.3.1" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index 364b02023770..532b33e14883 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -14,7 +14,7 @@ }, "dependencies": { "@astrojs/solid-js": "^6.0.1", - "astro": "^6.3.8", + "astro": "^6.4.0", "solid-js": "^1.9.11" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index 5b920d1dbd29..7c28fa80a5b4 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -14,7 +14,7 @@ }, "dependencies": { "@astrojs/svelte": "^8.1.2", - "astro": "^6.3.8", + "astro": "^6.4.0", "svelte": "^5.53.5" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index b0f33c54dc74..5a0e6741c35a 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -14,7 +14,7 @@ }, "dependencies": { "@astrojs/vue": "^6.0.1", - "astro": "^6.3.8", + "astro": "^6.4.0", "vue": "^3.5.29" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 784d6ed41900..8dfaaba4325f 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -13,7 +13,7 @@ "astro": "astro" }, "dependencies": { - "@astrojs/node": "^10.1.1", - "astro": "^6.3.8" + "@astrojs/node": "^10.1.2", + "astro": "^6.4.0" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index 79b85693f37e..1621543f05b5 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -18,7 +18,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^6.3.8" + "astro": "^6.4.0" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/minimal/package.json b/examples/minimal/package.json index 7f40d586be7b..1a5ef60588af 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -13,6 +13,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^6.3.8" + "astro": "^6.4.0" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index 3a77a0438adf..d87d58700884 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -13,6 +13,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^6.3.8" + "astro": "^6.4.0" } } diff --git a/examples/ssr/package.json b/examples/ssr/package.json index b2e513eb5da9..d231f2808acf 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.1.1", + "@astrojs/node": "^10.1.2", "@astrojs/svelte": "^8.1.2", - "astro": "^6.3.8", + "astro": "^6.4.0", "svelte": "^5.53.5" } } diff --git a/examples/starlog/package.json b/examples/starlog/package.json index 709ff11229d1..9a68c06de843 100644 --- a/examples/starlog/package.json +++ b/examples/starlog/package.json @@ -9,7 +9,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^6.3.8", + "astro": "^6.4.0", "sass": "^1.97.3", "sharp": "^0.34.3" }, diff --git a/examples/toolbar-app/package.json b/examples/toolbar-app/package.json index 322c822c64f6..8a0ce3d20157 100644 --- a/examples/toolbar-app/package.json +++ b/examples/toolbar-app/package.json @@ -16,7 +16,7 @@ }, "devDependencies": { "@types/node": "^22.10.6", - "astro": "^6.3.8" + "astro": "^6.4.0" }, "engines": { "node": ">=22.12.0" diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index 015fe219a4bf..66d70c9a4a9a 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -13,7 +13,7 @@ "astro": "astro" }, "dependencies": { - "@astrojs/markdoc": "^1.0.5", - "astro": "^6.3.8" + "@astrojs/markdoc": "^1.0.6", + "astro": "^6.4.0" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index 987b6356d211..524922b03003 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -13,9 +13,9 @@ "astro": "astro" }, "dependencies": { - "@astrojs/mdx": "^5.0.6", - "@astrojs/preact": "^5.1.3", - "astro": "^6.3.8", + "@astrojs/mdx": "^6.0.0", + "@astrojs/preact": "^5.1.4", + "astro": "^6.4.0", "preact": "^10.28.4" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 128c690b604e..90f0841c090b 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -13,9 +13,9 @@ "astro": "astro" }, "dependencies": { - "@astrojs/preact": "^5.1.3", + "@astrojs/preact": "^5.1.4", "@nanostores/preact": "^1.0.0", - "astro": "^6.3.8", + "astro": "^6.4.0", "nanostores": "^1.1.1", "preact": "^10.28.4" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index 15cca4df4c7b..c642373d291f 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -13,10 +13,10 @@ "astro": "astro" }, "dependencies": { - "@astrojs/mdx": "^5.0.6", + "@astrojs/mdx": "^6.0.0", "@tailwindcss/vite": "^4.2.1", "@types/canvas-confetti": "^1.9.0", - "astro": "^6.3.8", + "astro": "^6.4.0", "canvas-confetti": "^1.9.4", "tailwindcss": "^4.2.1" } diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index 06eb62470dea..e2c89ed1433a 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -14,7 +14,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^6.3.8", + "astro": "^6.4.0", "vitest": "^4.1.0" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index efbe57dc6971..89aae04d6315 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,110 @@ # astro +## 6.4.0 + +### Minor Changes + +- [#16468](https://github.com/withastro/astro/pull/16468) [`4cff3a1`](https://github.com/withastro/astro/commit/4cff3a107c3750ab5f0878a6b41836705282b771) Thanks [@matthewp](https://github.com/matthewp)! - Adds a new `preserveBuildServerDir` adapter feature + + Adapters can now set `preserveBuildServerDir: true` in their adapter features to keep the `dist/server/` directory structure for static builds, mirroring the existing `preserveBuildClientDir` option. This is useful for adapters that require a consistent `dist/client/` and `dist/server/` layout regardless of build output type. + + ```js + setAdapter({ + name: 'my-adapter', + adapterFeatures: { + buildOutput, + preserveBuildClientDir: true, + preserveBuildServerDir: true, + }, + }); + ``` + +- [#16848](https://github.com/withastro/astro/pull/16848) [`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Adds a new `markdown.processor` configuration option, allowing you to choose an alternative Markdown processor. + + Websites with many Markdown/MDX files tend to be slow to build because the unified ecosystem (e.g., remark, rehype) is slow to process. This feature introduces the ability to replace this part of the build pipeline with another processor. + + The default processor is `unified()`. This means that existing configurations remain unchanged and your remark/rehype plugins continue to work. + + ```js + // astro.config.mjs + import { defineConfig } from 'astro/config'; + import { unified } from '@astrojs/markdown-remark'; + import remarkToc from 'remark-toc'; + + export default defineConfig({ + markdown: { + processor: unified({ + remarkPlugins: [remarkToc], + }), + }, + }); + ``` + + In addition to this new configuration option, Astro provides a new alternative processor based on Rust: [Sätteri](https://satteri.bruits.org/). You can choose to use it now by installing `@astrojs/markdown-satteri`, importing the `satteri()` processor, and adapting your existing configuration: + + ```js + // astro.config.mjs + import { defineConfig } from 'astro/config'; + import { satteri } from '@astrojs/markdown-satteri'; + + export default defineConfig({ + markdown: { + processor: satteri({ + features: { directive: true }, + }), + }, + }); + ``` + + This processor does not support the remark and rehype plugins. This means you may need to convert them to [MDAST or HAST plugins](https://satteri.bruits.org/docs/plugins/) to retain your current functionality. + + The existing top-level `markdown.remarkPlugins`, `markdown.rehypePlugins`, `markdown.remarkRehype`, `markdown.gfm`, and `markdown.smartypants` options still work, but are now deprecated and will be removed in a future major update. The matching `remarkPlugins`, `rehypePlugins`, and `remarkRehype` options on the MDX integration are also deprecated for the same reason. To anticipate their removal, move them onto `unified({...})` (or your preferred plugin processor) : + + ```diff + // astro.config.mjs + import { defineConfig } from 'astro/config'; + import remarkToc from 'remark-toc'; + import rehypeSlug from 'rehype-slug'; + + import { unified } from '@astrojs/markdown-remark'; + + export default defineConfig({ + markdown: { + + processor: unified({ + + remarkPlugins: [remarkToc], + + rehypePlugins: [rehypeSlug], + + remarkRehype: true, + + gfm: true, + + smartypants: true, + + }), + - remarkPlugins: [remarkToc], + - rehypePlugins: [rehypeSlug], + - remarkRehype: true, + - gfm: true, + - smartypants: true, + }, + }); + ``` + + For more information on enabling and using this feature in your project, see our [Markdown guide](https://docs.astro.build/en/guides/markdown-content/). To give feedback on this new Rust processor, see the [Native Markdown / MDX parsing and processing RFC](https://github.com/withastro/roadmap/pull/1364). + +### Patch Changes + +- [#16468](https://github.com/withastro/astro/pull/16468) [`4cff3a1`](https://github.com/withastro/astro/commit/4cff3a107c3750ab5f0878a6b41836705282b771) Thanks [@matthewp](https://github.com/matthewp)! - Skips the static preview server when an adapter provides its own `previewEntrypoint`, allowing the adapter to handle both static and dynamic routes + +- [#16811](https://github.com/withastro/astro/pull/16811) [`e0e26db`](https://github.com/withastro/astro/commit/e0e26dbfe95f9d42f51ad414dbe877e60cbc637d) Thanks [@matthewp](https://github.com/matthewp)! - Fixes `X-Forwarded-Host` and `X-Forwarded-Proto` headers being ignored when set in a custom `src/app.ts` fetch handler before creating `FetchState` + +- [#16468](https://github.com/withastro/astro/pull/16468) [`4cff3a1`](https://github.com/withastro/astro/commit/4cff3a107c3750ab5f0878a6b41836705282b771) Thanks [@matthewp](https://github.com/matthewp)! - Fixes the static preview server to respect `preserveBuildClientDir`, serving files from `build.client` instead of `outDir` when the adapter requires it + +- [#16770](https://github.com/withastro/astro/pull/16770) [`1e2aa11`](https://github.com/withastro/astro/commit/1e2aa11caf8e7a48f37dd614fd2d4c15cc7a8439) Thanks [@matthewp](https://github.com/matthewp)! - Fixes a race condition where the Vite dep optimizer could lose React dependencies in dev mode when using Astro Actions + +- [#16468](https://github.com/withastro/astro/pull/16468) [`4cff3a1`](https://github.com/withastro/astro/commit/4cff3a107c3750ab5f0878a6b41836705282b771) Thanks [@matthewp](https://github.com/matthewp)! - Exempts internal routes (e.g. server islands) from `getStaticPaths()` validation, fixing server island rendering on static sites + +- [#16468](https://github.com/withastro/astro/pull/16468) [`4cff3a1`](https://github.com/withastro/astro/commit/4cff3a107c3750ab5f0878a6b41836705282b771) Thanks [@matthewp](https://github.com/matthewp)! - Fixes preview for static sites that contain non-prerendered routes. Previously, the preview command ignored SSR routes discovered during route scanning and always used the static preview server. + +- Updated dependencies [[`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc), [`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc)]: + - @astrojs/internal-helpers@0.10.0 + - @astrojs/markdown-remark@7.2.0 + ## 6.3.8 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index 40b831b54421..d3cb91d79f90 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "6.3.8", + "version": "6.4.0", "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/integrations/cloudflare/CHANGELOG.md b/packages/integrations/cloudflare/CHANGELOG.md index d3cd583a919a..c46c460166bb 100644 --- a/packages/integrations/cloudflare/CHANGELOG.md +++ b/packages/integrations/cloudflare/CHANGELOG.md @@ -1,5 +1,61 @@ # @astrojs/cloudflare +## 13.6.0 + +### Minor Changes + +- [#16729](https://github.com/withastro/astro/pull/16729) [`01aa164`](https://github.com/withastro/astro/commit/01aa1648ef436037b9204c8a297a09e66870cf86) Thanks [@matthewp](https://github.com/matthewp)! - Adds `@astrojs/cloudflare/fetch` and `@astrojs/cloudflare/hono` exports for composing Cloudflare-specific setup with Astro's advanced routing handlers. + + #### `@astrojs/cloudflare/fetch` + + For use with `astro/fetch` in a custom fetch handler: + + ```ts + import { astro, FetchState } from 'astro/fetch'; + import { cf } from '@astrojs/cloudflare/fetch'; + + export default { + async fetch(request: Request, env: Env, ctx: ExecutionContext) { + const state = new FetchState(request); + const asset = await cf(state, env, ctx); + if (asset) return asset; + return astro(state); + }, + }; + ``` + + #### `@astrojs/cloudflare/hono` + + For use with `astro/hono` as Hono middleware: + + ```ts + import { Hono } from 'hono'; + import { actions, middleware, pages, i18n } from 'astro/hono'; + import { cf } from '@astrojs/cloudflare/hono'; + + const app = new Hono<{ Bindings: Env }>(); + + app.use(cf()); + app.use(actions()); + app.use(middleware()); + app.use(pages()); + app.use(i18n()); + + export default app; + ``` + + Both handlers configure SESSION KV bindings, static asset serving via the ASSETS binding, `locals.cfContext`, client address, `waitUntil`, and prerendered error page fetch. + +### Patch Changes + +- [#16868](https://github.com/withastro/astro/pull/16868) [`f9bae95`](https://github.com/withastro/astro/commit/f9bae95a37c791cbb39a2402f3b969c853462010) Thanks [@helio-cf](https://github.com/helio-cf)! - Fixes user options passed to `cloudflare({...})` (`remoteBindings`, `inspectorPort`, `persistState`, `configPath`, `auxiliaryWorkers`) being silently ignored during `astro preview`. The adapter now resolves the full `@cloudflare/vite-plugin` config once at integration setup time and reuses that single resolved value across the dev/build plugin, the prerenderer's preview server, and the `astro preview` entrypoint, so user options can no longer be dropped at one of the call sites. + +- [#16468](https://github.com/withastro/astro/pull/16468) [`4cff3a1`](https://github.com/withastro/astro/commit/4cff3a107c3750ab5f0878a6b41836705282b771) Thanks [@matthewp](https://github.com/matthewp)! - Fixes static Cloudflare builds with server islands or image endpoints that failed at preview time due to mismatched output directories. + +- Updated dependencies [[`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc)]: + - @astrojs/internal-helpers@0.10.0 + - @astrojs/underscore-redirects@1.0.3 + ## 13.5.5 ### Patch Changes diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index a82fe12324b0..a79ce664c5dc 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.5.5", + "version": "13.6.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/markdoc/CHANGELOG.md b/packages/integrations/markdoc/CHANGELOG.md index 5252322f9fb9..ec6dfdd2cef1 100644 --- a/packages/integrations/markdoc/CHANGELOG.md +++ b/packages/integrations/markdoc/CHANGELOG.md @@ -1,5 +1,14 @@ # @astrojs/markdoc +## 1.0.6 + +### Patch Changes + +- [#16848](https://github.com/withastro/astro/pull/16848) [`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Removes `@astrojs/markdown-remark` from `@astrojs/markdoc`'s dependencies in favour of Astro's internal markdown utilities now that Astro's Markdown support is processor agnostic. + +- Updated dependencies [[`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc)]: + - @astrojs/internal-helpers@0.10.0 + ## 1.0.5 ### Patch Changes diff --git a/packages/integrations/markdoc/package.json b/packages/integrations/markdoc/package.json index 548daeee666d..240c7fae97c2 100644 --- a/packages/integrations/markdoc/package.json +++ b/packages/integrations/markdoc/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/markdoc", "description": "Add support for Markdoc in your Astro site", - "version": "1.0.5", + "version": "1.0.6", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/mdx/CHANGELOG.md b/packages/integrations/mdx/CHANGELOG.md index 57211145c66a..9f5df1f3f373 100644 --- a/packages/integrations/mdx/CHANGELOG.md +++ b/packages/integrations/mdx/CHANGELOG.md @@ -1,5 +1,129 @@ # @astrojs/mdx +## 6.0.0 + +### Major Changes + +- [#16848](https://github.com/withastro/astro/pull/16848) [`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Adds a new `markdown.processor` configuration option, allowing you to choose an alternative Markdown processor. + + Websites with many Markdown/MDX files tend to be slow to build because the unified ecosystem (e.g., remark, rehype) is slow to process. This feature introduces the ability to replace this part of the build pipeline with another processor. + + The default processor is `unified()`. This means that existing configurations remain unchanged and your remark/rehype plugins continue to work. + + ```js + // astro.config.mjs + import { defineConfig } from 'astro/config'; + import { unified } from '@astrojs/markdown-remark'; + import remarkToc from 'remark-toc'; + + export default defineConfig({ + markdown: { + processor: unified({ + remarkPlugins: [remarkToc], + }), + }, + }); + ``` + + In addition to this new configuration option, Astro provides a new alternative processor based on Rust: [Sätteri](https://satteri.bruits.org/). You can choose to use it now by installing `@astrojs/markdown-satteri`, importing the `satteri()` processor, and adapting your existing configuration: + + ```js + // astro.config.mjs + import { defineConfig } from 'astro/config'; + import { satteri } from '@astrojs/markdown-satteri'; + + export default defineConfig({ + markdown: { + processor: satteri({ + features: { directive: true }, + }), + }, + }); + ``` + + This processor does not support the remark and rehype plugins. This means you may need to convert them to [MDAST or HAST plugins](https://satteri.bruits.org/docs/plugins/) to retain your current functionality. + + The existing top-level `markdown.remarkPlugins`, `markdown.rehypePlugins`, `markdown.remarkRehype`, `markdown.gfm`, and `markdown.smartypants` options still work, but are now deprecated and will be removed in a future major update. The matching `remarkPlugins`, `rehypePlugins`, and `remarkRehype` options on the MDX integration are also deprecated for the same reason. To anticipate their removal, move them onto `unified({...})` (or your preferred plugin processor) : + + ```diff + // astro.config.mjs + import { defineConfig } from 'astro/config'; + import remarkToc from 'remark-toc'; + import rehypeSlug from 'rehype-slug'; + + import { unified } from '@astrojs/markdown-remark'; + + export default defineConfig({ + markdown: { + + processor: unified({ + + remarkPlugins: [remarkToc], + + rehypePlugins: [rehypeSlug], + + remarkRehype: true, + + gfm: true, + + smartypants: true, + + }), + - remarkPlugins: [remarkToc], + - rehypePlugins: [rehypeSlug], + - remarkRehype: true, + - gfm: true, + - smartypants: true, + }, + }); + ``` + + For more information on enabling and using this feature in your project, see our [Markdown guide](https://docs.astro.build/en/guides/markdown-content/). To give feedback on this new Rust processor, see the [Native Markdown / MDX parsing and processing RFC](https://github.com/withastro/roadmap/pull/1364). + +### Minor Changes + +- [#16848](https://github.com/withastro/astro/pull/16848) [`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Adds support for using [`@astrojs/markdown-satteri`](https://www.npmjs.com/package/@astrojs/markdown-satteri) to parse `.mdx` files. + + ```js + // astro.config.mjs + import { defineConfig } from 'astro/config'; + import mdx from '@astrojs/mdx'; + import { satteri } from '@astrojs/markdown-satteri'; + + export default defineConfig({ + markdown: { + processor: satteri({ + features: { directive: true }, + }), + }, + integrations: [mdx()], + }); + ``` + + Note that the [`recmaPlugins` option](https://docs.astro.build/en/guides/integrations-guide/mdx/#recmaplugins) is not supported when using Sätteri as your MDX processor. If you would like to use Sätteri for Markdown files, but still use Unified for MDX, you can pass a different Markdown processor to the MDX integration: + + ```js + // astro.config.mjs + import { defineConfig } from 'astro/config'; + import mdx from '@astrojs/mdx'; + import { satteri } from '@astrojs/markdown-satteri'; + import { unified } from '@astrojs/markdown-remark'; + import myPlugin from './my-recma-plugin.js'; + + export default defineConfig({ + markdown: { + processor: satteri({ + features: { directive: true }, + }), + }, + integrations: [ + mdx({ + recmaPlugins: [myPlugin], + processor: unified(), + }), + ], + }); + ``` + +### Patch Changes + +- Updated dependencies [[`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc), [`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc), [`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc)]: + - @astrojs/internal-helpers@0.10.0 + - @astrojs/markdown-remark@7.2.0 + - @astrojs/markdown-satteri@0.2.0 + ## 5.0.6 ### Patch Changes diff --git a/packages/integrations/mdx/package.json b/packages/integrations/mdx/package.json index bc6a4e5b563c..ea40a5fcdf7c 100644 --- a/packages/integrations/mdx/package.json +++ b/packages/integrations/mdx/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/mdx", "description": "Add support for MDX pages in your Astro site", - "version": "5.0.6", + "version": "6.0.0", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/netlify/CHANGELOG.md b/packages/integrations/netlify/CHANGELOG.md index f518f8ba8dbd..aca7f435bad7 100644 --- a/packages/integrations/netlify/CHANGELOG.md +++ b/packages/integrations/netlify/CHANGELOG.md @@ -1,5 +1,13 @@ # @astrojs/netlify +## 7.0.11 + +### Patch Changes + +- Updated dependencies [[`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc)]: + - @astrojs/internal-helpers@0.10.0 + - @astrojs/underscore-redirects@1.0.3 + ## 7.0.10 ### Patch Changes diff --git a/packages/integrations/netlify/package.json b/packages/integrations/netlify/package.json index 77c5fcffc340..2df7807c49b2 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.10", + "version": "7.0.11", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/node/CHANGELOG.md b/packages/integrations/node/CHANGELOG.md index 036a5ea5917a..786cc01b1a3a 100644 --- a/packages/integrations/node/CHANGELOG.md +++ b/packages/integrations/node/CHANGELOG.md @@ -1,5 +1,12 @@ # @astrojs/node +## 10.1.2 + +### Patch Changes + +- Updated dependencies [[`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc)]: + - @astrojs/internal-helpers@0.10.0 + ## 10.1.1 ### Patch Changes diff --git a/packages/integrations/node/package.json b/packages/integrations/node/package.json index 1a9a2228d035..3cc047d3ac51 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.1.1", + "version": "10.1.2", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/preact/CHANGELOG.md b/packages/integrations/preact/CHANGELOG.md index 41470be4fd2d..18274f630ed2 100644 --- a/packages/integrations/preact/CHANGELOG.md +++ b/packages/integrations/preact/CHANGELOG.md @@ -1,5 +1,12 @@ # @astrojs/preact +## 5.1.4 + +### Patch Changes + +- Updated dependencies [[`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc)]: + - @astrojs/internal-helpers@0.10.0 + ## 5.1.3 ### Patch Changes diff --git a/packages/integrations/preact/package.json b/packages/integrations/preact/package.json index 972f9f2cda5b..48b02d8a6476 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": "5.1.3", + "version": "5.1.4", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/react/CHANGELOG.md b/packages/integrations/react/CHANGELOG.md index 3d9b4489b54c..2dcff752065e 100644 --- a/packages/integrations/react/CHANGELOG.md +++ b/packages/integrations/react/CHANGELOG.md @@ -1,5 +1,12 @@ # @astrojs/react +## 5.0.6 + +### Patch Changes + +- Updated dependencies [[`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc)]: + - @astrojs/internal-helpers@0.10.0 + ## 5.0.5 ### Patch Changes diff --git a/packages/integrations/react/package.json b/packages/integrations/react/package.json index 589f64945a44..80c957a04c85 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": "5.0.5", + "version": "5.0.6", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/vercel/CHANGELOG.md b/packages/integrations/vercel/CHANGELOG.md index dacf3221bd1d..d9cea51b9508 100644 --- a/packages/integrations/vercel/CHANGELOG.md +++ b/packages/integrations/vercel/CHANGELOG.md @@ -1,5 +1,12 @@ # @astrojs/vercel +## 10.0.8 + +### Patch Changes + +- Updated dependencies [[`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc)]: + - @astrojs/internal-helpers@0.10.0 + ## 10.0.7 ### Patch Changes diff --git a/packages/integrations/vercel/package.json b/packages/integrations/vercel/package.json index 5fda88f3b26f..c4f1bf21d56a 100644 --- a/packages/integrations/vercel/package.json +++ b/packages/integrations/vercel/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/vercel", "description": "Deploy your site to Vercel", - "version": "10.0.7", + "version": "10.0.8", "type": "module", "author": "withastro", "license": "MIT", diff --git a/packages/internal-helpers/CHANGELOG.md b/packages/internal-helpers/CHANGELOG.md index 9e04482251ca..39e75167691c 100644 --- a/packages/internal-helpers/CHANGELOG.md +++ b/packages/internal-helpers/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/internal-helpers +## 0.10.0 + +### Minor Changes + +- [#16848](https://github.com/withastro/astro/pull/16848) [`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Adds `markdown`, `frontmatter`, and `shiki` helper modules, shared by Astro's content pipeline. + ## 0.9.1 ### Patch Changes diff --git a/packages/internal-helpers/package.json b/packages/internal-helpers/package.json index 2a7a88871126..037f753ee1f8 100644 --- a/packages/internal-helpers/package.json +++ b/packages/internal-helpers/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/internal-helpers", "description": "Internal helpers used by core Astro packages.", - "version": "0.9.1", + "version": "0.10.0", "type": "module", "author": "withastro", "license": "MIT", diff --git a/packages/markdown/remark/CHANGELOG.md b/packages/markdown/remark/CHANGELOG.md index 15e122ef9e7c..ce24231caac9 100644 --- a/packages/markdown/remark/CHANGELOG.md +++ b/packages/markdown/remark/CHANGELOG.md @@ -1,5 +1,82 @@ # @astrojs/markdown-remark +## 7.2.0 + +### Minor Changes + +- [#16848](https://github.com/withastro/astro/pull/16848) [`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Adds a new `markdown.processor` configuration option, allowing you to choose an alternative Markdown processor. + + Websites with many Markdown/MDX files tend to be slow to build because the unified ecosystem (e.g., remark, rehype) is slow to process. This feature introduces the ability to replace this part of the build pipeline with another processor. + + The default processor is `unified()`. This means that existing configurations remain unchanged and your remark/rehype plugins continue to work. + + ```js + // astro.config.mjs + import { defineConfig } from 'astro/config'; + import { unified } from '@astrojs/markdown-remark'; + import remarkToc from 'remark-toc'; + + export default defineConfig({ + markdown: { + processor: unified({ + remarkPlugins: [remarkToc], + }), + }, + }); + ``` + + In addition to this new configuration option, Astro provides a new alternative processor based on Rust: [Sätteri](https://satteri.bruits.org/). You can choose to use it now by installing `@astrojs/markdown-satteri`, importing the `satteri()` processor, and adapting your existing configuration: + + ```js + // astro.config.mjs + import { defineConfig } from 'astro/config'; + import { satteri } from '@astrojs/markdown-satteri'; + + export default defineConfig({ + markdown: { + processor: satteri({ + features: { directive: true }, + }), + }, + }); + ``` + + This processor does not support the remark and rehype plugins. This means you may need to convert them to [MDAST or HAST plugins](https://satteri.bruits.org/docs/plugins/) to retain your current functionality. + + The existing top-level `markdown.remarkPlugins`, `markdown.rehypePlugins`, `markdown.remarkRehype`, `markdown.gfm`, and `markdown.smartypants` options still work, but are now deprecated and will be removed in a future major update. The matching `remarkPlugins`, `rehypePlugins`, and `remarkRehype` options on the MDX integration are also deprecated for the same reason. To anticipate their removal, move them onto `unified({...})` (or your preferred plugin processor) : + + ```diff + // astro.config.mjs + import { defineConfig } from 'astro/config'; + import remarkToc from 'remark-toc'; + import rehypeSlug from 'rehype-slug'; + + import { unified } from '@astrojs/markdown-remark'; + + export default defineConfig({ + markdown: { + + processor: unified({ + + remarkPlugins: [remarkToc], + + rehypePlugins: [rehypeSlug], + + remarkRehype: true, + + gfm: true, + + smartypants: true, + + }), + - remarkPlugins: [remarkToc], + - rehypePlugins: [rehypeSlug], + - remarkRehype: true, + - gfm: true, + - smartypants: true, + }, + }); + ``` + + For more information on enabling and using this feature in your project, see our [Markdown guide](https://docs.astro.build/en/guides/markdown-content/). To give feedback on this new Rust processor, see the [Native Markdown / MDX parsing and processing RFC](https://github.com/withastro/roadmap/pull/1364). + +### Patch Changes + +- Updated dependencies [[`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc)]: + - @astrojs/internal-helpers@0.10.0 + ## 7.1.2 ### Patch Changes diff --git a/packages/markdown/remark/package.json b/packages/markdown/remark/package.json index f13922c57f79..da6bb6eeee58 100644 --- a/packages/markdown/remark/package.json +++ b/packages/markdown/remark/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/markdown-remark", - "version": "7.1.2", + "version": "7.2.0", "type": "module", "author": "withastro", "license": "MIT", diff --git a/packages/markdown/satteri/CHANGELOG.md b/packages/markdown/satteri/CHANGELOG.md new file mode 100644 index 000000000000..b19cd6890252 --- /dev/null +++ b/packages/markdown/satteri/CHANGELOG.md @@ -0,0 +1,31 @@ +# @astrojs/markdown-satteri + +## 0.2.0 + +### Minor Changes + +- [#16848](https://github.com/withastro/astro/pull/16848) [`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Adds `@astrojs/markdown-satteri`, a Markdown processor based on [Sätteri](https://satteri.bruits.org), a fast Markdown pipeline written in Rust. + + Sätteri is much faster than the default Remark-based processor, and supports a wide range of Markdown features out of the box, without requiring additional plugins. In the future, we plan to make this the default Markdown processor in Astro. + + ```sh + npm install @astrojs/markdown-satteri + ``` + + ```js + // astro.config.mjs + import { satteri } from '@astrojs/markdown-satteri'; + + export default defineConfig({ + markdown: { + processor: satteri(), + }, + }); + ``` + + Note that this processor currently does not support Prism syntax highlighting, and require using `syntaxHighlight: 'shiki'` or disabling syntax highlighting altogether for now. + +### Patch Changes + +- Updated dependencies [[`f732f3c`](https://github.com/withastro/astro/commit/f732f3cc716342a63e5b03815243ba10964b89dc)]: + - @astrojs/internal-helpers@0.10.0 diff --git a/packages/markdown/satteri/package.json b/packages/markdown/satteri/package.json index 3402827ce274..3112bbeffde5 100644 --- a/packages/markdown/satteri/package.json +++ b/packages/markdown/satteri/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/markdown-satteri", - "version": "0.1.0", + "version": "0.2.0", "type": "module", "author": "withastro", "license": "MIT", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1af88f8b570e..e697355e4355 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -194,10 +194,10 @@ importers: examples/advanced-routing: dependencies: '@astrojs/node': - specifier: ^10.1.1 + specifier: ^10.1.2 version: link:../../packages/integrations/node astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro hono: specifier: ^4.12.14 @@ -206,13 +206,13 @@ importers: examples/basics: dependencies: astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro examples/blog: dependencies: '@astrojs/mdx': - specifier: ^5.0.6 + specifier: ^6.0.0 version: link:../../packages/integrations/mdx '@astrojs/rss': specifier: ^4.0.18 @@ -221,7 +221,7 @@ importers: specifier: ^3.7.3 version: link:../../packages/integrations/sitemap astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro sharp: specifier: ^0.34.3 @@ -230,16 +230,16 @@ importers: examples/component: devDependencies: astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro examples/container-with-vitest: dependencies: '@astrojs/react': - specifier: ^5.0.5 + specifier: ^5.0.6 version: link:../../packages/integrations/react astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -270,16 +270,16 @@ importers: specifier: ^3.15.8 version: 3.15.8 astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro examples/framework-multiple: dependencies: '@astrojs/preact': - specifier: ^5.1.3 + specifier: ^5.1.4 version: link:../../packages/integrations/preact '@astrojs/react': - specifier: ^5.0.5 + specifier: ^5.0.6 version: link:../../packages/integrations/react '@astrojs/solid-js': specifier: ^6.0.1 @@ -297,7 +297,7 @@ importers: specifier: ^18.3.7 version: 18.3.7(@types/react@18.3.28) astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro preact: specifier: ^10.28.4 @@ -321,13 +321,13 @@ importers: examples/framework-preact: dependencies: '@astrojs/preact': - specifier: ^5.1.3 + specifier: ^5.1.4 version: link:../../packages/integrations/preact '@preact/signals': specifier: ^2.8.1 version: 2.8.2(preact@10.29.0) astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro preact: specifier: ^10.28.4 @@ -336,7 +336,7 @@ importers: examples/framework-react: dependencies: '@astrojs/react': - specifier: ^5.0.5 + specifier: ^5.0.6 version: link:../../packages/integrations/react '@types/react': specifier: ^18.3.28 @@ -345,7 +345,7 @@ importers: specifier: ^18.3.7 version: 18.3.7(@types/react@18.3.28) astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro react: specifier: ^18.3.1 @@ -360,7 +360,7 @@ importers: specifier: ^6.0.1 version: link:../../packages/integrations/solid astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro solid-js: specifier: ^1.9.11 @@ -372,7 +372,7 @@ importers: specifier: ^8.1.2 version: link:../../packages/integrations/svelte astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro svelte: specifier: ^5.53.5 @@ -384,7 +384,7 @@ importers: specifier: ^6.0.1 version: link:../../packages/integrations/vue astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro vue: specifier: ^3.5.29 @@ -393,40 +393,40 @@ importers: examples/hackernews: dependencies: '@astrojs/node': - specifier: ^10.1.1 + specifier: ^10.1.2 version: link:../../packages/integrations/node astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro examples/integration: devDependencies: astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro examples/minimal: dependencies: astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro examples/portfolio: dependencies: astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro examples/ssr: dependencies: '@astrojs/node': - specifier: ^10.1.1 + specifier: ^10.1.2 version: link:../../packages/integrations/node '@astrojs/svelte': specifier: ^8.1.2 version: link:../../packages/integrations/svelte astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro svelte: specifier: ^5.53.5 @@ -435,7 +435,7 @@ importers: examples/starlog: dependencies: astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro sass: specifier: ^1.97.3 @@ -450,28 +450,28 @@ importers: specifier: ^22.19.0 version: 22.19.19 astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro examples/with-markdoc: dependencies: '@astrojs/markdoc': - specifier: ^1.0.5 + specifier: ^1.0.6 version: link:../../packages/integrations/markdoc astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro examples/with-mdx: dependencies: '@astrojs/mdx': - specifier: ^5.0.6 + specifier: ^6.0.0 version: link:../../packages/integrations/mdx '@astrojs/preact': - specifier: ^5.1.3 + specifier: ^5.1.4 version: link:../../packages/integrations/preact astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro preact: specifier: ^10.28.4 @@ -480,13 +480,13 @@ importers: examples/with-nanostores: dependencies: '@astrojs/preact': - specifier: ^5.1.3 + specifier: ^5.1.4 version: link:../../packages/integrations/preact '@nanostores/preact': specifier: ^1.0.0 version: 1.0.0(nanostores@1.1.1)(preact@10.29.0) astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro nanostores: specifier: ^1.1.1 @@ -498,7 +498,7 @@ importers: examples/with-tailwindcss: dependencies: '@astrojs/mdx': - specifier: ^5.0.6 + specifier: ^6.0.0 version: link:../../packages/integrations/mdx '@tailwindcss/vite': specifier: ^4.2.1 @@ -507,7 +507,7 @@ importers: specifier: ^1.9.0 version: 1.9.0 astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro canvas-confetti: specifier: ^1.9.4 @@ -519,7 +519,7 @@ importers: examples/with-vitest: dependencies: astro: - specifier: ^6.3.8 + specifier: ^6.4.0 version: link:../../packages/astro vitest: specifier: ^4.1.0 From eeb064ca9452fd9d0ad9b7557059a646a90a3e57 Mon Sep 17 00:00:00 2001 From: Erika <3019731+Princesseuh@users.noreply.github.com> Date: Thu, 28 May 2026 14:54:42 +0200 Subject: [PATCH 2/4] fix(mdx): Restore MDX rehype plugin entrypoint (#16883) --- .changeset/public-ducks-wave.md | 5 + .changeset/restore-jsx-rehype.md | 5 + packages/astro/package.json | 4 + packages/astro/src/jsx/rehype.ts | 377 +++++++++++++++++++++++++++++++ pnpm-lock.yaml | 33 ++- 5 files changed, 406 insertions(+), 18 deletions(-) create mode 100644 .changeset/public-ducks-wave.md create mode 100644 .changeset/restore-jsx-rehype.md create mode 100644 packages/astro/src/jsx/rehype.ts diff --git a/.changeset/public-ducks-wave.md b/.changeset/public-ducks-wave.md new file mode 100644 index 000000000000..81ff8e8b9e1d --- /dev/null +++ b/.changeset/public-ducks-wave.md @@ -0,0 +1,5 @@ +--- +'@astrojs/markdown-satteri': patch +--- + +Fixes missing provenance information on the publish diff --git a/.changeset/restore-jsx-rehype.md b/.changeset/restore-jsx-rehype.md new file mode 100644 index 000000000000..f49cfac28141 --- /dev/null +++ b/.changeset/restore-jsx-rehype.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Restores the `astro/jsx/rehype.js` entry point so that older versions of `@astrojs/mdx` continue to work when used with Astro 6.x. This entry point will be removed in Astro 7.0. diff --git a/packages/astro/package.json b/packages/astro/package.json index d3cb91d79f90..777eb656ae7c 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -39,6 +39,7 @@ "./astro-jsx": "./astro-jsx.d.ts", "./tsconfigs/*.json": "./tsconfigs/*", "./tsconfigs/*": "./tsconfigs/*.json", + "./jsx/rehype.js": "./dist/jsx/rehype.js", "./jsx-runtime": { "types": "./jsx-runtime.d.ts", "default": "./dist/jsx-runtime/index.js" @@ -211,6 +212,8 @@ "expect-type": "^1.3.0", "fs-fixture": "^2.13.0", "hono": "^4.12.14", + "mdast-util-mdx": "^3.0.0", + "mdast-util-mdx-jsx": "^3.2.0", "node-mocks-http": "^1.17.2", "parse-srcset": "^1.0.2", "rehype-autolink-headings": "^7.1.0", @@ -240,6 +243,7 @@ "./astro-jsx": "./astro-jsx.d.ts", "./tsconfigs/*.json": "./tsconfigs/*", "./tsconfigs/*": "./tsconfigs/*.json", + "./jsx/rehype.js": "./dist/jsx/rehype.js", "./jsx-runtime": { "types": "./jsx-runtime.d.ts", "default": "./dist/jsx-runtime/index.js" diff --git a/packages/astro/src/jsx/rehype.ts b/packages/astro/src/jsx/rehype.ts new file mode 100644 index 000000000000..fe6b378aaff0 --- /dev/null +++ b/packages/astro/src/jsx/rehype.ts @@ -0,0 +1,377 @@ +// TODO: Remove this file in Astro 7.0. It now lives directly in the MDX integration at packages/integrations/mdx/src/rehype-analyze-astro-metadata.ts + +import type { RehypePlugin } from '@astrojs/internal-helpers/markdown'; +import type { RootContent } from 'hast'; +import type {} from 'mdast-util-mdx'; +import type { + MdxJsxAttribute, + MdxJsxFlowElementHast, + MdxJsxTextElementHast, +} from 'mdast-util-mdx-jsx'; +import { visit } from 'unist-util-visit'; +import type { VFile } from 'vfile'; +import { AstroError } from '../core/errors/errors.js'; +import { AstroErrorData } from '../core/errors/index.js'; +import { resolvePath } from '../core/viteUtils.js'; +import { createDefaultAstroMetadata } from '../vite-plugin-astro/metadata.js'; +import type { PluginMetadata } from '../vite-plugin-astro/types.js'; + +const ClientOnlyPlaceholder = 'astro-client-only'; + +export const rehypeAnalyzeAstroMetadata: RehypePlugin = () => { + return (tree, file) => { + // Initial metadata for this MDX file, it will be mutated as we traverse the tree + const metadata = createDefaultAstroMetadata(); + + // Parse imports in this file. This is used to match components with their import source + const imports = parseImports(tree.children); + + visit(tree, (node) => { + if (node.type !== 'mdxJsxFlowElement' && node.type !== 'mdxJsxTextElement') return; + + const tagName = node.name; + if ( + !tagName || + !isComponent(tagName) || + !(hasClientDirective(node) || hasServerDeferDirective(node)) + ) + return; + + // From this point onwards, `node` is confirmed to be an island component + + // Match this component with its import source + const matchedImport = findMatchingImport(tagName, imports); + if (!matchedImport) { + throw new AstroError({ + ...AstroErrorData.NoMatchingImport, + message: AstroErrorData.NoMatchingImport.message(node.name!), + }); + } + + // If this is an Astro component, that means the `client:` directive is misused as it doesn't + // work on Astro components as it's server-side only. Warn the user about this. + if (matchedImport.path.endsWith('.astro')) { + const clientAttribute = node.attributes.find( + (attr) => attr.type === 'mdxJsxAttribute' && attr.name.startsWith('client:'), + ) as MdxJsxAttribute | undefined; + if (clientAttribute) { + console.warn( + `You are attempting to render <${node.name!} ${ + clientAttribute.name + } />, but ${node.name!} is an Astro component. Astro components do not render in the client and should not have a hydration directive. Please use a framework component for client rendering.`, + ); + } + } + + const resolvedPath = resolvePath(matchedImport.path, file.path); + + if (hasClientOnlyDirective(node)) { + // Add this component to the metadata + metadata.clientOnlyComponents.push({ + exportName: matchedImport.name, + localName: '', + specifier: tagName, + resolvedPath, + }); + // Mutate node with additional island attributes + addClientOnlyMetadata(node, matchedImport, resolvedPath); + } else if (hasClientDirective(node)) { + // Add this component to the metadata + metadata.hydratedComponents.push({ + exportName: '*', + localName: '', + specifier: tagName, + resolvedPath, + }); + // Mutate node with additional island attributes + addClientMetadata(node, matchedImport, resolvedPath); + } else if (hasServerDeferDirective(node)) { + metadata.serverComponents.push({ + exportName: matchedImport.name, + localName: tagName, + specifier: matchedImport.path, + resolvedPath, + }); + // Mutate node with additional island attributes + addServerDeferMetadata(node, matchedImport, resolvedPath); + } + }); + + // Attach final metadata here, which can later be retrieved by `getAstroMetadata` + file.data.__astroMetadata = metadata; + }; +}; + +export function getAstroMetadata(file: VFile) { + return file.data.__astroMetadata as PluginMetadata['astro'] | undefined; +} + +type ImportSpecifier = { local: string; imported: string }; + +/** + * ``` + * import Foo from './Foo.jsx' + * import { Bar } from './Bar.jsx' + * import { Baz as Wiz } from './Bar.jsx' + * import * as Waz from './BaWazz.jsx' + * + * // => Map { + * // "./Foo.jsx" => Set { { local: "Foo", imported: "default" } }, + * // "./Bar.jsx" => Set { + * // { local: "Bar", imported: "Bar" } + * // { local: "Wiz", imported: "Baz" }, + * // }, + * // "./Waz.jsx" => Set { { local: "Waz", imported: "*" } }, + * // } + * ``` + */ +function parseImports(children: RootContent[]) { + // Map of import source to its imported specifiers + const imports = new Map>(); + + for (const child of children) { + if (child.type !== 'mdxjsEsm') continue; + + const body = child.data?.estree?.body; + if (!body) continue; + + for (const ast of body) { + if (ast.type !== 'ImportDeclaration') continue; + + const source = ast.source.value as string; + const specs: ImportSpecifier[] = ast.specifiers.map((spec) => { + switch (spec.type) { + case 'ImportDefaultSpecifier': + return { local: spec.local.name, imported: 'default' }; + case 'ImportNamespaceSpecifier': + return { local: spec.local.name, imported: '*' }; + case 'ImportSpecifier': { + return { + local: spec.local.name, + imported: + spec.imported.type === 'Identifier' + ? spec.imported.name + : String(spec.imported.value), + }; + } + default: + throw new Error('Unknown import declaration specifier: ' + spec); + } + }); + + // Get specifiers set from source or initialize a new one + let specSet = imports.get(source); + if (!specSet) { + specSet = new Set(); + imports.set(source, specSet); + } + + for (const spec of specs) { + specSet.add(spec); + } + } + } + + return imports; +} + +function isComponent(tagName: string) { + return ( + (tagName[0] && tagName[0].toLowerCase() !== tagName[0]) || + tagName.includes('.') || + /[^a-zA-Z]/.test(tagName[0]) + ); +} + +function hasClientDirective(node: MdxJsxFlowElementHast | MdxJsxTextElementHast) { + return node.attributes.some( + (attr) => attr.type === 'mdxJsxAttribute' && attr.name.startsWith('client:'), + ); +} + +function hasServerDeferDirective(node: MdxJsxFlowElementHast | MdxJsxTextElementHast) { + return node.attributes.some( + (attr) => attr.type === 'mdxJsxAttribute' && attr.name === 'server:defer', + ); +} + +function hasClientOnlyDirective(node: MdxJsxFlowElementHast | MdxJsxTextElementHast) { + return node.attributes.some( + (attr) => attr.type === 'mdxJsxAttribute' && attr.name === 'client:only', + ); +} + +type MatchedImport = { name: string; path: string }; + +/** + * ``` + * import Button from './Button.jsx' + *