Skip to content

Commit 14f1d49

Browse files
author
fightingcat
authored
Expose Babel config for @astro/react. (#10675)
1 parent e2a780a commit 14f1d49

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

.changeset/tall-wombats-clap.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@astrojs/react": minor
3+
---
4+
5+
Expose Babel config for @astro/react.

packages/integrations/react/src/index.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { AstroIntegration } from 'astro';
33
import { version as ReactVersion } from 'react-dom';
44
import type * as vite from 'vite';
55

6-
export type ReactIntegrationOptions = Pick<ViteReactPluginOptions, 'include' | 'exclude'> & {
6+
export type ReactIntegrationOptions = Pick<ViteReactPluginOptions, 'include' | 'exclude' | 'babel'> & {
77
experimentalReactChildren?: boolean;
88
};
99

@@ -46,6 +46,7 @@ function optionsPlugin(experimentalReactChildren: boolean): vite.Plugin {
4646
function getViteConfiguration({
4747
include,
4848
exclude,
49+
babel,
4950
experimentalReactChildren,
5051
}: ReactIntegrationOptions = {}) {
5152
return {
@@ -65,7 +66,7 @@ function getViteConfiguration({
6566
: '@astrojs/react/server-v17.js',
6667
],
6768
},
68-
plugins: [react({ include, exclude }), optionsPlugin(!!experimentalReactChildren)],
69+
plugins: [react({ include, exclude, babel }), optionsPlugin(!!experimentalReactChildren)],
6970
resolve: {
7071
dedupe: ['react', 'react-dom', 'react-dom/server'],
7172
},
@@ -89,6 +90,7 @@ function getViteConfiguration({
8990
export default function ({
9091
include,
9192
exclude,
93+
babel,
9294
experimentalReactChildren,
9395
}: ReactIntegrationOptions = {}): AstroIntegration {
9496
return {
@@ -97,7 +99,7 @@ export default function ({
9799
'astro:config:setup': ({ command, addRenderer, updateConfig, injectScript }) => {
98100
addRenderer(getRenderer());
99101
updateConfig({
100-
vite: getViteConfiguration({ include, exclude, experimentalReactChildren }),
102+
vite: getViteConfiguration({ include, exclude, babel, experimentalReactChildren }),
101103
});
102104
if (command === 'dev') {
103105
const preamble = FAST_REFRESH_PREAMBLE.replace(`__BASE__`, '/');

0 commit comments

Comments
 (0)