Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instructions on how to enable the React Compiler in a Waku pro… #857

Merged
merged 4 commits into from
Dec 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions docs/guides/react-compiler.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
slug: guides/react-compiler
title: Enabling React Compiler in Waku
description: Learn how to enable the React Compiler in your Waku project using the Vite Plugin to optimize your React applications.
---

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`.
dai-shi marked this conversation as resolved.
Show resolved Hide resolved

dai-shi marked this conversation as resolved.
Show resolved Hide resolved
```bash
npm install -D @vitejs/plugin-react babel-plugin-react-compiler
```

```ts
// waku.config.ts
import { defineConfig } from 'waku/config';
import react from '@vitejs/plugin-react';

const ReactCompilerConfig = {};

const getConfig = () => ({
plugins: [
react({
babel: {
plugins: [['babel-plugin-react-compiler', ReactCompilerConfig]],
},
}),
],
});

export default defineConfig({
unstable_viteConfigs: {
'dev-main': getConfig,
'build-client': getConfig,
},
});
```

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.
Loading