@samitouri / QOS-React-1 / commits / 23cd3aca28

[rcr] Remove runtimeModule compiler option (#31145)

Now that the compiler always injects `react-compiler-runtime`, this option is unnecessary.

lauren committed Oct 7, 2024 at 18:07 UTC 23cd3aca283817b8c359e806e9c7bc6b26fcd27c
4 files changed -122
compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts
-12
@@ -87,17 +87,6 @@ export type PluginOptions = {
87 */
88 compilationMode: CompilationMode;
89
90 - /*
91 - * If enabled, Forget will import `useMemoCache` from the given module
92 - * instead of `react/compiler-runtime`.
93 - *
94 - * ```
95 - * // If set to "react-compiler-runtime"
96 - * import {c as useMemoCache} from 'react-compiler-runtime';
97 - * ```
98 - */
99 - runtimeModule?: string | null | undefined;
100 -
90 /**
91 * By default React Compiler will skip compilation of code that suppresses the default
92 * React ESLint rules, since this is a strong indication that the code may be breaking React rules
@@ -214,7 +203,6 @@ export const defaultOptions: PluginOptions = {
203 logger: null,
204 gating: null,
205 noEmit: false,
217 - runtimeModule: null,
206 eslintSuppressionRules: null,
207 flowSuppressions: true,
208 ignoreUseNoForget: false,
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/userspace-use-memo-cache.expect.md deleted
-80
@@ -1,80 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -// @runtimeModule="react-compiler-runtime"
6 -import {useState} from 'react';
7 -
8 -function Component(props) {
9 - const [x, setX] = useState(1);
10 - let y;
11 - if (props.cond) {
12 - y = x * 2;
13 - }
14 - return (
15 - <button
16 - onClick={() => {
17 - setX(10 * y);
18 - }}>
19 - Click me
20 - </button>
21 - );
22 -}
23 -
24 -export const FIXTURE_ENTRYPOINT = {
25 - fn: Component,
26 - params: [true],
27 - isComponent: true,
28 -};
29 -
30 -```
31 -
32 -## Code
33 -
34 -```javascript
35 -import { c as _c } from "react/compiler-runtime"; // @runtimeModule="react-compiler-runtime"
36 -import { useState } from "react";
37 -
38 -function Component(props) {
39 - const $ = _c(5);
40 - const [x, setX] = useState(1);
41 - let y;
42 - if ($[0] !== props.cond || $[1] !== x) {
43 - if (props.cond) {
44 - y = x * 2;
45 - }
46 - $[0] = props.cond;
47 - $[1] = x;
48 - $[2] = y;
49 - } else {
50 - y = $[2];
51 - }
52 -
53 - const t0 = y;
54 - let t1;
55 - if ($[3] !== t0) {
56 - t1 = (
57 - <button
58 - onClick={() => {
59 - setX(10 * y);
60 - }}
61 - >
62 - Click me
63 - </button>
64 - );
65 - $[3] = t0;
66 - $[4] = t1;
67 - } else {
68 - t1 = $[4];
69 - }
70 - return t1;
71 -}
72 -
73 -export const FIXTURE_ENTRYPOINT = {
74 - fn: Component,
75 - params: [true],
76 - isComponent: true,
77 -};
78 -
79 -```
80 -
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/userspace-use-memo-cache.js deleted
-24
@@ -1,24 +0,0 @@
1 -// @runtimeModule="react-compiler-runtime"
2 -import {useState} from 'react';
3 -
4 -function Component(props) {
5 - const [x, setX] = useState(1);
6 - let y;
7 - if (props.cond) {
8 - y = x * 2;
9 - }
10 - return (
11 - <button
12 - onClick={() => {
13 - setX(10 * y);
14 - }}>
15 - Click me
16 - </button>
17 - );
18 -}
19 -
20 -export const FIXTURE_ENTRYPOINT = {
21 - fn: Component,
22 - params: [true],
23 - isComponent: true,
24 -};
compiler/packages/snap/src/compiler.ts
-6
@@ -48,7 +48,6 @@ function makePluginOptions(
48 let enableEmitFreeze = null;
49 let enableEmitHookGuards = null;
50 let compilationMode: CompilationMode = 'all';
51 - let runtimeModule = null;
51 let panicThreshold: PanicThresholdOptions = 'all_errors';
52 let hookPattern: string | null = null;
53 // TODO(@mofeiZ) rewrite snap fixtures to @validatePreserveExistingMemo:false
@@ -104,10 +103,6 @@ function makePluginOptions(
103 importSpecifierName: '$dispatcherGuard',
104 };
105 }
107 - const runtimeModuleMatch = /@runtimeModule="([^"]+)"/.exec(firstLine);
108 - if (runtimeModuleMatch) {
109 - runtimeModule = runtimeModuleMatch[1];
110 - }
106
107 const targetMatch = /@target="([^"]+)"/.exec(firstLine);
108 if (targetMatch) {
@@ -251,7 +246,6 @@ function makePluginOptions(
246 gating,
247 panicThreshold,
248 noEmit: false,
254 - runtimeModule,
249 eslintSuppressionRules,
250 flowSuppressions,
251 ignoreUseNoForget,