@samitouri / QOS-React-2 / commits / 702aadd82b

Fix to only add imports if we compiled something

We should only add imports if we actually compiled anything, this is what caused the internal issue despite the file in question not having any functions opted-in to compilation.

Joe Savona committed Nov 7, 2023 at 16:22 UTC 702aadd82b2548f87c579fead92476e3efc64ac7
5 files changed +25 -21
compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts
+1 -2
@@ -356,9 +356,8 @@ export function compileProgram(
356 // Forget compiled the component, we need to update existing imports of unstable_useMemoCache
357 if (compiledFns.length > 0) {
358 updateUseMemoCacheImport(program, options);
359 + addImportsToProgram(program, externalFunctions);
360 }
360 -
361 - addImportsToProgram(program, externalFunctions);
361 }
362
363 function shouldVisitNode(
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.gating-with-no-compiled-functions.expect.md deleted
-19
@@ -1,19 +0,0 @@
1 -
2 -## Input
3 -
4 -```javascript
5 -// @gating
6 -import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag";
7 -
8 -export default 42;
9 -
10 -```
11 -
12 -
13 -## Error
14 -
15 -```
16 -[ReactForget] InvalidConfig: Encountered conflicting import specifiers for isForgetEnabled_Fixtures in generated program.
17 -```
18 -
19 -
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-no-gating-import-without-compiled-functions.expect.md new
+21
@@ -0,0 +1,21 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +// @gating
6 +import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag";
7 +
8 +export default 42;
9 +
10 +```
11 +
12 +## Code
13 +
14 +```javascript
15 +// @gating
16 +import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag";
17 +
18 +export default 42;
19 +
20 +```
21 +
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-no-gating-import-without-compiled-functions.js renamed
compiler/packages/sprout/src/SproutTodoFilter.ts
+3
@@ -476,6 +476,9 @@ const skipFilter = new Set([
476 // Tested e2e in forget-feedback repo
477 "userspace-use-memo-cache",
478 "transitive-freeze-function-expressions",
479 +
480 + // nothing to compile/run
481 + "repro-no-gating-import-without-compiled-functions",
482 ]);
483
484 export default skipFilter;