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

Question: Recommended approach for adoption #29

Open
jasekiw opened this issue Jul 17, 2023 · 4 comments
Open

Question: Recommended approach for adoption #29

jasekiw opened this issue Jul 17, 2023 · 4 comments

Comments

@jasekiw
Copy link

jasekiw commented Jul 17, 2023

I am really intrigued that there is a version of react forget I can play with.

I am interested in starting to use this on a production application with around 40k lines of code.

Would you say this library is production ready? What would be the recommended approach for adopting this library into a production system like this? I imagine gradual adoption would be the safest route. ex. use it on all new components.

Thanks for this awesome library!

@lxsmnsyc
Copy link
Owner

lxsmnsyc commented Jul 17, 2023

There's two ways to opt-in or out of Forgetti partially:

  • You can use include to define which parts of your project should be compiled.
  • Use /* @forgetti skip */ to disable optimization on selected parts of your code.

This requires a lot of testing. I'm not sure how it went in production environment but maybe @SukkaW could share some of his insights since he has tested this more than I do.

@jasekiw
Copy link
Author

jasekiw commented Jul 18, 2023

I probably want to opt in on a component basis. Would it be possible to have a /* @forgetti include*/ or /* @forgetti enable */. Otherwise I might have to do MyComponent.forgetti.tsx for the include path to work.

I'm interested to see what @SukkaW has to say regarding his experience.

@lxsmnsyc
Copy link
Owner

Well the inverse is quite difficult to do because it has to match the include config first, which is kinda counter-intuitive.

@SukkaW
Copy link
Contributor

SukkaW commented Jul 19, 2023

I heavily rely on /* @forgetti skip */ and webpack loader's test, include and exclude for the gradual adoption, because:

  • Many react libraries do not follow the rule of hooks
    • Nearly all TanStack's libraries will not work with forgetti (I have discussed this with @lxsmnsyc on his discord server before about TanStack Table React). You will likely need to wrap them with your own hook and exclude it from the optimization using /* @forgetti skip */.
  • forgetti is not compatible with React Server Component (RSC), which requires excluding them from the forgetti-loader.
  • forgetti still has various transformation issues and edge cases with certain expressions. Therefore, you should expect can not read property of undefined errors a lot during the adoption process.
    • Debugging these errors and creating a minimal reproduction can be quite challenging. But without minimal reproduction, it is hard for maintainers to fix the issue.

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

No branches or pull requests

3 participants