diff options
author | 2023-08-09 12:11:41 -0700 | |
---|---|---|
committer | 2023-08-09 14:11:41 -0500 | |
commit | 58b121d42a9f58a5a992f0c378b036f37e9715fc (patch) | |
tree | 3ea76e48c5e4777c22af5fe417fd91468bd548a5 /packages/integrations/preact/src | |
parent | e65b5b54950978957b75873ad4f493b3be26f3ea (diff) | |
download | astro-58b121d42a9f58a5a992f0c378b036f37e9715fc.tar.gz astro-58b121d42a9f58a5a992f0c378b036f37e9715fc.tar.zst astro-58b121d42a9f58a5a992f0c378b036f37e9715fc.zip |
Support Bun by adjusting how `@babel/plugin-transform-react-jsx` is imported. (#8007)
* Support bun/other tooling that respects `__esModule`
* Add changeset file
Diffstat (limited to 'packages/integrations/preact/src')
-rw-r--r-- | packages/integrations/preact/src/index.ts | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/packages/integrations/preact/src/index.ts b/packages/integrations/preact/src/index.ts index 4f4b0ee79..98a2dd205 100644 --- a/packages/integrations/preact/src/index.ts +++ b/packages/integrations/preact/src/index.ts @@ -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'); + // @ts-expect-error types not found + 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'); + // @ts-expect-error types not found + const plugin = await import('@babel/plugin-transform-react-jsx'); + const jsx = plugin.default?.default ?? plugin.default; return { plugins: [ jsx({}, { runtime: 'automatic', importSource: 'preact/compat' }), |