summaryrefslogtreecommitdiff
path: root/packages/integrations/react/src
diff options
context:
space:
mode:
authorGravatar Matthew Phillips <matthew@skypack.dev> 2023-08-17 09:01:50 -0400
committerGravatar Matthew Phillips <matthew@skypack.dev> 2023-08-17 09:01:50 -0400
commit4843bff0d2deea68349901f80d5de59d22df7a9c (patch)
tree287682efccda51ab5c6ad9580fc9c388111b421b /packages/integrations/react/src
parentcbb77af978bd0dcee08ad2dcadadb032abc44dc1 (diff)
downloadastro-4843bff0d2deea68349901f80d5de59d22df7a9c.tar.gz
astro-4843bff0d2deea68349901f80d5de59d22df7a9c.tar.zst
astro-4843bff0d2deea68349901f80d5de59d22df7a9c.zip
Fix more conflicts
Diffstat (limited to 'packages/integrations/react/src')
-rw-r--r--packages/integrations/react/src/index.ts20
1 files changed, 8 insertions, 12 deletions
diff --git a/packages/integrations/react/src/index.ts b/packages/integrations/react/src/index.ts
index a318bb4c2..712b98610 100644
--- a/packages/integrations/react/src/index.ts
+++ b/packages/integrations/react/src/index.ts
@@ -4,10 +4,11 @@ import react, { type Options as ViteReactPluginOptions } from '@vitejs/plugin-re
import { appendForwardSlash } from '@astrojs/internal-helpers/path';
import type * as vite from 'vite';
-const FAST_REFRESH_PREAMBLE = react.preambleCode;
-
-
+export type ReactIntegrationOptions = Pick<ViteReactPluginOptions, 'include' | 'exclude'> & {
+ experimentalReactChildren?: boolean;
+};
+const FAST_REFRESH_PREAMBLE = react.preambleCode;
function getRenderer() {
return {
@@ -43,7 +44,7 @@ function optionsPlugin(experimentalReactChildren: boolean): vite.Plugin {
};
}
-function getViteConfiguration(experimentalReactChildren: boolean, { include, exclude }: Options = {}) {
+function getViteConfiguration({ include, exclude, experimentalReactChildren }: ReactIntegrationOptions = {}) {
return {
optimizeDeps: {
include: [
@@ -63,7 +64,7 @@ function getViteConfiguration(experimentalReactChildren: boolean, { include, exc
},
plugins: [
react({ include, exclude }),
- optionsPlugin(experimentalReactChildren)
+ optionsPlugin(!!experimentalReactChildren)
],
resolve: {
dedupe: ['react', 'react-dom', 'react-dom/server'],
@@ -84,22 +85,17 @@ function getViteConfiguration(experimentalReactChildren: boolean, { include, exc
};
}
-export type ReactIntegrationOptions = Pick<ViteReactPluginOptions, 'include' | 'exclude'> & {
- experimentalReactChildren: boolean;
-};
export default function ({
include,
exclude,
experimentalReactChildren
-}: ReactIntegrationOptions = {
- experimentalReactChildren: false
-}): AstroIntegration {
+}: ReactIntegrationOptions = {}): AstroIntegration {
return {
name: '@astrojs/react',
hooks: {
'astro:config:setup': ({ config, command, addRenderer, updateConfig, injectScript }) => {
addRenderer(getRenderer());
- updateConfig({ vite: getViteConfiguration(experimentalReactChildren, { include, exclude }) });
+ updateConfig({ vite: getViteConfiguration({ include, exclude, experimentalReactChildren }) });
if (command === 'dev') {
const preamble = FAST_REFRESH_PREAMBLE.replace(
`__BASE__`,