Skip to content

Commit dec088b

Browse files
L-Qundai-shi
andauthored
Instructions on how to enable the React Compiler in a Waku pro… (#857)
Background: #853 --------- Co-authored-by: Daishi Kato <[email protected]>
1 parent 20020a0 commit dec088b

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

docs/guides/react-compiler.mdx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
slug: guides/react-compiler
3+
title: Enabling React Compiler in Waku
4+
description: Learn how to enable the React Compiler in your Waku project using the Vite Plugin to optimize your React applications.
5+
---
6+
7+
The React Compiler is a build-time tool designed to optimize React applications automatically. This guide will show you how to enable the React Compiler by integrating it with the `@vitejs/plugin-react`.
8+
9+
```bash
10+
npm install -D @vitejs/plugin-react babel-plugin-react-compiler
11+
```
12+
13+
```ts
14+
// waku.config.ts
15+
import { defineConfig } from 'waku/config';
16+
import react from '@vitejs/plugin-react';
17+
18+
const ReactCompilerConfig = {};
19+
20+
const getConfig = () => ({
21+
plugins: [
22+
react({
23+
babel: {
24+
plugins: [['babel-plugin-react-compiler', ReactCompilerConfig]],
25+
},
26+
}),
27+
],
28+
});
29+
30+
export default defineConfig({
31+
unstable_viteConfigs: {
32+
'dev-main': getConfig,
33+
'build-client': getConfig,
34+
},
35+
});
36+
```
37+
38+
Check out [a working example](../../examples/05_compiler), or visit the [StackBlitz demo](https://stackblitz.com/github/dai-shi/waku/tree/main/examples/05_compiler) with Waku v0.21.12 and up.

0 commit comments

Comments
 (0)