forked from withastro/astro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor MDX transformJSX handling (withastro#10688)
- Loading branch information
1 parent
6cb3eef
commit 85ea333
Showing
10 changed files
with
198 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"astro": patch | ||
--- | ||
|
||
Marks renderer `jsxImportSource` and `jsxTransformOptions` options as deprecated as they are no longer used since Astro 3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,11 @@ | ||
const renderer = { | ||
import type { AstroRenderer } from '../@types/astro.js'; | ||
import { jsxTransformOptions } from './transform-options.js'; | ||
|
||
const renderer: AstroRenderer = { | ||
name: 'astro:jsx', | ||
serverEntrypoint: 'astro/jsx/server.js', | ||
jsxImportSource: 'astro', | ||
jsxTransformOptions: async () => { | ||
// @ts-expect-error types not found | ||
const plugin = await import('@babel/plugin-transform-react-jsx'); | ||
const jsx = plugin.default?.default ?? plugin.default; | ||
const { default: astroJSX } = await import('./babel.js'); | ||
return { | ||
plugins: [ | ||
astroJSX(), | ||
jsx({}, { throwIfNamespace: false, runtime: 'automatic', importSource: 'astro' }), | ||
], | ||
}; | ||
}, | ||
jsxTransformOptions, | ||
}; | ||
|
||
export default renderer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { JSXTransformConfig } from '../@types/astro.js'; | ||
|
||
export async function jsxTransformOptions(): Promise<JSXTransformConfig> { | ||
// @ts-expect-error types not found | ||
const plugin = await import('@babel/plugin-transform-react-jsx'); | ||
const jsx = plugin.default?.default ?? plugin.default; | ||
const { default: astroJSX } = await import('./babel.js'); | ||
return { | ||
plugins: [ | ||
astroJSX(), | ||
jsx({}, { throwIfNamespace: false, runtime: 'automatic', importSource: 'astro' }), | ||
], | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# vite-plugin-jsx | ||
# vite-plugin-mdx | ||
|
||
Modifies Vite’s built-in JSX behavior to allow for React, Preact, and Solid.js to coexist and all use `.jsx` and `.tsx` extensions. | ||
Handles transforming MDX via the `astro:jsx` renderer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.