babel-plugin-react-compiler 19.0.0-beta-27714ef-20250124 → 19.0.0-beta-714736e-20250131

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.js CHANGED
@@ -126596,6 +126596,7 @@ var EnvironmentConfigSchema = z.object({
126596
126596
  * original source will be disabled as well.
126597
126597
  */
126598
126598
  disableMemoizationForDebugging: z.boolean().default(false),
126599
+ enableMinimalTransformsForRetry: z.boolean().default(false),
126599
126600
  /**
126600
126601
  * When true, rather using memoized values, the compiler will always re-compute
126601
126602
  * values, and then use a heuristic to compare the memoized value to the newly
@@ -126662,6 +126663,17 @@ var EnvironmentConfigSchema = z.object({
126662
126663
  */
126663
126664
  lowerContextAccess: ExternalFunctionSchema.nullable().default(null)
126664
126665
  });
126666
+ var MINIMAL_RETRY_CONFIG = {
126667
+ validateHooksUsage: false,
126668
+ validateRefAccessDuringRender: false,
126669
+ validateNoSetStateInRender: false,
126670
+ validateNoSetStateInPassiveEffects: false,
126671
+ validateNoJSXInTryStatements: false,
126672
+ validateMemoizedEffectDependencies: false,
126673
+ validateNoCapitalizedCalls: null,
126674
+ validateBlocklistedImports: null,
126675
+ enableMinimalTransformsForRetry: true
126676
+ };
126665
126677
  var testComplexConfigDefaults = {
126666
126678
  validateNoCapitalizedCalls: [],
126667
126679
  enableChangeDetectionForDebugging: {
@@ -135319,7 +135331,7 @@ function inferReferenceEffects(fn, options = { isFunctionExpression: false }) {
135319
135331
  }
135320
135332
  if (options.isFunctionExpression) {
135321
135333
  fn.effects = functionEffects;
135322
- } else {
135334
+ } else if (!fn.env.config.enableMinimalTransformsForRetry) {
135323
135335
  raiseFunctionEffectErrors(functionEffects);
135324
135336
  }
135325
135337
  }
@@ -144694,7 +144706,7 @@ function runWithEnvironment(func, env) {
144694
144706
  log2({ kind: "hir", name: "PruneMaybeThrows", value: hir });
144695
144707
  validateContextVariableLValues(hir);
144696
144708
  validateUseMemo(hir);
144697
- if (!env.config.enablePreserveExistingManualUseMemo && !env.config.disableMemoizationForDebugging && !env.config.enableChangeDetectionForDebugging) {
144709
+ if (!env.config.enablePreserveExistingManualUseMemo && !env.config.disableMemoizationForDebugging && !env.config.enableChangeDetectionForDebugging && !env.config.enableMinimalTransformsForRetry) {
144698
144710
  dropManualMemoization(hir);
144699
144711
  log2({ kind: "hir", name: "DropManualMemoization", value: hir });
144700
144712
  }
@@ -144779,8 +144791,10 @@ function runWithEnvironment(func, env) {
144779
144791
  name: "PropagatePhiTypes",
144780
144792
  value: hir
144781
144793
  });
144782
- inferReactiveScopeVariables(hir);
144783
- log2({ kind: "hir", name: "InferReactiveScopeVariables", value: hir });
144794
+ if (!env.config.enableMinimalTransformsForRetry) {
144795
+ inferReactiveScopeVariables(hir);
144796
+ log2({ kind: "hir", name: "InferReactiveScopeVariables", value: hir });
144797
+ }
144784
144798
  const fbtOperands = memoizeFbtAndMacroOperandsInSameScope(hir);
144785
144799
  log2({
144786
144800
  kind: "hir",
@@ -145343,52 +145357,75 @@ function compileProgram(program, pass) {
145343
145357
  fn.node.body.directives
145344
145358
  );
145345
145359
  }
145346
- let compiledFn;
145347
- try {
145348
- const suppressionsInFunction = filterSuppressionsThatAffectFunction(
145349
- suppressions,
145350
- fn
145351
- );
145352
- if (suppressionsInFunction.length > 0) {
145353
- const lintError = suppressionsToCompilerError(suppressionsInFunction);
145354
- if (optOutDirectives.length > 0) {
145355
- logError(lintError, pass, fn.node.loc ?? null);
145356
- } else {
145357
- handleError(lintError, pass, fn.node.loc ?? null);
145358
- }
145359
- return null;
145360
+ const suppressionsInFunction = filterSuppressionsThatAffectFunction(
145361
+ suppressions,
145362
+ fn
145363
+ );
145364
+ let compileResult;
145365
+ if (suppressionsInFunction.length > 0) {
145366
+ compileResult = {
145367
+ kind: "error",
145368
+ error: suppressionsToCompilerError(suppressionsInFunction)
145369
+ };
145370
+ } else {
145371
+ try {
145372
+ compileResult = {
145373
+ kind: "compile",
145374
+ compiledFn: compileFn(
145375
+ fn,
145376
+ environment,
145377
+ fnType,
145378
+ useMemoCacheIdentifier.name,
145379
+ pass.opts.logger,
145380
+ pass.filename,
145381
+ pass.code
145382
+ )
145383
+ };
145384
+ } catch (err) {
145385
+ compileResult = { kind: "error", error: err };
145360
145386
  }
145361
- compiledFn = compileFn(
145362
- fn,
145363
- environment,
145364
- fnType,
145365
- useMemoCacheIdentifier.name,
145366
- pass.opts.logger,
145367
- pass.filename,
145368
- pass.code
145369
- );
145370
- pass.opts.logger?.logEvent(pass.filename, {
145371
- kind: "CompileSuccess",
145372
- fnLoc: fn.node.loc ?? null,
145373
- fnName: compiledFn.id?.name ?? null,
145374
- memoSlots: compiledFn.memoSlotsUsed,
145375
- memoBlocks: compiledFn.memoBlocks,
145376
- memoValues: compiledFn.memoValues,
145377
- prunedMemoBlocks: compiledFn.prunedMemoBlocks,
145378
- prunedMemoValues: compiledFn.prunedMemoValues
145379
- });
145380
- } catch (err) {
145381
- if (fn.node.body.type === "BlockStatement") {
145382
- if (optOutDirectives.length > 0) {
145383
- logError(err, pass, fn.node.loc ?? null);
145384
- return null;
145385
- }
145387
+ }
145388
+ if (compileResult.kind === "error" && environment.enableFire) {
145389
+ try {
145390
+ compileResult = {
145391
+ kind: "compile",
145392
+ compiledFn: compileFn(
145393
+ fn,
145394
+ {
145395
+ ...environment,
145396
+ ...MINIMAL_RETRY_CONFIG
145397
+ },
145398
+ fnType,
145399
+ useMemoCacheIdentifier.name,
145400
+ pass.opts.logger,
145401
+ pass.filename,
145402
+ pass.code
145403
+ )
145404
+ };
145405
+ } catch (err) {
145406
+ compileResult = { kind: "error", error: err };
145407
+ }
145408
+ }
145409
+ if (compileResult.kind === "error") {
145410
+ if (optOutDirectives.length > 0) {
145411
+ logError(compileResult.error, pass, fn.node.loc ?? null);
145412
+ } else {
145413
+ handleError(compileResult.error, pass, fn.node.loc ?? null);
145386
145414
  }
145387
- handleError(err, pass, fn.node.loc ?? null);
145388
145415
  return null;
145389
145416
  }
145417
+ pass.opts.logger?.logEvent(pass.filename, {
145418
+ kind: "CompileSuccess",
145419
+ fnLoc: fn.node.loc ?? null,
145420
+ fnName: compileResult.compiledFn.id?.name ?? null,
145421
+ memoSlots: compileResult.compiledFn.memoSlotsUsed,
145422
+ memoBlocks: compileResult.compiledFn.memoBlocks,
145423
+ memoValues: compileResult.compiledFn.memoValues,
145424
+ prunedMemoBlocks: compileResult.compiledFn.prunedMemoBlocks,
145425
+ prunedMemoValues: compileResult.compiledFn.prunedMemoValues
145426
+ });
145390
145427
  if (optInDirectives.length > 0) {
145391
- return compiledFn;
145428
+ return compileResult.compiledFn;
145392
145429
  } else if (pass.opts.compilationMode === "annotation") {
145393
145430
  return null;
145394
145431
  }
@@ -145404,7 +145441,7 @@ function compileProgram(program, pass) {
145404
145441
  return null;
145405
145442
  }
145406
145443
  if (!pass.opts.noEmit) {
145407
- return compiledFn;
145444
+ return compileResult.compiledFn;
145408
145445
  }
145409
145446
  return null;
145410
145447
  };