Update base for Update on "[compiler][ez] Rename disableMemoizationForDebugging to just disableMemoization"

Summary: We don't really need to make positive claims about what a particular mode is for in the name

[ghstack-poisoned]
This commit is contained in:
Mike Vitousek
2024-07-02 09:59:45 -07:00
parent d20c363231
commit ddacda023b
6 changed files with 40 additions and 20 deletions
@@ -480,19 +480,28 @@ export function parseConfigPragma(pragma: string): EnvironmentConfig {
}
if (
key === "enablePreserveExistingManualUseMemoAsHook" &&
(val === undefined || val === "true")
key === "enablePreserveExistingManualUseMemo" &&
(val === undefined || val === "true" || val === "scope")
) {
maybeConfig["enablePreserveExistingManualUseMemo"] = "hook";
maybeConfig[key] = "scope";
continue;
}
if (key === "enablePreserveExistingManualUseMemo" && val === "hook") {
maybeConfig[key] = "hook";
continue;
}
if (
key === "enablePreserveExistingManualUseMemoAsScope" &&
(val === undefined || val === "true")
key === "enablePreserveExistingManualUseMemo" &&
!(val === "false" || val === "off")
) {
maybeConfig["enablePreserveExistingManualUseMemo"] = "scope";
continue;
CompilerError.throwInvalidConfig({
reason: `Invalid setting '${val}' for 'enablePreserveExistingManualUseMemo'. Valid settings are 'hook', 'scope', or 'off'.`,
description: null,
loc: null,
suggestions: null,
});
}
if (typeof defaultConfig[key as keyof EnvironmentConfig] !== "boolean") {
@@ -2,7 +2,7 @@
## Input
```javascript
// @enablePreserveExistingManualUseMemoAsScope
// @enablePreserveExistingManualUseMemo
import { useMemo } from "react";
let cur = 99;
function random(id) {
@@ -28,7 +28,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingManualUseMemoAsScope
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingManualUseMemo
import { useMemo } from "react";
let cur = 99;
function random(id) {
@@ -1,4 +1,4 @@
// @enablePreserveExistingManualUseMemoAsScope
// @enablePreserveExistingManualUseMemo
import { useMemo } from "react";
let cur = 99;
function random(id) {
@@ -2,7 +2,7 @@
## Input
```javascript
// @enablePreserveExistingManualUseMemoAsScope
// @enablePreserveExistingManualUseMemo
import { useMemo } from "react";
function Component({ a }) {
@@ -21,7 +21,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingManualUseMemoAsScope
import { c as _c } from "react/compiler-runtime"; // @enablePreserveExistingManualUseMemo
import { useMemo } from "react";
function Component(t0) {
@@ -1,4 +1,4 @@
// @enablePreserveExistingManualUseMemoAsScope
// @enablePreserveExistingManualUseMemo
import { useMemo } from "react";
function Component({ a }) {
+18 -7
View File
@@ -141,17 +141,28 @@ function makePluginOptions(
},
};
}
if (firstLine.includes("@enablePreserveExistingManualUseMemoAsHook")) {
enablePreserveExistingManualUseMemo = "hook";
} else if (
firstLine.includes("@enablePreserveExistingManualUseMemoAsScope")
const useMemoMatch = /@enablePreserveExistingManualUseMemo:"([^"]+)"/.exec(
firstLine
);
if (
useMemoMatch &&
(useMemoMatch[1] === "hook" || useMemoMatch[1] === "scope")
) {
enablePreserveExistingManualUseMemo = "scope";
} else if (firstLine.includes("@enablePreserveExistingManualUseMemo")) {
enablePreserveExistingManualUseMemo = useMemoMatch[1];
} else if (
useMemoMatch &&
(useMemoMatch[1] === "false" || useMemoMatch[1] === "off")
) {
enablePreserveExistingManualUseMemo = null;
} else if (useMemoMatch) {
throw new Error(
"Use either @enablePreserveExistingManualUseMemoAsScope or @enablePreserveExistingManualUseMemoAsHook"
`Invalid setting '${useMemoMatch[1]}' for 'enablePreserveExistingManualUseMemo'. Valid settings are 'hook', 'scope', or 'off'.`
);
} else if (firstLine.includes("@enablePreserveExistingManualUseMemo")) {
enablePreserveExistingManualUseMemo = "scope";
}
const hookPatternMatch = /@hookPattern:"([^"]+)"/.exec(firstLine);
if (
hookPatternMatch &&