[compiler] Add option for firing effect functions (#31794)
Config flag for `fire` -- --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/31794). * #31811 * #31798 * #31797 * #31796 * #31795 * __->__ #31794
Jordan Brown committed
Dec 16, 2024 at 15:48 UTC
308be6e8dc0310c67c0b7341e459ebd8ad1ee1d0
2 files changed
+8
compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts
+2
@@ -249,6 +249,8 @@ const EnvironmentConfigSchema = z.object({
249
*/
250
enableOptionalDependencies: z.boolean().default(true),
251
252
+ enableFire: z.boolean().default(false),
253
+
254
/**
255
* Enables inference and auto-insertion of effect dependencies. Takes in an array of
256
* configurable module and import pairs to allow for user-land experimentation. For example,
compiler/packages/snap/src/compiler.ts
+6
@@ -58,6 +58,7 @@ function makePluginOptions(
58
let validatePreserveExistingMemoizationGuarantees = false;
59
let customMacros: null | Array<Macro> = null;
60
let validateBlocklistedImports = null;
61
+ let enableFire = false;
62
let target: CompilerReactTarget = '19';
63
64
if (firstLine.indexOf('@compilationMode(annotation)') !== -1) {
@@ -129,6 +130,10 @@ function makePluginOptions(
130
validatePreserveExistingMemoizationGuarantees = true;
131
}
132
133
+ if (firstLine.includes('@enableFire')) {
134
+ enableFire = true;
135
+ }
136
+
137
const hookPatternMatch = /@hookPattern:"([^"]+)"/.exec(firstLine);
138
if (
139
hookPatternMatch &&
@@ -207,6 +212,7 @@ function makePluginOptions(
212
hookPattern,
213
validatePreserveExistingMemoizationGuarantees,
214
validateBlocklistedImports,
215
+ enableFire,
216
},
217
compilationMode,
218
logger,