mirror of
https://github.com/withastro/astro.git
synced 2025-02-17 22:44:24 -05:00
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',
|
serverEntrypoint: 'astro/jsx/server.js',
|
||||||
jsxImportSource: 'astro',
|
jsxImportSource: 'astro',
|
||||||
jsxTransformOptions: async () => {
|
jsxTransformOptions: async () => {
|
||||||
const {
|
// @ts-expect-error types not found
|
||||||
default: { default: jsx },
|
const plugin = await import('@babel/plugin-transform-react-jsx');
|
||||||
// @ts-expect-error
|
const jsx = plugin.default?.default ?? plugin.default;
|
||||||
} = await import('@babel/plugin-transform-react-jsx');
|
|
||||||
const { default: astroJSX } = await import('./babel.js');
|
const { default: astroJSX } = await import('./babel.js');
|
||||||
return {
|
return {
|
||||||
plugins: [
|
plugins: [
|
||||||
|
|
|
@ -7,10 +7,9 @@ function getRenderer(development: boolean): AstroRenderer {
|
||||||
serverEntrypoint: '@astrojs/preact/server.js',
|
serverEntrypoint: '@astrojs/preact/server.js',
|
||||||
jsxImportSource: 'preact',
|
jsxImportSource: 'preact',
|
||||||
jsxTransformOptions: async () => {
|
jsxTransformOptions: async () => {
|
||||||
const {
|
// @ts-expect-error types not found
|
||||||
default: { default: jsx },
|
const plugin = await import('@babel/plugin-transform-react-jsx');
|
||||||
// @ts-expect-error types not found
|
const jsx = plugin.default?.default ?? plugin.default;
|
||||||
} = await import('@babel/plugin-transform-react-jsx');
|
|
||||||
return {
|
return {
|
||||||
plugins: [jsx({}, { runtime: 'automatic', importSource: 'preact' })],
|
plugins: [jsx({}, { runtime: 'automatic', importSource: 'preact' })],
|
||||||
};
|
};
|
||||||
|
@ -25,10 +24,9 @@ function getCompatRenderer(development: boolean): AstroRenderer {
|
||||||
serverEntrypoint: '@astrojs/preact/server.js',
|
serverEntrypoint: '@astrojs/preact/server.js',
|
||||||
jsxImportSource: 'react',
|
jsxImportSource: 'react',
|
||||||
jsxTransformOptions: async () => {
|
jsxTransformOptions: async () => {
|
||||||
const {
|
// @ts-expect-error types not found
|
||||||
default: { default: jsx },
|
const plugin = await import('@babel/plugin-transform-react-jsx');
|
||||||
// @ts-expect-error types not found
|
const jsx = plugin.default?.default ?? plugin.default;
|
||||||
} = await import('@babel/plugin-transform-react-jsx');
|
|
||||||
return {
|
return {
|
||||||
plugins: [
|
plugins: [
|
||||||
jsx({}, { runtime: 'automatic', importSource: 'preact/compat' }),
|
jsx({}, { runtime: 'automatic', importSource: 'preact/compat' }),
|
||||||
|
|
Loading…
Add table
Reference in a new issue