Support Bun by adjusting how @babel/plugin-transform-react-jsx
is imported. (#8007)
* Support bun/other tooling that respects `__esModule` * Add changeset file
This commit is contained in:
parent
e65b5b5495
commit
58b121d42a
3 changed files with 15 additions and 12 deletions
6
.changeset/quick-actors-sing.md
Normal file
6
.changeset/quick-actors-sing.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
'@astrojs/preact': patch
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Support Bun by adjusting how `@babel/plugin-transform-react-jsx` is imported.
|
|
@ -3,10 +3,9 @@ const renderer = {
|
|||
serverEntrypoint: 'astro/jsx/server.js',
|
||||
jsxImportSource: 'astro',
|
||||
jsxTransformOptions: async () => {
|
||||
const {
|
||||
default: { default: jsx },
|
||||
// @ts-expect-error
|
||||
} = await import('@babel/plugin-transform-react-jsx');
|
||||
// @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: [
|
||||
|
|
|
@ -7,10 +7,9 @@ function getRenderer(development: boolean): AstroRenderer {
|
|||
serverEntrypoint: '@astrojs/preact/server.js',
|
||||
jsxImportSource: 'preact',
|
||||
jsxTransformOptions: async () => {
|
||||
const {
|
||||
default: { default: jsx },
|
||||
// @ts-expect-error types not found
|
||||
} = await import('@babel/plugin-transform-react-jsx');
|
||||
const plugin = await import('@babel/plugin-transform-react-jsx');
|
||||
const jsx = plugin.default?.default ?? plugin.default;
|
||||
return {
|
||||
plugins: [jsx({}, { runtime: 'automatic', importSource: 'preact' })],
|
||||
};
|
||||
|
@ -25,10 +24,9 @@ function getCompatRenderer(development: boolean): AstroRenderer {
|
|||
serverEntrypoint: '@astrojs/preact/server.js',
|
||||
jsxImportSource: 'react',
|
||||
jsxTransformOptions: async () => {
|
||||
const {
|
||||
default: { default: jsx },
|
||||
// @ts-expect-error types not found
|
||||
} = await import('@babel/plugin-transform-react-jsx');
|
||||
const plugin = await import('@babel/plugin-transform-react-jsx');
|
||||
const jsx = plugin.default?.default ?? plugin.default;
|
||||
return {
|
||||
plugins: [
|
||||
jsx({}, { runtime: 'automatic', importSource: 'preact/compat' }),
|
||||
|
|
Loading…
Reference in a new issue