From 7f24a7a1a37bcd228a9d3d197c34c4ac4e99974f Mon Sep 17 00:00:00 2001 From: Hailey Date: Sun, 10 Nov 2024 14:19:13 -0800 Subject: [PATCH] fix compiler --- babel.config.js | 2 +- lib/react-compiler-runtime/index.js | 21 --------------------- lib/react-compiler-runtime/package.json | 9 --------- package.json | 1 + yarn.lock | 9 ++++++++- 5 files changed, 10 insertions(+), 32 deletions(-) delete mode 100644 lib/react-compiler-runtime/index.js delete mode 100644 lib/react-compiler-runtime/package.json diff --git a/babel.config.js b/babel.config.js index c976d04b67..92437fb86e 100644 --- a/babel.config.js +++ b/babel.config.js @@ -20,7 +20,7 @@ module.exports = function (api) { [ 'babel-plugin-react-compiler', { - runtimeModule: 'react-compiler-runtime', + target: '18', }, ], [ diff --git a/lib/react-compiler-runtime/index.js b/lib/react-compiler-runtime/index.js deleted file mode 100644 index 44f80e0c98..0000000000 --- a/lib/react-compiler-runtime/index.js +++ /dev/null @@ -1,21 +0,0 @@ -const React = require('react') -const $empty = Symbol.for('react.memo_cache_sentinel') -/** - * DANGER: this hook is NEVER meant to be called directly! - * - * Note that this is a temporary userspace implementation of this function - * from React 19. It is not as efficient and may invalidate more frequently - * than the official API. Please upgrade to React 19 as soon as you can. - **/ -export function c(size) { - // eslint-disable-next-line react-hooks/rules-of-hooks - return React.useState(() => { - const $ = new Array(size) - for (let ii = 0; ii < size; ii++) { - $[ii] = $empty - } - // @ts-ignore - $[$empty] = true - return $ - })[0] -} diff --git a/lib/react-compiler-runtime/package.json b/lib/react-compiler-runtime/package.json deleted file mode 100644 index cb8f78bd55..0000000000 --- a/lib/react-compiler-runtime/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "react-compiler-runtime", - "version": "0.0.1", - "license": "MIT", - "main": "index.js", - "peerDependencies": { - "react": "^18.2.0" - } -} \ No newline at end of file diff --git a/package.json b/package.json index 52451bc682..fb7827e5e7 100644 --- a/package.json +++ b/package.json @@ -242,6 +242,7 @@ "babel-loader": "^9.1.2", "babel-plugin-macros": "^3.1.0", "babel-plugin-module-resolver": "^5.0.0", + "babel-plugin-react-compiler": "^19.0.0-beta-63b359f-20241101", "babel-plugin-react-native-web": "^0.18.12", "babel-preset-expo": "^10.0.0", "eslint": "^8.19.0", diff --git a/yarn.lock b/yarn.lock index 87cae076de..fd99b2c0c6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2335,7 +2335,7 @@ debug "^4.3.1" globals "^11.1.0" -"@babel/types@^7.0.0", "@babel/types@^7.12.6", "@babel/types@^7.20.0", "@babel/types@^7.20.7", "@babel/types@^7.21.2", "@babel/types@^7.24.7", "@babel/types@^7.25.2", "@babel/types@^7.25.9", "@babel/types@^7.26.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": +"@babel/types@^7.0.0", "@babel/types@^7.12.6", "@babel/types@^7.19.0", "@babel/types@^7.20.0", "@babel/types@^7.20.7", "@babel/types@^7.21.2", "@babel/types@^7.24.7", "@babel/types@^7.25.2", "@babel/types@^7.25.9", "@babel/types@^7.26.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": version "7.26.0" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.26.0.tgz#deabd08d6b753bc8e0f198f8709fb575e31774ff" integrity sha512-Z/yiTPj+lDVnF7lWeKCIJzaIkI0vYO87dMpZ4bg4TDrFe4XXLFWL1TbXU27gBP3QccxV9mZICCrnjnYlJjXHOA== @@ -7636,6 +7636,13 @@ babel-plugin-polyfill-regenerator@^0.6.1: dependencies: "@babel/helper-define-polyfill-provider" "^0.6.2" +babel-plugin-react-compiler@^19.0.0-beta-63b359f-20241101: + version "19.0.0-beta-63b359f-20241101" + resolved "https://registry.yarnpkg.com/babel-plugin-react-compiler/-/babel-plugin-react-compiler-19.0.0-beta-63b359f-20241101.tgz#0f2fe28c0e32b9fc08bcc534da6a03f0ba2d6f73" + integrity sha512-qrmTHJP3O2kGbtL7kuySX3Lmk+5/4ZR1rHr8QhKa0GzKbmpAUGrTeWOg0NCI5t+QUfKKizxIO1+t0HsZW9x4vQ== + dependencies: + "@babel/types" "^7.19.0" + babel-plugin-react-native-web@^0.18.12, babel-plugin-react-native-web@~0.18.10: version "0.18.12" resolved "https://registry.yarnpkg.com/babel-plugin-react-native-web/-/babel-plugin-react-native-web-0.18.12.tgz#3e9764484492ea612a16b40135b07c2d05b7969d"