Skip to content

Commit c8fa782

Browse files
committed
chore: hack with applyToEnvironment
1 parent e851bf8 commit c8fa782

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

packages/plugin-rsc/examples/basic/vite.config.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import assert from 'node:assert'
22
import rsc, { transformHoistInlineDirective } from '@vitejs/plugin-rsc'
33
import tailwindcss from '@tailwindcss/vite'
4-
import react, { type ViteReactPluginApi } from '@vitejs/plugin-react'
4+
import react from '@vitejs/plugin-react'
55
import { type Plugin, defineConfig, normalizePath, parseAstAsync } from 'vite'
66
import inspect from 'vite-plugin-inspect'
77
import path from 'node:path'
@@ -23,20 +23,12 @@ export default defineConfig({
2323
plugins: [
2424
tailwindcss(),
2525
process.env.TEST_REACT_COMPILER
26-
? [
27-
react({ babel: { plugins: ['babel-plugin-react-compiler'] } }),
28-
// skip react compiler in non CSR environments
29-
{
30-
name: 'react-babel-override',
31-
api: {
32-
reactBabel: (babelConfig, context) => {
33-
if (context.ssr) {
34-
babelConfig.plugins = []
35-
}
36-
},
37-
} satisfies ViteReactPluginApi,
38-
},
39-
]
26+
? (react({
27+
babel: { plugins: ['babel-plugin-react-compiler'] },
28+
}).map((p) => ({
29+
...p,
30+
applyToEnvironment: (e: any) => e.name === 'client',
31+
})) as any)
4032
: react(),
4133
vitePluginUseCache(),
4234
rsc({

0 commit comments

Comments
 (0)