babel-plugin-react-compiler 0.0.0-experimental-1113db2-20250421 → 0.0.0-experimental-f69c469-20250424
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 +11 -1
- package/dist/index.js +56 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -1575,7 +1575,7 @@ declare const CompilerReactTargetSchema: z.ZodUnion<[z.ZodLiteral<"17">, z.ZodLi
|
|
1575
1575
|
type CompilerReactTarget = z.infer<typeof CompilerReactTargetSchema>;
|
1576
1576
|
declare const CompilationModeSchema: z.ZodEnum<["infer", "syntax", "annotation", "all"]>;
|
1577
1577
|
type CompilationMode = z.infer<typeof CompilationModeSchema>;
|
1578
|
-
type LoggerEvent = CompileSuccessEvent | CompileErrorEvent | CompileDiagnosticEvent | CompileSkipEvent | PipelineErrorEvent | TimingEvent;
|
1578
|
+
type LoggerEvent = CompileSuccessEvent | CompileErrorEvent | CompileDiagnosticEvent | CompileSkipEvent | PipelineErrorEvent | TimingEvent | AutoDepsDecorationsEvent | AutoDepsEligibleEvent;
|
1579
1579
|
type CompileErrorEvent = {
|
1580
1580
|
kind: 'CompileError';
|
1581
1581
|
fnLoc: t.SourceLocation | null;
|
@@ -1611,6 +1611,16 @@ type TimingEvent = {
|
|
1611
1611
|
kind: 'Timing';
|
1612
1612
|
measurement: PerformanceMeasure;
|
1613
1613
|
};
|
1614
|
+
type AutoDepsDecorationsEvent = {
|
1615
|
+
kind: 'AutoDepsDecorations';
|
1616
|
+
fnLoc: t.SourceLocation;
|
1617
|
+
decorations: Array<t.SourceLocation>;
|
1618
|
+
};
|
1619
|
+
type AutoDepsEligibleEvent = {
|
1620
|
+
kind: 'AutoDepsEligible';
|
1621
|
+
fnLoc: t.SourceLocation;
|
1622
|
+
depArrayLoc: t.SourceLocation;
|
1623
|
+
};
|
1614
1624
|
type Logger = {
|
1615
1625
|
logEvent: (filename: string | null, event: LoggerEvent) => void;
|
1616
1626
|
debugLogIRs?: (value: CompilerPipelineValue) => void;
|
package/dist/index.js
CHANGED
@@ -136404,6 +136404,7 @@ function declareTemporary(env, block, result) {
|
|
136404
136404
|
|
136405
136405
|
// src/Inference/InferEffectDependencies.ts
|
136406
136406
|
function inferEffectDependencies(fn) {
|
136407
|
+
var _a, _b;
|
136407
136408
|
let hasRewrite = false;
|
136408
136409
|
const fnExpressions = /* @__PURE__ */ new Map();
|
136409
136410
|
const autodepFnConfigs = /* @__PURE__ */ new Map();
|
@@ -136494,6 +136495,7 @@ function inferEffectDependencies(fn) {
|
|
136494
136495
|
loc: fnExpr.loc
|
136495
136496
|
});
|
136496
136497
|
}
|
136498
|
+
const usedDeps = [];
|
136497
136499
|
for (const dep of scopeInfo.deps) {
|
136498
136500
|
if ((isUseRefType(dep.identifier) || isSetStateType(dep.identifier)) && !reactiveIds.has(dep.identifier.id) || isFireFunctionType(dep.identifier)) {
|
136499
136501
|
continue;
|
@@ -136506,6 +136508,21 @@ function inferEffectDependencies(fn) {
|
|
136506
136508
|
);
|
136507
136509
|
newInstructions.push(...instructions);
|
136508
136510
|
effectDeps.push(place);
|
136511
|
+
usedDeps.push(dep);
|
136512
|
+
}
|
136513
|
+
const decorations = [];
|
136514
|
+
for (const loc of collectDepUsages(usedDeps, fnExpr.value)) {
|
136515
|
+
if (typeof loc === "symbol") {
|
136516
|
+
continue;
|
136517
|
+
}
|
136518
|
+
decorations.push(loc);
|
136519
|
+
}
|
136520
|
+
if (typeof value.loc !== "symbol") {
|
136521
|
+
(_a = fn.env.logger) == null ? void 0 : _a.logEvent(fn.env.filename, {
|
136522
|
+
kind: "AutoDepsDecorations",
|
136523
|
+
fnLoc: value.loc,
|
136524
|
+
decorations
|
136525
|
+
});
|
136509
136526
|
}
|
136510
136527
|
newInstructions.push({
|
136511
136528
|
id: makeInstructionId(0),
|
@@ -136527,6 +136544,19 @@ function inferEffectDependencies(fn) {
|
|
136527
136544
|
rewriteInstrs.set(instr.id, newInstructions);
|
136528
136545
|
fn.env.inferredEffectLocations.add(callee.loc);
|
136529
136546
|
}
|
136547
|
+
} else if (value.args.length >= 2 && value.args.length - 1 === autodepFnLoads.get(callee.identifier.id) && value.args[0] != null && value.args[0].kind === "Identifier") {
|
136548
|
+
const penultimateArg = value.args[value.args.length - 2];
|
136549
|
+
const depArrayArg = value.args[value.args.length - 1];
|
136550
|
+
if (depArrayArg.kind !== "Spread" && penultimateArg.kind !== "Spread" && typeof depArrayArg.loc !== "symbol" && typeof penultimateArg.loc !== "symbol" && typeof value.loc !== "symbol") {
|
136551
|
+
(_b = fn.env.logger) == null ? void 0 : _b.logEvent(fn.env.filename, {
|
136552
|
+
kind: "AutoDepsEligible",
|
136553
|
+
fnLoc: value.loc,
|
136554
|
+
depArrayLoc: __spreadProps(__spreadValues({}, depArrayArg.loc), {
|
136555
|
+
start: penultimateArg.loc.end,
|
136556
|
+
end: depArrayArg.loc.end
|
136557
|
+
})
|
136558
|
+
});
|
136559
|
+
}
|
136530
136560
|
}
|
136531
136561
|
}
|
136532
136562
|
}
|
@@ -136613,6 +136643,27 @@ function inferReactiveIdentifiers(fn) {
|
|
136613
136643
|
}
|
136614
136644
|
return reactiveIds;
|
136615
136645
|
}
|
136646
|
+
function collectDepUsages(deps, fnExpr) {
|
136647
|
+
const identifiers = /* @__PURE__ */ new Map();
|
136648
|
+
const loadedDeps = /* @__PURE__ */ new Set();
|
136649
|
+
const sourceLocations = [];
|
136650
|
+
for (const dep of deps) {
|
136651
|
+
identifiers.set(dep.identifier.id, dep);
|
136652
|
+
}
|
136653
|
+
for (const [, block] of fnExpr.loweredFunc.func.body.blocks) {
|
136654
|
+
for (const instr of block.instructions) {
|
136655
|
+
if (instr.value.kind === "LoadLocal" && identifiers.has(instr.value.place.identifier.id)) {
|
136656
|
+
loadedDeps.add(instr.lvalue.identifier.id);
|
136657
|
+
}
|
136658
|
+
for (const place of eachInstructionOperand(instr)) {
|
136659
|
+
if (loadedDeps.has(place.identifier.id)) {
|
136660
|
+
sourceLocations.push(place.identifier.loc);
|
136661
|
+
}
|
136662
|
+
}
|
136663
|
+
}
|
136664
|
+
}
|
136665
|
+
return sourceLocations;
|
136666
|
+
}
|
136616
136667
|
|
136617
136668
|
// src/Optimization/InstructionReordering.ts
|
136618
136669
|
function instructionReordering(fn) {
|
@@ -142615,6 +142666,11 @@ function runWithEnvironment(func, env) {
|
|
142615
142666
|
});
|
142616
142667
|
if (env.config.inferEffectDependencies) {
|
142617
142668
|
inferEffectDependencies(hir);
|
142669
|
+
log2({
|
142670
|
+
kind: "hir",
|
142671
|
+
name: "InferEffectDependencies",
|
142672
|
+
value: hir
|
142673
|
+
});
|
142618
142674
|
}
|
142619
142675
|
if (env.config.inlineJsxTransform) {
|
142620
142676
|
inlineJsxTransform(hir, env.config.inlineJsxTransform);
|
package/package.json
CHANGED