@@ -21,21 +21,21 @@ const versionsConfig = {
21
21
18 : {
22
22
server : '@astrojs/react/server.js' ,
23
23
client : '@astrojs/react/client.js' ,
24
- externals : [ 'react-dom/server' , 'react-dom/client' ]
24
+ externals : [ 'react-dom/server' , 'react-dom/client' ] ,
25
25
} ,
26
26
19 : {
27
27
server : '@astrojs/react/server.js' ,
28
28
client : '@astrojs/react/client.js' ,
29
- externals : [ 'react-dom/server' , 'react-dom/client' ]
30
- }
29
+ externals : [ 'react-dom/server' , 'react-dom/client' ] ,
30
+ } ,
31
31
} ;
32
32
33
- type SupportedReactVersion = keyof ( typeof versionsConfig ) ;
33
+ type SupportedReactVersion = keyof typeof versionsConfig ;
34
34
type ReactVersionConfig = ( typeof versionsConfig ) [ SupportedReactVersion ] ;
35
35
36
36
function getReactMajorVersion ( ) : number {
37
37
const matches = / \d + \. / . exec ( ReactVersion ) ;
38
- if ( ! matches ) {
38
+ if ( ! matches ) {
39
39
return NaN ;
40
40
}
41
41
return Number ( matches [ 0 ] ) ;
@@ -75,12 +75,10 @@ function optionsPlugin(experimentalReactChildren: boolean): vite.Plugin {
75
75
} ;
76
76
}
77
77
78
- function getViteConfiguration ( {
79
- include,
80
- exclude,
81
- babel,
82
- experimentalReactChildren,
83
- } : ReactIntegrationOptions = { } , reactConfig : ReactVersionConfig ) {
78
+ function getViteConfiguration (
79
+ { include, exclude, babel, experimentalReactChildren } : ReactIntegrationOptions = { } ,
80
+ reactConfig : ReactVersionConfig
81
+ ) {
84
82
return {
85
83
optimizeDeps : {
86
84
include : [
@@ -90,9 +88,7 @@ function getViteConfiguration({
90
88
'react/jsx-dev-runtime' ,
91
89
'react-dom' ,
92
90
] ,
93
- exclude : [
94
- reactConfig . server ,
95
- ] ,
91
+ exclude : [ reactConfig . server ] ,
96
92
} ,
97
93
plugins : [ react ( { include, exclude, babel } ) , optionsPlugin ( ! ! experimentalReactChildren ) ] ,
98
94
resolve : {
@@ -119,7 +115,7 @@ export default function ({
119
115
experimentalReactChildren,
120
116
} : ReactIntegrationOptions = { } ) : AstroIntegration {
121
117
const majorVersion = getReactMajorVersion ( ) ;
122
- if ( isUnsupportedVersion ( majorVersion ) ) {
118
+ if ( isUnsupportedVersion ( majorVersion ) ) {
123
119
throw new Error ( `Unsupported React version: ${ majorVersion } .` ) ;
124
120
}
125
121
const versionConfig = versionsConfig [ majorVersion as SupportedReactVersion ] ;
@@ -130,7 +126,10 @@ export default function ({
130
126
'astro:config:setup' : ( { command, addRenderer, updateConfig, injectScript } ) => {
131
127
addRenderer ( getRenderer ( versionConfig ) ) ;
132
128
updateConfig ( {
133
- vite : getViteConfiguration ( { include, exclude, babel, experimentalReactChildren } , versionConfig ) ,
129
+ vite : getViteConfiguration (
130
+ { include, exclude, babel, experimentalReactChildren } ,
131
+ versionConfig
132
+ ) ,
134
133
} ) ;
135
134
if ( command === 'dev' ) {
136
135
const preamble = FAST_REFRESH_PREAMBLE . replace ( `__BASE__` , '/' ) ;
0 commit comments