babel-plugin-react-compiler 0.0.0-experimental-8f8b1db-20250523 → 0.0.0-experimental-a550a97-20250527

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1558,6 +1558,8 @@ declare const DynamicGatingOptionsSchema: z.ZodObject<{
1558
1558
  source: string;
1559
1559
  }>;
1560
1560
  type DynamicGatingOptions = z.infer<typeof DynamicGatingOptionsSchema>;
1561
+ declare const CustomOptOutDirectiveSchema: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
1562
+ type CustomOptOutDirective = z.infer<typeof CustomOptOutDirectiveSchema>;
1561
1563
  type PluginOptions = {
1562
1564
  environment: EnvironmentConfig;
1563
1565
  logger: Logger | null;
@@ -1569,6 +1571,7 @@ type PluginOptions = {
1569
1571
  eslintSuppressionRules: Array<string> | null | undefined;
1570
1572
  flowSuppressions: boolean;
1571
1573
  ignoreUseNoForget: boolean;
1574
+ customOptOutDirectives: CustomOptOutDirective;
1572
1575
  sources: Array<string> | ((filename: string) => boolean) | null;
1573
1576
  enableReanimatedCheck: boolean;
1574
1577
  target: CompilerReactTarget;
@@ -1647,7 +1650,7 @@ type CompilerPass = {
1647
1650
  declare const OPT_IN_DIRECTIVES: Set<string>;
1648
1651
  declare const OPT_OUT_DIRECTIVES: Set<string>;
1649
1652
  declare function tryFindDirectiveEnablingMemoization(directives: Array<t.Directive>, opts: PluginOptions): Result<t.Directive | null, CompilerError>;
1650
- declare function findDirectiveDisablingMemoization(directives: Array<t.Directive>): t.Directive | null;
1653
+ declare function findDirectiveDisablingMemoization(directives: Array<t.Directive>, { customOptOutDirectives }: PluginOptions): t.Directive | null;
1651
1654
  type BabelFn = NodePath$1<t.FunctionDeclaration> | NodePath$1<t.FunctionExpression> | NodePath$1<t.ArrowFunctionExpression>;
1652
1655
  type CompileProgramMetadata = {
1653
1656
  retryErrors: Array<{
package/dist/index.js CHANGED
@@ -97362,11 +97362,16 @@ function tryFindDirectiveEnablingMemoization(directives, opts) {
97362
97362
  return Err(dynamicGating.unwrapErr());
97363
97363
  }
97364
97364
  }
97365
- function findDirectiveDisablingMemoization(directives) {
97366
- var _a;
97367
- return (_a = directives.find(
97365
+ function findDirectiveDisablingMemoization(directives, { customOptOutDirectives }) {
97366
+ var _a, _b;
97367
+ if (customOptOutDirectives != null) {
97368
+ return (_a = directives.find(
97369
+ (directive2) => customOptOutDirectives.indexOf(directive2.value.value) !== -1
97370
+ )) != null ? _a : null;
97371
+ }
97372
+ return (_b = directives.find(
97368
97373
  (directive2) => OPT_OUT_DIRECTIVES.has(directive2.value.value)
97369
- )) != null ? _a : null;
97374
+ )) != null ? _b : null;
97370
97375
  }
97371
97376
  function findDirectivesDynamicGating(directives, opts) {
97372
97377
  var _a, _b;
@@ -97593,7 +97598,7 @@ function compileProgram(program, pass) {
97593
97598
  filename: pass.filename,
97594
97599
  code: pass.code,
97595
97600
  suppressions,
97596
- hasModuleScopeOptOut: findDirectiveDisablingMemoization(program.node.directives) != null
97601
+ hasModuleScopeOptOut: findDirectiveDisablingMemoization(program.node.directives, pass.opts) != null
97597
97602
  });
97598
97603
  const queue = findFunctionsToCompile(
97599
97604
  program,
@@ -97702,7 +97707,10 @@ function processFn(fn, fnType, programContext) {
97702
97707
  }
97703
97708
  directives = {
97704
97709
  optIn: optIn.unwrapOr(null),
97705
- optOut: findDirectiveDisablingMemoization(fn.node.body.directives)
97710
+ optOut: findDirectiveDisablingMemoization(
97711
+ fn.node.body.directives,
97712
+ programContext.opts
97713
+ )
97706
97714
  };
97707
97715
  }
97708
97716
  let compiledFn;
@@ -98408,6 +98416,7 @@ var PanicThresholdOptionsSchema = z.enum([
98408
98416
  var DynamicGatingOptionsSchema = z.object({
98409
98417
  source: z.string()
98410
98418
  });
98419
+ var CustomOptOutDirectiveSchema = z.nullable(z.array(z.string())).default(null);
98411
98420
  var CompilerReactTargetSchema = z.union([
98412
98421
  z.literal("17"),
98413
98422
  z.literal("18"),
@@ -98458,6 +98467,7 @@ var defaultOptions = {
98458
98467
  return filename.indexOf("node_modules") === -1;
98459
98468
  },
98460
98469
  enableReanimatedCheck: true,
98470
+ customOptOutDirectives: null,
98461
98471
  target: "19"
98462
98472
  };
98463
98473
  function parsePluginOptions(obj) {
@@ -98514,6 +98524,20 @@ function parsePluginOptions(obj) {
98514
98524
  }
98515
98525
  break;
98516
98526
  }
98527
+ case "customOptOutDirectives": {
98528
+ const result = CustomOptOutDirectiveSchema.safeParse(value);
98529
+ if (result.success) {
98530
+ parsedOptions[key2] = result.data;
98531
+ } else {
98532
+ CompilerError.throwInvalidConfig({
98533
+ reason: "Could not parse custom opt out directives. Update React Compiler config to fix the error",
98534
+ description: `${fromZodError(result.error)}`,
98535
+ loc: null,
98536
+ suggestions: null
98537
+ });
98538
+ }
98539
+ break;
98540
+ }
98517
98541
  default: {
98518
98542
  parsedOptions[key2] = value;
98519
98543
  }
@@ -98927,20 +98951,24 @@ var testComplexConfigDefaults = {
98927
98951
  }
98928
98952
  ]
98929
98953
  };
98954
+ function* splitPragma(pragma) {
98955
+ for (const entry of pragma.split("@")) {
98956
+ const keyVal = entry.trim();
98957
+ const valIdx = keyVal.indexOf(":");
98958
+ if (valIdx === -1) {
98959
+ yield { key: keyVal.split(" ", 1)[0], value: null };
98960
+ } else {
98961
+ yield { key: keyVal.slice(0, valIdx), value: keyVal.slice(valIdx + 1) };
98962
+ }
98963
+ }
98964
+ }
98930
98965
  function parseConfigPragmaEnvironmentForTest(pragma) {
98931
98966
  const maybeConfig = {};
98932
- for (const token2 of pragma.split(" ")) {
98933
- if (!token2.startsWith("@")) {
98934
- continue;
98935
- }
98936
- const keyVal = token2.slice(1);
98937
- const valIdx = keyVal.indexOf(":");
98938
- const key2 = valIdx === -1 ? keyVal : keyVal.slice(0, valIdx);
98939
- const val = valIdx === -1 ? void 0 : keyVal.slice(valIdx + 1);
98940
- const isSet = val === void 0 || val === "true";
98967
+ for (const { key: key2, value: val } of splitPragma(pragma)) {
98941
98968
  if (!hasOwnProperty2(EnvironmentConfigSchema.shape, key2)) {
98942
98969
  continue;
98943
98970
  }
98971
+ const isSet = val == null || val === "true";
98944
98972
  if (isSet && key2 in testComplexConfigDefaults) {
98945
98973
  maybeConfig[key2] = testComplexConfigDefaults[key2];
98946
98974
  } else if (isSet) {
@@ -98992,18 +99020,11 @@ function parseConfigPragmaForTests(pragma, defaults) {
98992
99020
  compilationMode: defaults.compilationMode,
98993
99021
  environment
98994
99022
  });
98995
- for (const token2 of pragma.split(" ")) {
98996
- if (!token2.startsWith("@")) {
98997
- continue;
98998
- }
98999
- const keyVal = token2.slice(1);
99000
- const idx = keyVal.indexOf(":");
99001
- const key2 = idx === -1 ? keyVal : keyVal.slice(0, idx);
99002
- const val = idx === -1 ? void 0 : keyVal.slice(idx + 1);
99023
+ for (const { key: key2, value: val } of splitPragma(pragma)) {
99003
99024
  if (!hasOwnProperty2(defaultOptions, key2)) {
99004
99025
  continue;
99005
99026
  }
99006
- const isSet = val === void 0 || val === "true";
99027
+ const isSet = val == null || val === "true";
99007
99028
  if (isSet && key2 in testComplexPluginOptionDefaults) {
99008
99029
  options[key2] = testComplexPluginOptionDefaults[key2];
99009
99030
  } else if (isSet) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-plugin-react-compiler",
3
- "version": "0.0.0-experimental-8f8b1db-20250523",
3
+ "version": "0.0.0-experimental-a550a97-20250527",
4
4
  "description": "Babel plugin for React Compiler.",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",