@@ -37381,6 +37381,7 @@ class Environment {
37381
37381
_Environment_nextScope.set(this, 0);
37382
37382
_Environment_scope.set(this, void 0);
37383
37383
_Environment_outlinedFunctions.set(this, []);
37384
+ this.inferredEffectLocations = new Set();
37384
37385
_Environment_contextIdentifiers.set(this, void 0);
37385
37386
_Environment_hoistedIdentifiers.set(this, void 0);
37386
37387
__classPrivateFieldSet(this, _Environment_scope, scope, "f");
@@ -42169,6 +42170,7 @@ function codegenReactiveFunction(cx, fn) {
42169
42170
outlined: [],
42170
42171
hasFireRewrite: fn.env.hasFireRewrite,
42171
42172
hasInferredEffect: fn.env.hasInferredEffect,
42173
+ inferredEffectLocations: fn.env.inferredEffectLocations,
42172
42174
});
42173
42175
}
42174
42176
class CountMemoBlockVisitor extends ReactiveFunctionVisitor {
@@ -48286,6 +48288,7 @@ function inferEffectDependencies(fn) {
48286
48288
});
48287
48289
value.args.push(Object.assign(Object.assign({}, depsPlace), { effect: Effect.Freeze }));
48288
48290
rewriteInstrs.set(instr.id, newInstructions);
48291
+ fn.env.inferredEffectLocations.add(callee.loc);
48289
48292
}
48290
48293
else if (loadGlobals.has(value.args[0].identifier.id)) {
48291
48294
newInstructions.push({
@@ -48296,6 +48299,7 @@ function inferEffectDependencies(fn) {
48296
48299
});
48297
48300
value.args.push(Object.assign(Object.assign({}, depsPlace), { effect: Effect.Freeze }));
48298
48301
rewriteInstrs.set(instr.id, newInstructions);
48302
+ fn.env.inferredEffectLocations.add(callee.loc);
48299
48303
}
48300
48304
}
48301
48305
}
@@ -54378,6 +54382,7 @@ function compileProgram(program, pass) {
54378
54382
ArrowFunctionExpression: traverseFunction,
54379
54383
}, Object.assign(Object.assign({}, pass), { opts: Object.assign(Object.assign({}, pass.opts), pass.opts), filename: (_b = pass.filename) !== null && _b !== void 0 ? _b : null }));
54380
54384
const retryErrors = [];
54385
+ const inferredEffectLocations = new Set();
54381
54386
const processFn = (fn, fnType) => {
54382
54387
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
54383
54388
let optInDirectives = [];
@@ -54462,6 +54467,10 @@ function compileProgram(program, pass) {
54462
54467
if (!pass.opts.noEmit) {
54463
54468
return compileResult.compiledFn;
54464
54469
}
54470
+ for (const loc of compileResult.compiledFn.inferredEffectLocations) {
54471
+ if (loc !== GeneratedSource)
54472
+ inferredEffectLocations.add(loc);
54473
+ }
54465
54474
return null;
54466
54475
};
54467
54476
while (queue.length !== 0) {
@@ -54516,7 +54525,7 @@ function compileProgram(program, pass) {
54516
54525
if (compiledFns.length > 0) {
54517
54526
addImportsToProgram(program, programContext);
54518
54527
}
54519
- return { retryErrors };
54528
+ return { retryErrors, inferredEffectLocations };
54520
54529
}
54521
54530
function shouldSkipCompilation(program, pass) {
54522
54531
if (pass.opts.sources) {
@@ -55190,7 +55199,10 @@ function assertValidEffectImportReference(numArgs, paths, context) {
55190
55199
const parent = path.parentPath;
55191
55200
if (parent != null && parent.isCallExpression()) {
55192
55201
const args = parent.get('arguments');
55193
- if (args.length === numArgs) {
55202
+ const maybeCalleeLoc = path.node.loc;
55203
+ const hasInferredEffect = maybeCalleeLoc != null &&
55204
+ context.inferredEffectLocations.has(maybeCalleeLoc);
55205
+ if (args.length === numArgs && !hasInferredEffect) {
55194
55206
const maybeErrorDiagnostic = matchCompilerDiagnostic(path, context.transformErrors);
55195
55207
throwInvalidReact({
55196
55208
reason: '[InferEffectDependencies] React Compiler is unable to infer dependencies of this effect. ' +
@@ -55219,7 +55231,7 @@ function assertValidFireImportReference(paths, context) {
55219
55231
}, context);
55220
55232
}
55221
55233
}
55222
- function validateNoUntransformedReferences(path, filename, logger, env, transformErrors ) {
55234
+ function validateNoUntransformedReferences(path, filename, logger, env, compileResult ) {
55223
55235
const moduleLoadChecks = new Map();
55224
55236
if (env.enableFire) {
55225
55237
for (const module of Environment.knownReactModules) {
@@ -55234,7 +55246,7 @@ function validateNoUntransformedReferences(path, filename, logger, env, transfor
55234
55246
}
55235
55247
}
55236
55248
if (moduleLoadChecks.size > 0) {
55237
- transformProgram(path, moduleLoadChecks, filename, logger, transformErrors );
55249
+ transformProgram(path, moduleLoadChecks, filename, logger, compileResult );
55238
55250
}
55239
55251
}
55240
55252
function validateImportSpecifier(specifier, importSpecifierChecks, state) {
@@ -55294,13 +55306,15 @@ function validateNamespacedImport(specifier, importSpecifierChecks, state) {
55294
55306
checkFn(references, state);
55295
55307
}
55296
55308
}
55297
- function transformProgram(path, moduleLoadChecks, filename, logger, transformErrors) {
55309
+ function transformProgram(path, moduleLoadChecks, filename, logger, compileResult) {
55310
+ var _a, _b;
55298
55311
const traversalState = {
55299
55312
shouldInvalidateScopes: true,
55300
55313
program: path,
55301
55314
filename,
55302
55315
logger,
55303
- transformErrors,
55316
+ transformErrors: (_a = compileResult === null || compileResult === void 0 ? void 0 : compileResult.retryErrors) !== null && _a !== void 0 ? _a : [],
55317
+ inferredEffectLocations: (_b = compileResult === null || compileResult === void 0 ? void 0 : compileResult.inferredEffectLocations) !== null && _b !== void 0 ? _b : new Set(),
55304
55318
};
55305
55319
path.traverse({
55306
55320
ImportDeclaration(path) {
@@ -55336,7 +55350,7 @@ function BabelPluginReactCompiler(_babel) {
55336
55350
visitor: {
55337
55351
Program: {
55338
55352
enter(prog, pass) {
55339
- var _a, _b, _c, _d, _e ;
55353
+ var _a, _b, _c, _d;
55340
55354
const filename = (_a = pass.filename) !== null && _a !== void 0 ? _a : 'unknown';
55341
55355
if (ENABLE_REACT_COMPILER_TIMINGS === true) {
55342
55356
performance.mark(`${filename}:start`, {
@@ -55359,7 +55373,7 @@ function BabelPluginReactCompiler(_babel) {
55359
55373
comments: (_c = pass.file.ast.comments) !== null && _c !== void 0 ? _c : [],
55360
55374
code: pass.file.code,
55361
55375
});
55362
- validateNoUntransformedReferences(prog, (_d = pass.filename) !== null && _d !== void 0 ? _d : null, opts.logger, opts.environment, (_e = result === null || result === void 0 ? void 0 : result.retryErrors) !== null && _e !== void 0 ? _e : [] );
55376
+ validateNoUntransformedReferences(prog, (_d = pass.filename) !== null && _d !== void 0 ? _d : null, opts.logger, opts.environment, result);
55363
55377
if (ENABLE_REACT_COMPILER_TIMINGS === true) {
55364
55378
performance.mark(`${filename}:end`, {
55365
55379
detail: 'BabelPlugin:Program:end',
0 commit comments