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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

L-Qun
Copy link

@L-Qun L-Qun commented Aug 29, 2024

Background: #853

Copy link

vercel bot commented Aug 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
waku ⬜️ Ignored (Inspect) Visit Preview Aug 30, 2024 0:13am

Copy link

codesandbox-ci bot commented Aug 29, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

});
```

For a practical demonstration, visit this [StackBlitz demo](https://stackblitz.com/edit/github-ukt9tm?file=vite.config.ts) which provides a real-world example of the configuration in action.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the demo.

Suggested change
For a practical demonstration, visit this [StackBlitz demo](https://stackblitz.com/edit/github-ukt9tm?file=vite.config.ts) which provides a real-world example of the configuration in action.
For a practical demonstration, visit this [StackBlitz demo](https://stackblitz.com/edit/github-h4uxwo?file=vite.config.ts) which provides a real-world example of the configuration in action.

As I tried, removing "annotation" will cause errors. Can you please try it? I guess we should add it in the instruction above. What do you think? Do you think we can recommend it even with "annotation"?

Copy link
Author

@L-Qun L-Qun Aug 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

I believe we shouldn't add this restriction because if we add an "annotation", users will need add the "use memo" directive manually

I found the error is Error: __vite_ssr_import_1__.c is not a function, actually I encountered this error when I implement react compiler feature, I can try to fix it issue

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can try to fix it issue

That will be great.

Copy link
Author

@L-Qun L-Qun Aug 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

This issue occurs when I pass react compiler config in viteReact called by createRscViteServer. So in my implementation I only pass react compiler config in viteReact called by createMainViteServer

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we not need react compiler for server files?

My plan is to allow customizing vite config for each server in v0.22.0. Give me more time.

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`.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's build-time only.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

I copied it from React offical website

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I wonder if raw Vite app + React Compiler works in DEV mode. I don't think this is Waku specific.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dev mode is also a kind of build-time. built time in this context means it won't haveruntime cost, which will have no exta bundle size & cpu runs when you open browser

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
@dai-shi
Copy link
Owner

dai-shi commented Oct 4, 2024

let's revisit this after v0.22 is finished.

@dai-shi dai-shi marked this pull request as draft October 4, 2024 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants