summaryrefslogtreecommitdiff
path: root/packages/integrations/react/src
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthewp@users.noreply.github.com> 2024-05-07 17:13:57 +0000
committerGravatar astrobot-houston <fred+astrobot@astro.build> 2024-05-07 17:13:57 +0000
commitcceeafb62adf96b6f52b87024d774a30adf7f376 (patch)
tree69a539f1e7be0c7590700ac3759b8234fa6b45e1 /packages/integrations/react/src
parentd47baa466aaeedde9c79ed5375d0be34762ac8b6 (diff)
downloadastro-cceeafb62adf96b6f52b87024d774a30adf7f376.tar.gz
astro-cceeafb62adf96b6f52b87024d774a30adf7f376.tar.zst
astro-cceeafb62adf96b6f52b87024d774a30adf7f376.zip
[ci] format
Diffstat (limited to 'packages/integrations/react/src')
-rw-r--r--packages/integrations/react/src/index.ts31
1 files changed, 15 insertions, 16 deletions
diff --git a/packages/integrations/react/src/index.ts b/packages/integrations/react/src/index.ts
index 62803e788..838640239 100644
--- a/packages/integrations/react/src/index.ts
+++ b/packages/integrations/react/src/index.ts
@@ -21,21 +21,21 @@ const versionsConfig = {
18: {
server: '@astrojs/react/server.js',
client: '@astrojs/react/client.js',
- externals: ['react-dom/server', 'react-dom/client']
+ externals: ['react-dom/server', 'react-dom/client'],
},
19: {
server: '@astrojs/react/server.js',
client: '@astrojs/react/client.js',
- externals: ['react-dom/server', 'react-dom/client']
- }
+ externals: ['react-dom/server', 'react-dom/client'],
+ },
};
-type SupportedReactVersion = keyof (typeof versionsConfig);
+type SupportedReactVersion = keyof typeof versionsConfig;
type ReactVersionConfig = (typeof versionsConfig)[SupportedReactVersion];
function getReactMajorVersion(): number {
const matches = /\d+\./.exec(ReactVersion);
- if(!matches) {
+ if (!matches) {
return NaN;
}
return Number(matches[0]);
@@ -75,12 +75,10 @@ function optionsPlugin(experimentalReactChildren: boolean): vite.Plugin {
};
}
-function getViteConfiguration({
- include,
- exclude,
- babel,
- experimentalReactChildren,
-}: ReactIntegrationOptions = {}, reactConfig: ReactVersionConfig) {
+function getViteConfiguration(
+ { include, exclude, babel, experimentalReactChildren }: ReactIntegrationOptions = {},
+ reactConfig: ReactVersionConfig
+) {
return {
optimizeDeps: {
include: [
@@ -90,9 +88,7 @@ function getViteConfiguration({
'react/jsx-dev-runtime',
'react-dom',
],
- exclude: [
- reactConfig.server,
- ],
+ exclude: [reactConfig.server],
},
plugins: [react({ include, exclude, babel }), optionsPlugin(!!experimentalReactChildren)],
resolve: {
@@ -119,7 +115,7 @@ export default function ({
experimentalReactChildren,
}: ReactIntegrationOptions = {}): AstroIntegration {
const majorVersion = getReactMajorVersion();
- if(isUnsupportedVersion(majorVersion)) {
+ if (isUnsupportedVersion(majorVersion)) {
throw new Error(`Unsupported React version: ${majorVersion}.`);
}
const versionConfig = versionsConfig[majorVersion as SupportedReactVersion];
@@ -130,7 +126,10 @@ export default function ({
'astro:config:setup': ({ command, addRenderer, updateConfig, injectScript }) => {
addRenderer(getRenderer(versionConfig));
updateConfig({
- vite: getViteConfiguration({ include, exclude, babel, experimentalReactChildren }, versionConfig),
+ vite: getViteConfiguration(
+ { include, exclude, babel, experimentalReactChildren },
+ versionConfig
+ ),
});
if (command === 'dev') {
const preamble = FAST_REFRESH_PREAMBLE.replace(`__BASE__`, '/');