Skip to content

Commit 09d7d3e

Browse files
committed
patch: vite:react-babel
1 parent c5c774e commit 09d7d3e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

packages/plugin-rsc/e2e/basic.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ test.describe('dev-react-compiler', () => {
5454
},
5555
})
5656
defineTest(f)
57+
58+
// TODO: actually verify compiler is enabled in client environment
5759
})
5860

5961
test.describe('build-react-compiler', () => {

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,23 @@ export default defineConfig({
2323
plugins: [
2424
tailwindcss(),
2525
process.env.TEST_REACT_COMPILER
26-
? react({ babel: { plugins: ['babel-plugin-react-compiler'] } })
26+
? [
27+
react({ babel: { plugins: ['babel-plugin-react-compiler'] } }),
28+
{
29+
name: 'patch-react-transform',
30+
configResolved(config) {
31+
const plugin: any = config.plugins.find(
32+
(p) => p.name === 'vite:react-babel',
33+
)
34+
const original = plugin.transform.handler
35+
plugin.transform.handler = function () {
36+
if (this.environment.name === 'client') {
37+
return original.apply(this, arguments)
38+
}
39+
}
40+
},
41+
},
42+
]
2743
: react(),
2844
vitePluginUseCache(),
2945
rsc({

0 commit comments

Comments
 (0)