-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
161 additions
and
190 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
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,21 +1,11 @@ | ||
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
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.