@samitouri / QOS-React-2 / commits / f070cab870

[snap] add memoizeJSX flag

--- #1603 for snap

Mofei Zhang committed May 17, 2023 at 14:39 UTC f070cab87017b58f07a1b75953c7585a1bd0d5b6
1 file changed +8 -6
compiler/forget/packages/snap/src/compiler-worker.ts
+8 -6
@@ -89,19 +89,19 @@ export async function compile(
89 const firstLine = input.substring(0, input.indexOf("\n"));
90
91 let enableOnlyOnUseForgetDirective = false;
92 + let gating = null;
93 + let instrumentForget = null;
94 + let panicOnBailout = true;
95 + let memoizeJsxElements = true;
96 if (firstLine.indexOf("@forgetDirective") !== -1) {
97 enableOnlyOnUseForgetDirective = true;
98 }
95 -
96 - let gating = null;
97 - let instrumentForget = null;
99 if (firstLine.indexOf("@gating") !== -1) {
100 gating = {
101 source: "ReactForgetFeatureFlag",
102 importSpecifierName: "isForgetEnabled_Fixtures",
103 };
104 }
104 -
105 if (firstLine.indexOf("@instrumentForget") !== -1) {
106 instrumentForget = {
107 gating: {
@@ -114,11 +114,12 @@ export async function compile(
114 },
115 };
116 }
117 -
118 - let panicOnBailout = true;
117 if (firstLine.indexOf("@panicOnBailout false") !== -1) {
118 panicOnBailout = false;
119 }
120 + if (firstLine.indexOf("@memoizeJsxElements false") !== -1) {
121 + memoizeJsxElements = false;
122 + }
123
124 const language = parseLanguage(firstLine);
125
@@ -138,6 +139,7 @@ export async function compile(
139 ]),
140 validateHooksUsage: true,
141 inlineUseMemo: true,
142 + memoizeJsxElements,
143 },
144 logger: null,
145 gating,