Skip to content

Commit

Permalink
[compiler] Add option for firing effect functions (#31794)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jbrown215 authored Dec 16, 2024
1 parent d325f87 commit 308be6e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ const EnvironmentConfigSchema = z.object({
*/
enableOptionalDependencies: z.boolean().default(true),

enableFire: z.boolean().default(false),

/**
* Enables inference and auto-insertion of effect dependencies. Takes in an array of
* configurable module and import pairs to allow for user-land experimentation. For example,
Expand Down
6 changes: 6 additions & 0 deletions compiler/packages/snap/src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function makePluginOptions(
let validatePreserveExistingMemoizationGuarantees = false;
let customMacros: null | Array<Macro> = null;
let validateBlocklistedImports = null;
let enableFire = false;
let target: CompilerReactTarget = '19';

if (firstLine.indexOf('@compilationMode(annotation)') !== -1) {
Expand Down Expand Up @@ -129,6 +130,10 @@ function makePluginOptions(
validatePreserveExistingMemoizationGuarantees = true;
}

if (firstLine.includes('@enableFire')) {
enableFire = true;
}

const hookPatternMatch = /@hookPattern:"([^"]+)"/.exec(firstLine);
if (
hookPatternMatch &&
Expand Down Expand Up @@ -207,6 +212,7 @@ function makePluginOptions(
hookPattern,
validatePreserveExistingMemoizationGuarantees,
validateBlocklistedImports,
enableFire,
},
compilationMode,
logger,
Expand Down

0 comments on commit 308be6e

Please sign in to comment.