about summary refs log tree commit diff
path: root/.eslintrc.js
diff options
context:
space:
mode:
authorlauren <poteto@users.noreply.github.com>2024-05-22 13:46:45 -0400
committerGitHub <noreply@github.com>2024-05-22 18:46:45 +0100
commitbf8db6172fafcbc791c94ea8e8b797490306525c (patch)
treec25d3fdcef22c140729e774388ae225814a9b3e1 /.eslintrc.js
parente6e7027d01b32363cdfc319a04b74064a9c38529 (diff)
downloadvoidsky-bf8db6172fafcbc791c94ea8e8b797490306525c.tar.zst
Add React Compiler (#4161)
* Install babel-plugin-react-compiler

* Install eslint-plugin-react-compiler

* Add and configure react-compiler-runtime

React Compiler uses a small cache function from React 19 at runtime.
Until it's possible to use R19 on RN, this adds a userspace
implementation to polyfill the cache function

* Add eslint-plugin-react-compiler to config

* @lingui/macro should run as the first plugin

@lingui recommends running their `macro` plugin [first in the
pipeline](https://lingui.dev/ref/macro). Normally with the React
Compiler, the compiler plugin should run first as we want to see the
original code as it was written. However, this sometimes causes
conflicts with other babel plugins.

In this case, it looks like the @lingui/macro plugin does some very
light transformation that the compiler can still understand and compile
correctly, so let's run it first.

Before this commit, the compiler would cause the @lingui/macro plugin to
crash because it seems like it would strip off the `extra.raw` property
off of StringLiterals which was being used
[here](https://github.com/lingui/js-lingui/blob/1293412c5dcc565636403443788a5b5d4ca206c1/packages/macro/src/macroJsx.ts#L395).
I need to figure out why the compiler is doing that but for now this
works and should be a safe change unless there were specific reasons
the macro plugin was placed 2nd to last.
Diffstat (limited to '.eslintrc.js')
-rw-r--r--.eslintrc.js2
1 files changed, 2 insertions, 0 deletions
diff --git a/.eslintrc.js b/.eslintrc.js
index eb7ad04b1..1d0b30a59 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -13,6 +13,7 @@ module.exports = {
     'lingui',
     'simple-import-sort',
     'bsky-internal',
+    'eslint-plugin-react-compiler',
   ],
   rules: {
     // Temporary until https://github.com/facebook/react-native/pull/43756 gets into a release.
@@ -67,6 +68,7 @@ module.exports = {
       },
     ],
     'simple-import-sort/exports': 'warn',
+    'react-compiler/react-compiler': 'error',
   },
   ignorePatterns: [
     '**/__mocks__/*.ts',