Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDX integration v3 #10935

Merged
merged 16 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/blue-geese-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/mdx": patch
---

Simplifies plain MDX components as hast element nodes to further improve HTML string inlining for the `optimize` option
5 changes: 5 additions & 0 deletions .changeset/chilly-items-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": patch
---

Improves the error message when failed to render MDX components
5 changes: 5 additions & 0 deletions .changeset/fresh-masks-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/mdx": major
---

Refactors the MDX transformation to rely only on the unified pipeline. Babel and esbuild transformations are removed, which should result in faster build times. The refactor requires using Astro v4.8.0 but no other changes are necessary.
5 changes: 5 additions & 0 deletions .changeset/friendly-plants-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": minor
---

Exports `astro/jsx/rehype.js` with utilities to generate an Astro metadata object
5 changes: 5 additions & 0 deletions .changeset/large-glasses-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/mdx": patch
---

Allows Vite plugins to transform `.mdx` files before the MDX plugin transforms it
7 changes: 7 additions & 0 deletions .changeset/slimy-cobras-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@astrojs/mdx": major
---

Allows integrations after the MDX integration to update `markdown.remarkPlugins` and `markdown.rehypePlugins`, and have the plugins work in MDX too.

If your integration relies on Astro's previous behavior that prevents integrations from adding remark/rehype plugins for MDX, you will now need to configure `@astrojs/mdx` with `extendMarkdownConfig: false` and explicitly specify any `remarkPlugins` and `rehypePlugins` options instead.
5 changes: 5 additions & 0 deletions .changeset/small-oranges-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/mdx": major
---

Renames the `optimize.customComponentNames` option to `optimize.ignoreElementNames` to better reflect its usecase. Its behaviour is not changed and should continue to work as before.
5 changes: 5 additions & 0 deletions .changeset/smart-rats-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/mdx": patch
---

Updates the `optimize` option to group static sibling nodes as a `<Fragment />`. This reduces the number of AST nodes and simplifies runtime rendering of MDX pages.
5 changes: 5 additions & 0 deletions .changeset/sweet-goats-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/mdx": major
---

Replaces the internal `remark-images-to-component` plugin with `rehype-images-to-component` to let users use additional rehype plugins for images
5 changes: 5 additions & 0 deletions .changeset/tame-avocados-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/mdx": patch
---

Tags the MDX component export for quicker component checks while rendering
5 changes: 5 additions & 0 deletions .changeset/violet-snails-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/mdx": patch
---

Fixes `export const components` keys detection for the `optimize` option
5 changes: 5 additions & 0 deletions .changeset/young-chicken-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/mdx": patch
---

Improves `optimize` handling for MDX components with attributes and inline MDX components
2 changes: 2 additions & 0 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@
"astro-scripts": "workspace:*",
"cheerio": "1.0.0-rc.12",
"eol": "^0.9.1",
"mdast-util-mdx": "^3.0.0",
"mdast-util-mdx-jsx": "^3.1.2",
"memfs": "^4.9.1",
"node-mocks-http": "^1.14.1",
"parse-srcset": "^1.0.2",
Expand Down
3 changes: 3 additions & 0 deletions packages/astro/src/jsx/babel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ function addClientOnlyMetadata(
}
}

/**
* @deprecated This plugin is no longer used. Remove in Astro 5.0
*/
export default function astroJSX(): PluginObj {
return {
visitor: {
Expand Down
Loading
Loading