babel-plugin-react-compiler 0.0.0-experimental-e4f4f9a-20250130 → 0.0.0-experimental-a08709b-20250203

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