Skip to content

Commit b970cce

Browse files
authored
Merge pull request #94 from reactjs/sync-eb174dd9
2 parents 102b6d9 + 21626d7 commit b970cce

File tree

6 files changed

+173
-32
lines changed

6 files changed

+173
-32
lines changed

public/.well-known/atproto-did

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
did:plc:uorpbnp2q32vuvyeruwauyhe
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
title: "React Compiler Beta Release"
3+
author: Lauren Tan
4+
date: 2024/10/21
5+
description: At React Conf 2024, we announced the experimental release of React Compiler, a build-time tool that optimizes your React app through automatic memoization. In this post, we want to share what's next for open source, and our progress on the compiler.
6+
7+
---
8+
9+
October 21, 2024 by [Lauren Tan](https://twitter.com/potetotes).
10+
11+
---
12+
13+
<Intro>
14+
15+
The React team is excited to share new updates:
16+
17+
</Intro>
18+
19+
1. We're publishing React Compiler Beta today, so that early adopters and library maintainers can try it and provide feedback.
20+
2. We're officially supporting React Compiler for apps on React 17+, through an optional `react-compiler-runtime` package.
21+
3. We're opening up public membership of the [React Compiler Working Group](https://github.com/reactwg/react-compiler) to prepare the community for gradual adoption of the compiler.
22+
23+
---
24+
25+
At [React Conf 2024](/blog/2024/05/22/react-conf-2024-recap), we announced the experimental release of React Compiler, a build-time tool that optimizes your React app through automatic memoization. [You can find an introduction to React Compiler here](/learn/react-compiler).
26+
27+
Since the first release, we've fixed numerous bugs reported by the React community, received several high quality bug fixes and contributions[^1] to the compiler, made the compiler more resilient to the broad diversity of JavaScript patterns, and have continued to roll out the compiler more widely at Meta.
28+
29+
In this post, we want to share what's next for React Compiler.
30+
31+
## Try React Compiler Beta today {/*try-react-compiler-beta-today*/}
32+
33+
At [React India 2024](https://www.youtube.com/watch?v=qd5yk2gxbtg), we shared an update on React Compiler. Today, we are excited to announce a new Beta release of React Compiler and ESLint plugin. New betas are published to npm using the `@beta` tag.
34+
35+
To install React Compiler Beta:
36+
37+
<TerminalBlock>
38+
npm install -D babel-plugin-react-compiler@beta eslint-plugin-react-compiler@beta
39+
</TerminalBlock>
40+
41+
Or, if you're using Yarn:
42+
43+
<TerminalBlock>
44+
yarn add -D babel-plugin-react-compiler@beta eslint-plugin-react-compiler@beta
45+
</TerminalBlock>
46+
47+
You can watch [Sathya Gunasekaran's](https://twitter.com/_gsathya) talk at React India here:
48+
49+
<YouTubeIframe src="https://www.youtube.com/embed/qd5yk2gxbtg" />
50+
51+
## We recommend everyone use the React Compiler linter today {/*we-recommend-everyone-use-the-react-compiler-linter-today*/}
52+
53+
React Compiler’s ESLint plugin helps developers proactively identify and correct [Rules of React](/reference/rules) violations. **We strongly recommend everyone use the linter today**. The linter does not require that you have the compiler installed, so you can use it independently, even if you are not ready to try out the compiler.
54+
55+
To install the linter only:
56+
57+
<TerminalBlock>
58+
npm install -D eslint-plugin-react-compiler@beta
59+
</TerminalBlock>
60+
61+
Or, if you're using Yarn:
62+
63+
<TerminalBlock>
64+
yarn add -D eslint-plugin-react-compiler@beta
65+
</TerminalBlock>
66+
67+
After installation you can enable the linter by [adding it to your ESLint config](/learn/react-compiler#installing-eslint-plugin-react-compiler). Using the linter helps identify Rules of React breakages, making it easier to adopt the compiler when it's fully released.
68+
69+
## Backwards Compatibility {/*backwards-compatibility*/}
70+
71+
React Compiler produces code that depends on runtime APIs added in React 19, but we've since added support for the compiler to also work with React 17 and 18. If you are not on React 19 yet, in the Beta release you can now try out React Compiler by specifying a minimum `target` in your compiler config, and adding `react-compiler-runtime` as a dependency. [You can find docs on this here](/learn/react-compiler#using-react-compiler-with-react-17-or-18).
72+
73+
## Using React Compiler in libraries {/*using-react-compiler-in-libraries*/}
74+
75+
Our initial release was focused on identifying major issues with using the compiler in applications. We've gotten great feedback and have substantially improved the compiler since then. We're now ready for broad feedback from the community, and for library authors to try out the compiler to improve performance and the developer experience of maintaining your library.
76+
77+
React Compiler can also be used to compile libraries. Because React Compiler needs to run on the original source code prior to any code transformations, it is not possible for an application's build pipeline to compile the libraries they use. Hence, our recommendation is for library maintainers to independently compile and test their libraries with the compiler, and ship compiled code to npm.
78+
79+
Because your code is pre-compiled, users of your library will not need to have the compiler enabled in order to benefit from the automatic memoization applied to your library. If your library targets apps not yet on React 19, specify a minimum `target` and add `react-compiler-runtime` as a direct dependency. The runtime package will use the correct implementation of APIs depending on the application's version, and polyfill the missing APIs if necessary.
80+
81+
[You can find more docs on this here.](/learn/react-compiler#using-the-compiler-on-libraries)
82+
83+
## Opening up React Compiler Working Group to everyone {/*opening-up-react-compiler-working-group-to-everyone*/}
84+
85+
We previously announced the invite-only [React Compiler Working Group](https://github.com/reactwg/react-compiler) at React Conf to provide feedback, ask questions, and collaborate on the compiler's experimental release.
86+
87+
From today, together with the Beta release of React Compiler, we are opening up Working Group membership to everyone. The goal of the React Compiler Working Group is to prepare the ecosystem for a smooth, gradual adoption of React Compiler by existing applications and libraries. Please continue to file bug reports in the [React repo](https://github.com/facebook/react), but please leave feedback, ask questions, or share ideas in the [Working Group discussion forum](https://github.com/reactwg/react-compiler/discussions).
88+
89+
The core team will also use the discussions repo to share our research findings. As the Stable Release gets closer, any important information will also be posted on this forum.
90+
91+
## React Compiler at Meta {/*react-compiler-at-meta*/}
92+
93+
At [React Conf](/blog/2024/05/22/react-conf-2024-recap), we shared that our rollout of the compiler on Quest Store and Instagram were successful. Since then, we've deployed React Compiler across several more major web apps at Meta, including [Facebook](https://www.facebook.com) and [Threads](https://www.threads.net). That means if you've used any of these apps recently, you may have had your experience powered by the compiler. We were able to onboard these apps onto the compiler with few code changes required, in a monorepo with more than 100,000 React components.
94+
95+
We've seen notable performance improvements across all of these apps. As we've rolled out, we're continuing to see results on the order of [the wins we shared previously at ReactConf](https://youtu.be/lyEKhv8-3n0?t=3223). These apps have already been heavily hand tuned and optimized by Meta engineers and React experts over the years, so even improvements on the order of a few percent are a huge win for us.
96+
97+
We also expected developer productivity wins from React Compiler. To measure this, we collaborated with our data science partners at Meta[^2] to conduct a thorough statistical analysis of the impact of manual memoization on productivity. Before rolling out the compiler at Meta, we discovered that only about 8% of React pull requests used manual memoization and that these pull requests took 31-46% longer to author[^3]. This confirmed our intuition that manual memoization introduces cognitive overhead, and we anticipate that React Compiler will lead to more efficient code authoring and review. Notably, React Compiler also ensures that *all* code is memoized by default, not just the (in our case) 8% where developers explicitly apply memoization.
98+
99+
## Roadmap to Stable {/*roadmap-to-stable*/}
100+
101+
*This is not a final roadmap, and is subject to change.*
102+
103+
We intend to ship a Release Candidate of the compiler in the near future following the Beta release, when the majority of apps and libraries that follow the Rules of React have been proven to work well with the compiler. After a period of final feedback from the community, we plan on a Stable Release for the compiler. The Stable Release will mark the beginning of a new foundation for React, and all apps and libraries will be strongly recommended to use the compiler and ESLint plugin.
104+
105+
* ✅ Experimental: Released at React Conf 2024, primarily for feedback from early adopters.
106+
* ✅ Public Beta: Available today, for feedback from the wider community.
107+
* 🚧 Release Candidate (RC): React Compiler works for the majority of rule-following apps and libraries without issue.
108+
* 🚧 General Availability: After final feedback period from the community.
109+
110+
These releases also include the compiler's ESLint plugin, which surfaces diagnostics statically analyzed by the compiler. We plan to combine the existing eslint-plugin-react-hooks plugin with the compiler's ESLint plugin, so only one plugin needs to be installed.
111+
112+
Post-Stable, we plan to add more compiler optimizations and improvements. This includes both continual improvements to automatic memoization, and new optimizations altogether, with minimal to no change of product code. Upgrading to each new release of the compiler is aimed to be straightforward, and each upgrade will continue to improve performance and add better handling of diverse JavaScript and React patterns.
113+
114+
Throughout this process, we also plan to prototype an IDE extension for React. It is still very early in research, so we expect to be able to share more of our findings with you in a future React Labs blog post.
115+
116+
---
117+
118+
Thanks to [Sathya Gunasekaran](https://twitter.com/_gsathya), [Joe Savona](https://twitter.com/en_JS), [Ricky Hanlon](https://twitter.com/rickhanlonii), [Alex Taylor](https://github.com/alexmckenley), [Jason Bonta](https://twitter.com/someextent), and [Eli White](https://twitter.com/Eli_White) for reviewing and editing this post.
119+
120+
---
121+
122+
[^1]: Thanks [@nikeee](https://github.com/facebook/react/pulls?q=is%3Apr+author%3Anikeee), [@henryqdineen](https://github.com/facebook/react/pulls?q=is%3Apr+author%3Ahenryqdineen), [@TrickyPi](https://github.com/facebook/react/pulls?q=is%3Apr+author%3ATrickyPi), and several others for their contributions to the compiler.
123+
124+
[^2]: Thanks [Vaishali Garg](https://www.linkedin.com/in/vaishaligarg09) for leading this study on React Compiler at Meta, and for reviewing this post.
125+
126+
[^3]: After controlling on author tenure, diff length/complexity, and other potential confounding factors.

src/content/blog/index.md

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ This blog is the official source for the updates from the React team. Anything i
1010

1111
<div className="sm:-mx-5 flex flex-col gap-5 mt-12">
1212

13+
<BlogCard title="React Compiler Beta Release" date="October 21, 2024" url="/blog/2024/10/21/react-compiler-beta-release">
14+
15+
We announced an experimental release of React Compiler at React Conf 2024. We've made a lot of progress since then, and in this post we want to share what's next for React Compiler ...
16+
17+
</BlogCard>
18+
1319
<BlogCard title="React Conf 2024 Recap" date="May 22, 2024" url="/blog/2024/05/22/react-conf-2024-recap">
1420

1521
Last week we hosted React Conf 2024, a two-day conference in Henderson, Nevada where 700+ attendees gathered in-person to discuss the latest in UI engineering. This was our first in-person conference since 2019, and we were thrilled to be able to bring the community together again ...

src/content/learn/react-compiler.md

+32-31
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ These docs are still a work in progress. More documentation is available in the
1313
<YouWillLearn>
1414

1515
* Getting started with the compiler
16-
* Installing the compiler and eslint plugin
16+
* Installing the compiler and ESLint plugin
1717
* Troubleshooting
1818

1919
</YouWillLearn>
@@ -26,7 +26,7 @@ The latest Beta release can be found with the `@beta` tag, and daily experimenta
2626

2727
React Compiler is a new compiler that we've open sourced to get early feedback from the community. It is a build-time only tool that automatically optimizes your React app. It works with plain JavaScript, and understands the [Rules of React](/reference/rules), so you don't need to rewrite any code to use it.
2828

29-
The compiler also includes an [eslint plugin](#installing-eslint-plugin-react-compiler) that surfaces the analysis from the compiler right in your editor. **We strongly recommend everyone use the linter today.** The linter does not require that you have the compiler installed, so you can use it even if you are not ready to try out the compiler.
29+
The compiler also includes an [ESLint plugin](#installing-eslint-plugin-react-compiler) that surfaces the analysis from the compiler right in your editor. **We strongly recommend everyone use the linter today.** The linter does not require that you have the compiler installed, so you can use it even if you are not ready to try out the compiler.
3030

3131
The compiler is currently released as `beta`, and is available to try out on React 17+ apps and libraries. To install the Beta:
3232

@@ -48,6 +48,10 @@ In order to optimize applications, React Compiler automatically memoizes your co
4848

4949
The compiler uses its knowledge of JavaScript and React's rules to automatically memoize values or groups of values within your components and hooks. If it detects breakages of the rules, it will automatically skip over just those components or hooks, and continue safely compiling other code.
5050

51+
<Note>
52+
React Compiler can statically detect when Rules of React are broken, and safely opt-out of optimizing just the affected components or hooks. It is not necessary for the compiler to optimize 100% of your codebase.
53+
</Note>
54+
5155
If your codebase is already very well-memoized, you might not expect to see major performance improvements with the compiler. However, in practice memoizing the correct dependencies that cause performance issues is tricky to get right by hand.
5256

5357
<DeepDive>
@@ -120,52 +124,49 @@ Please note that the compiler is still in Beta and has many rough edges. While i
120124

121125
In addition to these docs, we recommend checking the [React Compiler Working Group](https://github.com/reactwg/react-compiler) for additional information and discussion about the compiler.
122126

123-
### Checking compatibility {/*checking-compatibility*/}
124-
125-
Prior to installing the compiler, you can first check to see if your codebase is compatible:
126-
127-
<TerminalBlock>
128-
npx react-compiler-healthcheck@beta
129-
</TerminalBlock>
130-
131-
This script will:
132-
133-
- Check how many components can be successfully optimized: higher is better
134-
- Check for `<StrictMode>` usage: having this enabled and followed means a higher chance that the [Rules of React](/reference/rules) are followed
135-
- Check for incompatible library usage: known libraries that are incompatible with the compiler
136-
137-
As an example:
138-
139-
<TerminalBlock>
140-
Successfully compiled 8 out of 9 components.
141-
StrictMode usage not found.
142-
Found no usage of incompatible libraries.
143-
</TerminalBlock>
144-
145127
### Installing eslint-plugin-react-compiler {/*installing-eslint-plugin-react-compiler*/}
146128

147-
React Compiler also powers an eslint plugin. The eslint plugin can be used **independently** of the compiler, meaning you can use the eslint plugin even if you don't use the compiler.
129+
React Compiler also powers an ESLint plugin. The ESLint plugin can be used **independently** of the compiler, meaning you can use the ESLint plugin even if you don't use the compiler.
148130

149131
<TerminalBlock>
150132
npm install -D eslint-plugin-react-compiler@beta
151133
</TerminalBlock>
152134

153-
Then, add it to your eslint config:
135+
Then, add it to your ESLint config:
136+
137+
```js
138+
import reactCompiler from 'eslint-plugin-react-compiler'
139+
140+
export default [
141+
{
142+
plugins: {
143+
'react-compiler': reactCompiler,
144+
},
145+
rules: {
146+
'react-compiler/react-compiler': 'error',
147+
},
148+
},
149+
]
150+
```
151+
152+
Or, in the deprecated eslintrc config format:
154153

155154
```js
156155
module.exports = {
157156
plugins: [
158157
'eslint-plugin-react-compiler',
159158
],
160159
rules: {
161-
'react-compiler/react-compiler': "error",
160+
'react-compiler/react-compiler': 'error',
162161
},
163162
}
164163
```
165164

166-
The eslint plugin will display any violations of the rules of React in your editor. When it does this, it means that the compiler has skipped over optimizing that component or hook. This is perfectly okay, and the compiler can recover and continue optimizing other components in your codebase.
165+
The ESLint plugin will display any violations of the rules of React in your editor. When it does this, it means that the compiler has skipped over optimizing that component or hook. This is perfectly okay, and the compiler can recover and continue optimizing other components in your codebase.
167166

168-
**You don't have to fix all eslint violations straight away.** You can address them at your own pace to increase the amount of components and hooks being optimized, but it is not required to fix everything before you can use the compiler.
167+
<Note>
168+
**You don't have to fix all ESLint violations straight away.** You can address them at your own pace to increase the amount of components and hooks being optimized, but it is not required to fix everything before you can use the compiler.
169+
</Note>
169170

170171
### Rolling out the compiler to your codebase {/*using-the-compiler-effectively*/}
171172

@@ -349,11 +350,11 @@ React Compiler can verify many of the Rules of React statically, and will safely
349350
[React Devtools](/learn/react-developer-tools) (v5.0+) has built-in support for React Compiler and will display a "Memo ✨" badge next to components that have been optimized by the compiler.
350351

351352
### Something is not working after compilation {/*something-is-not-working-after-compilation*/}
352-
If you have eslint-plugin-react-compiler installed, the compiler will display any violations of the rules of React in your editor. When it does this, it means that the compiler has skipped over optimizing that component or hook. This is perfectly okay, and the compiler can recover and continue optimizing other components in your codebase. **You don't have to fix all eslint violations straight away.** You can address them at your own pace to increase the amount of components and hooks being optimized.
353+
If you have eslint-plugin-react-compiler installed, the compiler will display any violations of the rules of React in your editor. When it does this, it means that the compiler has skipped over optimizing that component or hook. This is perfectly okay, and the compiler can recover and continue optimizing other components in your codebase. **You don't have to fix all ESLint violations straight away.** You can address them at your own pace to increase the amount of components and hooks being optimized.
353354

354355
Due to the flexible and dynamic nature of JavaScript however, it's not possible to comprehensively detect all cases. Bugs and undefined behavior such as infinite loops may occur in those cases.
355356

356-
If your app doesn't work properly after compilation and you aren't seeing any eslint errors, the compiler may be incorrectly compiling your code. To confirm this, try to make the issue go away by aggressively opting out any component or hook you think might be related via the [`"use no memo"` directive](#opt-out-of-the-compiler-for-a-component).
357+
If your app doesn't work properly after compilation and you aren't seeing any ESLint errors, the compiler may be incorrectly compiling your code. To confirm this, try to make the issue go away by aggressively opting out any component or hook you think might be related via the [`"use no memo"` directive](#opt-out-of-the-compiler-for-a-component).
357358

358359
```js {2}
359360
function SuspiciousComponent() {

0 commit comments

Comments
 (0)