From 44a6a602a7e5f21184d44f8b16f6abfa61a960d4 Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Tue, 3 Oct 2023 14:49:58 -0700 Subject: [PATCH] [be] Update feature defaults to reflect usage Updates feature flag default values to match the flags we have turned on internally for some time w/o issues. --- .../src/HIR/Environment.ts | 8 +- ...ay-map-captures-receiver-noAlias.expect.md | 3 +- .../array-map-captures-receiver-noAlias.js | 1 - .../array-map-frozen-array-noAlias.expect.md | 3 +- .../array-map-frozen-array-noAlias.js | 1 - .../compiler/array-map-frozen-array.expect.md | 31 ++--- ...le-array-mutating-lambda-noAlias.expect.md | 3 +- ...p-mutable-array-mutating-lambda-noAlias.js | 1 - ...ap-mutable-array-mutating-lambda.expect.md | 37 +++--- ...ay-map-noAlias-escaping-function.expect.md | 3 +- .../array-map-noAlias-escaping-function.js | 1 - ...and-local-variables-with-default.expect.md | 117 ++++++++---------- ...ed-scope-declarations-and-locals.expect.md | 61 ++++----- .../fixtures/compiler/hook-noAlias.expect.md | 3 +- .../fixtures/compiler/hook-noAlias.js | 1 - .../compiler/optional-call-logical.expect.md | 25 ++-- ...ject-method-calls-mutable-lambda.expect.md | 3 +- ...only-object-method-calls-mutable-lambda.js | 1 - .../readonly-object-method-calls.expect.md | 3 +- .../compiler/readonly-object-method-calls.js | 1 - .../tagged-template-in-hook.expect.md | 11 +- .../fixture-test-utils/src/compiler-utils.ts | 9 -- 22 files changed, 130 insertions(+), 197 deletions(-) diff --git a/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts b/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts index e4ec4f1537..a29a3283c4 100644 --- a/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts +++ b/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts @@ -251,6 +251,10 @@ const DEFAULT_ENVIRONMENT_CONFIG: CompleteEnvironmentConfig = { enableTreatHooksAsFunctions: true, memoizeJsxElements: true, + enableFunctionCallSignatureOptimizations: true, + inlineUseMemo: true, + validateHooksUsage: true, + enableNoAliasOptimizations: true, assertValidMutableRanges: false, bailoutOnHoleyArrays: false, @@ -258,13 +262,9 @@ const DEFAULT_ENVIRONMENT_CONFIG: CompleteEnvironmentConfig = { enableAssumeHooksFollowRulesOfReact: false, enableEmitFreeze: null, enableForest: false, - enableFunctionCallSignatureOptimizations: false, enableMergeConsecutiveScopes: false, - enableNoAliasOptimizations: false, - inlineUseMemo: false, validateFrozenLambdas: false, - validateHooksUsage: false, validateNoSetStateInRender: false, validateRefAccessDuringRender: false, }; diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-captures-receiver-noAlias.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-captures-receiver-noAlias.expect.md index 3c9dd0d0de..b83e08b90f 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-captures-receiver-noAlias.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-captures-receiver-noAlias.expect.md @@ -2,7 +2,6 @@ ## Input ```javascript -// @enableNoAliasOptimizations function Component(props) { // This item is part of the receiver, should be memoized const item = { a: props.a }; @@ -22,7 +21,7 @@ export const FIXTURE_ENTRYPOINT = { ## Code ```javascript -import { unstable_useMemoCache as useMemoCache } from "react"; // @enableNoAliasOptimizations +import { unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { const $ = useMemoCache(2); const c_0 = $[0] !== props.a; diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-captures-receiver-noAlias.js b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-captures-receiver-noAlias.js index d5914bf00f..4bf4668de4 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-captures-receiver-noAlias.js +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-captures-receiver-noAlias.js @@ -1,4 +1,3 @@ -// @enableNoAliasOptimizations function Component(props) { // This item is part of the receiver, should be memoized const item = { a: props.a }; diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-frozen-array-noAlias.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-frozen-array-noAlias.expect.md index e14a823f42..01e065815e 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-frozen-array-noAlias.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-frozen-array-noAlias.expect.md @@ -2,7 +2,6 @@ ## Input ```javascript -// @enableNoAliasOptimizations function Component(props) { const x = []; {x}; @@ -21,7 +20,7 @@ export const FIXTURE_ENTRYPOINT = { ## Code ```javascript -import { unstable_useMemoCache as useMemoCache } from "react"; // @enableNoAliasOptimizations +import { unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { const $ = useMemoCache(3); let t0; diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-frozen-array-noAlias.js b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-frozen-array-noAlias.js index 0d8df82fd2..90b7bbdd45 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-frozen-array-noAlias.js +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-frozen-array-noAlias.js @@ -1,4 +1,3 @@ -// @enableNoAliasOptimizations function Component(props) { const x = []; {x}; diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-frozen-array.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-frozen-array.expect.md index a42227c996..01e065815e 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-frozen-array.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-frozen-array.expect.md @@ -22,7 +22,7 @@ export const FIXTURE_ENTRYPOINT = { ```javascript import { unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { - const $ = useMemoCache(4); + const $ = useMemoCache(3); let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { t0 = []; @@ -31,29 +31,22 @@ function Component(props) { t0 = $[0]; } const x = t0; - let t2; + let t1; if ($[1] === Symbol.for("react.memo_cache_sentinel")) { - let t1; - if ($[2] === Symbol.for("react.memo_cache_sentinel")) { - t1 = (item) => item; - $[2] = t1; - } else { - t1 = $[2]; - } - t2 = x.map(t1); - $[1] = t2; + t1 = x.map((item) => item); + $[1] = t1; } else { - t2 = $[1]; + t1 = $[1]; } - const y = t2; - let t3; - if ($[3] === Symbol.for("react.memo_cache_sentinel")) { - t3 = [x, y]; - $[3] = t3; + const y = t1; + let t2; + if ($[2] === Symbol.for("react.memo_cache_sentinel")) { + t2 = [x, y]; + $[2] = t2; } else { - t3 = $[3]; + t2 = $[2]; } - return t3; + return t2; } export const FIXTURE_ENTRYPOINT = { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-mutable-array-mutating-lambda-noAlias.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-mutable-array-mutating-lambda-noAlias.expect.md index 62ef2ade57..89d5ae7eb5 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-mutable-array-mutating-lambda-noAlias.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-mutable-array-mutating-lambda-noAlias.expect.md @@ -2,7 +2,6 @@ ## Input ```javascript -// @enableNoAliasOptimizations function Component(props) { const x = []; const y = x.map((item) => { @@ -23,7 +22,7 @@ export const FIXTURE_ENTRYPOINT = { ## Code ```javascript -import { unstable_useMemoCache as useMemoCache } from "react"; // @enableNoAliasOptimizations +import { unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { const $ = useMemoCache(3); let t0; diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-mutable-array-mutating-lambda-noAlias.js b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-mutable-array-mutating-lambda-noAlias.js index 68b90eda4e..b59c4bfd13 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-mutable-array-mutating-lambda-noAlias.js +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-mutable-array-mutating-lambda-noAlias.js @@ -1,4 +1,3 @@ -// @enableNoAliasOptimizations function Component(props) { const x = []; const y = x.map((item) => { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-mutable-array-mutating-lambda.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-mutable-array-mutating-lambda.expect.md index f38245529e..89d5ae7eb5 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-mutable-array-mutating-lambda.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-mutable-array-mutating-lambda.expect.md @@ -24,37 +24,30 @@ export const FIXTURE_ENTRYPOINT = { ```javascript import { unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { - const $ = useMemoCache(4); - let t1; + const $ = useMemoCache(3); + let t0; let x; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { x = []; - let t0; - if ($[2] === Symbol.for("react.memo_cache_sentinel")) { - t0 = (item) => { - item.updated = true; - return item; - }; - $[2] = t0; - } else { - t0 = $[2]; - } - t1 = x.map(t0); - $[0] = t1; + t0 = x.map((item) => { + item.updated = true; + return item; + }); + $[0] = t0; $[1] = x; } else { - t1 = $[0]; + t0 = $[0]; x = $[1]; } - const y = t1; - let t2; - if ($[3] === Symbol.for("react.memo_cache_sentinel")) { - t2 = [x, y]; - $[3] = t2; + const y = t0; + let t1; + if ($[2] === Symbol.for("react.memo_cache_sentinel")) { + t1 = [x, y]; + $[2] = t1; } else { - t2 = $[3]; + t1 = $[2]; } - return t2; + return t1; } export const FIXTURE_ENTRYPOINT = { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-noAlias-escaping-function.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-noAlias-escaping-function.expect.md index 1bf189fbc7..af22a304df 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-noAlias-escaping-function.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-noAlias-escaping-function.expect.md @@ -2,7 +2,6 @@ ## Input ```javascript -// @enableNoAliasOptimizations function Component(props) { const f = (item) => item; const x = [...props.items].map(f); // `f` doesn't escape here... @@ -20,7 +19,7 @@ export const FIXTURE_ENTRYPOINT = { ## Code ```javascript -import { unstable_useMemoCache as useMemoCache } from "react"; // @enableNoAliasOptimizations +import { unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { const $ = useMemoCache(5); let t0; diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-noAlias-escaping-function.js b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-noAlias-escaping-function.js index 461a166366..60726b5e5c 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-noAlias-escaping-function.js +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-map-noAlias-escaping-function.js @@ -1,4 +1,3 @@ -// @enableNoAliasOptimizations function Component(props) { const f = (item) => item; const x = [...props.items].map(f); // `f` doesn't escape here... diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-and-local-variables-with-default.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-and-local-variables-with-default.expect.md index 247056d02b..f12061aa0a 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-and-local-variables-with-default.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-and-local-variables-with-default.expect.md @@ -56,94 +56,87 @@ function useFragment(_arg1, _arg2) { } function Component(props) { - const $ = useMemoCache(17); - let t0; - if ($[0] === Symbol.for("react.memo_cache_sentinel")) { - t0 = graphql`...`; - $[0] = t0; - } else { - t0 = $[0]; - } - const post = useFragment(t0, props.post); - const c_1 = $[1] !== post; + const $ = useMemoCache(16); + const post = useFragment(graphql`...`, props.post); + const c_0 = $[0] !== post; let media; let allUrls; let onClick; - if (c_1) { + if (c_0) { allUrls = []; - const { media: t1, comments: t3, urls: t5 } = post; - const c_5 = $[5] !== t1; - let t2; - if (c_5) { - t2 = t1 === undefined ? null : t1; + const { media: t0, comments: t2, urls: t4 } = post; + const c_4 = $[4] !== t0; + let t1; + if (c_4) { + t1 = t0 === undefined ? null : t0; + $[4] = t0; $[5] = t1; + } else { + t1 = $[5]; + } + media = t1; + const c_6 = $[6] !== t2; + let t3; + if (c_6) { + t3 = t2 === undefined ? [] : t2; $[6] = t2; - } else { - t2 = $[6]; - } - media = t2; - const c_7 = $[7] !== t3; - let t4; - if (c_7) { - t4 = t3 === undefined ? [] : t3; $[7] = t3; + } else { + t3 = $[7]; + } + const comments = t3; + const c_8 = $[8] !== t4; + let t5; + if (c_8) { + t5 = t4 === undefined ? [] : t4; $[8] = t4; - } else { - t4 = $[8]; - } - const comments = t4; - const c_9 = $[9] !== t5; - let t6; - if (c_9) { - t6 = t5 === undefined ? [] : t5; $[9] = t5; - $[10] = t6; } else { - t6 = $[10]; + t5 = $[9]; } - const urls = t6; - const c_11 = $[11] !== comments.length; - let t7; - if (c_11) { - t7 = (e) => { + const urls = t5; + const c_10 = $[10] !== comments.length; + let t6; + if (c_10) { + t6 = (e) => { if (!comments.length) { return; } console.log(comments.length); }; - $[11] = comments.length; - $[12] = t7; + $[10] = comments.length; + $[11] = t6; } else { - t7 = $[12]; + t6 = $[11]; } - onClick = t7; + onClick = t6; allUrls.push(...urls); - $[1] = post; - $[2] = media; - $[3] = allUrls; - $[4] = onClick; + $[0] = post; + $[1] = media; + $[2] = allUrls; + $[3] = onClick; } else { - media = $[2]; - allUrls = $[3]; - onClick = $[4]; + media = $[1]; + allUrls = $[2]; + onClick = $[3]; } - const c_13 = $[13] !== media; - const c_14 = $[14] !== allUrls; - const c_15 = $[15] !== onClick; - let t8; - if (c_13 || c_14 || c_15) { - t8 = ; - $[13] = media; - $[14] = allUrls; - $[15] = onClick; - $[16] = t8; + const c_12 = $[12] !== media; + const c_13 = $[13] !== allUrls; + const c_14 = $[14] !== onClick; + let t7; + if (c_12 || c_13 || c_14) { + t7 = ; + $[12] = media; + $[13] = allUrls; + $[14] = onClick; + $[15] = t7; } else { - t8 = $[16]; + t7 = $[15]; } - return t8; + return t7; } export const FIXTURE_ENTRYPOINT = { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-declarations-and-locals.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-declarations-and-locals.expect.md index bf056a0292..9d606ddc5b 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-declarations-and-locals.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-declarations-and-locals.expect.md @@ -30,60 +30,53 @@ function Component(props) { ```javascript import { unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { - const $ = useMemoCache(9); - let t0; - if ($[0] === Symbol.for("react.memo_cache_sentinel")) { - t0 = graphql`...`; - $[0] = t0; - } else { - t0 = $[0]; - } - const post = useFragment(t0, props.post); - const c_1 = $[1] !== post; + const $ = useMemoCache(8); + const post = useFragment(graphql`...`, props.post); + const c_0 = $[0] !== post; let media; let onClick; - if (c_1) { + if (c_0) { const allUrls = []; const { media: t83, comments, urls } = post; media = t83; - const c_4 = $[4] !== comments.length; - let t1; - if (c_4) { - t1 = (e) => { + const c_3 = $[3] !== comments.length; + let t0; + if (c_3) { + t0 = (e) => { if (!comments.length) { return; } console.log(comments.length); }; - $[4] = comments.length; - $[5] = t1; + $[3] = comments.length; + $[4] = t0; } else { - t1 = $[5]; + t0 = $[4]; } - onClick = t1; + onClick = t0; allUrls.push(...urls); - $[1] = post; - $[2] = media; - $[3] = onClick; + $[0] = post; + $[1] = media; + $[2] = onClick; } else { - media = $[2]; - onClick = $[3]; + media = $[1]; + onClick = $[2]; } - const c_6 = $[6] !== media; - const c_7 = $[7] !== onClick; - let t2; - if (c_6 || c_7) { - t2 = ; - $[6] = media; - $[7] = onClick; - $[8] = t2; + const c_5 = $[5] !== media; + const c_6 = $[6] !== onClick; + let t1; + if (c_5 || c_6) { + t1 = ; + $[5] = media; + $[6] = onClick; + $[7] = t1; } else { - t2 = $[8]; + t1 = $[7]; } - return t2; + return t1; } ``` diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hook-noAlias.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hook-noAlias.expect.md index 6b0821aca3..dc025f44e2 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hook-noAlias.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hook-noAlias.expect.md @@ -2,7 +2,6 @@ ## Input ```javascript -// @enableNoAliasOptimizations import { useNoAlias } from "shared-runtime"; function Component(props) { @@ -28,7 +27,7 @@ export const FIXTURE_ENTRYPOINT = { ## Code ```javascript -import { unstable_useMemoCache as useMemoCache } from "react"; // @enableNoAliasOptimizations +import { unstable_useMemoCache as useMemoCache } from "react"; import { useNoAlias } from "shared-runtime"; function Component(props) { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hook-noAlias.js b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hook-noAlias.js index f31a2f738f..b824adb8c1 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hook-noAlias.js +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hook-noAlias.js @@ -1,4 +1,3 @@ -// @enableNoAliasOptimizations import { useNoAlias } from "shared-runtime"; function Component(props) { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/optional-call-logical.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/optional-call-logical.expect.md index 3166d8eaf3..65c736d354 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/optional-call-logical.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/optional-call-logical.expect.md @@ -14,25 +14,18 @@ function Component(props) { ```javascript import { unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { - const $ = useMemoCache(3); + const $ = useMemoCache(2); + const item = useFragment(graphql`...`, props.item); + const c_0 = $[0] !== item.items; let t0; - if ($[0] === Symbol.for("react.memo_cache_sentinel")) { - t0 = graphql`...`; - $[0] = t0; + if (c_0) { + t0 = item.items?.map((item_0) => renderItem(item_0)) ?? []; + $[0] = item.items; + $[1] = t0; } else { - t0 = $[0]; + t0 = $[1]; } - const item = useFragment(t0, props.item); - const c_1 = $[1] !== item.items; - let t1; - if (c_1) { - t1 = item.items?.map((item_0) => renderItem(item_0)) ?? []; - $[1] = item.items; - $[2] = t1; - } else { - t1 = $[2]; - } - return t1; + return t0; } ``` diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls-mutable-lambda.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls-mutable-lambda.expect.md index e3c6f16f68..8d4eb5e618 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls-mutable-lambda.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls-mutable-lambda.expect.md @@ -2,7 +2,6 @@ ## Input ```javascript -// @enableNoAliasOptimizations function Component(props) { const x = makeObject(); const user = useFragment( @@ -24,7 +23,7 @@ function Component(props) { ## Code ```javascript -import { unstable_useMemoCache as useMemoCache } from "react"; // @enableNoAliasOptimizations +import { unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { const $ = useMemoCache(3); const x = makeObject(); diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls-mutable-lambda.js b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls-mutable-lambda.js index 0bd543d9d3..29e9ebacf2 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls-mutable-lambda.js +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls-mutable-lambda.js @@ -1,4 +1,3 @@ -// @enableNoAliasOptimizations function Component(props) { const x = makeObject(); const user = useFragment( diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls.expect.md index 0bf19c9303..fd396ef3ac 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls.expect.md @@ -2,7 +2,6 @@ ## Input ```javascript -// @enableNoAliasOptimizations function Component(props) { const user = useFragment( graphql`fragment Component_user on User { ... }`, @@ -22,7 +21,7 @@ function Component(props) { ## Code ```javascript -import { unstable_useMemoCache as useMemoCache } from "react"; // @enableNoAliasOptimizations +import { unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { const $ = useMemoCache(5); const user = useFragment( diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls.js b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls.js index b8e03b19be..0fc0a977d0 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls.js +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls.js @@ -1,4 +1,3 @@ -// @enableNoAliasOptimizations function Component(props) { const user = useFragment( graphql`fragment Component_user on User { ... }`, diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/tagged-template-in-hook.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/tagged-template-in-hook.expect.md index fbfaee47a8..a7db7906f2 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/tagged-template-in-hook.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/tagged-template-in-hook.expect.md @@ -12,17 +12,8 @@ function Component(props) { ## Code ```javascript -import { unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { - const $ = useMemoCache(1); - let t0; - if ($[0] === Symbol.for("react.memo_cache_sentinel")) { - t0 = graphql`fragment on User { name }`; - $[0] = t0; - } else { - t0 = $[0]; - } - const user = useFragment(t0, props.user); + const user = useFragment(graphql`fragment on User { name }`, props.user); return user.name; } diff --git a/compiler/packages/fixture-test-utils/src/compiler-utils.ts b/compiler/packages/fixture-test-utils/src/compiler-utils.ts index 3fb958fd25..da3fd63232 100644 --- a/compiler/packages/fixture-test-utils/src/compiler-utils.ts +++ b/compiler/packages/fixture-test-utils/src/compiler-utils.ts @@ -28,7 +28,6 @@ export function transformFixtureInput( let enableEmitFreeze = null; let compilationMode: CompilationMode = "all"; let enableForest = false; - let enableNoAliasOptimizations = false; let enableMergeConsecutiveScopes = false; let bailoutOnHoleyArrays = false; @@ -86,10 +85,6 @@ export function transformFixtureInput( if (firstLine.includes("@enableForest true")) { enableForest = true; } - if (firstLine.includes("@enableNoAliasOptimizations")) { - enableNoAliasOptimizations = true; - } - if (firstLine.includes("@bailoutOnHoleyArrays")) { bailoutOnHoleyArrays = true; } @@ -134,13 +129,9 @@ export function transformFixtureInput( ], ]), enableAssumeHooksFollowRulesOfReact, - enableFunctionCallSignatureOptimizations: true, - enableNoAliasOptimizations, disableAllMemoization, enableTreatHooksAsFunctions, - inlineUseMemo: true, memoizeJsxElements, - validateHooksUsage: true, validateRefAccessDuringRender, validateFrozenLambdas: true, validateNoSetStateInRender,