babel-plugin-react-compiler 0.0.0-experimental-3ab621d-20241203 → 0.0.0-experimental-37ed2a7-20241204
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 +40 -28
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -151537,6 +151537,7 @@ function inferEffectDependencies(fn) {
|
|
151537
151537
|
}
|
151538
151538
|
const autodepFnLoads = new Map();
|
151539
151539
|
const scopeInfos = new Map();
|
151540
|
+
const loadGlobals = new Set();
|
151540
151541
|
const reactiveIds = inferReactiveIdentifiers(fn);
|
151541
151542
|
for (const [, block] of fn.body.blocks) {
|
151542
151543
|
if (
|
@@ -151558,26 +151559,22 @@ function inferEffectDependencies(fn) {
|
|
151558
151559
|
const {value: value, lvalue: lvalue} = instr;
|
151559
151560
|
if (value.kind === 'FunctionExpression') {
|
151560
151561
|
fnExpressions.set(lvalue.identifier.id, instr);
|
151561
|
-
} else if (
|
151562
|
-
|
151563
|
-
|
151564
|
-
|
151565
|
-
|
151566
|
-
|
151567
|
-
const
|
151568
|
-
if (
|
151569
|
-
|
151570
|
-
|
151571
|
-
|
151572
|
-
|
151573
|
-
|
151574
|
-
|
151575
|
-
|
151576
|
-
|
151577
|
-
if (moduleTargets != null) {
|
151578
|
-
const numRequiredArgs = moduleTargets.get(DEFAULT_EXPORT);
|
151579
|
-
if (numRequiredArgs != null) {
|
151580
|
-
autodepFnLoads.set(lvalue.identifier.id, numRequiredArgs);
|
151562
|
+
} else if (value.kind === 'LoadGlobal') {
|
151563
|
+
loadGlobals.add(lvalue.identifier.id);
|
151564
|
+
if (
|
151565
|
+
value.binding.kind === 'ImportSpecifier' ||
|
151566
|
+
value.binding.kind === 'ImportDefault'
|
151567
|
+
) {
|
151568
|
+
const moduleTargets = autodepFnConfigs.get(value.binding.module);
|
151569
|
+
if (moduleTargets != null) {
|
151570
|
+
const importSpecifierName =
|
151571
|
+
value.binding.kind === 'ImportSpecifier'
|
151572
|
+
? value.binding.imported
|
151573
|
+
: DEFAULT_EXPORT;
|
151574
|
+
const numRequiredArgs = moduleTargets.get(importSpecifierName);
|
151575
|
+
if (numRequiredArgs != null) {
|
151576
|
+
autodepFnLoads.set(lvalue.identifier.id, numRequiredArgs);
|
151577
|
+
}
|
151581
151578
|
}
|
151582
151579
|
}
|
151583
151580
|
} else if (
|
@@ -151585,6 +151582,15 @@ function inferEffectDependencies(fn) {
|
|
151585
151582
|
autodepFnLoads.get(value.callee.identifier.id) === value.args.length &&
|
151586
151583
|
value.args[0].kind === 'Identifier'
|
151587
151584
|
) {
|
151585
|
+
const effectDeps = [];
|
151586
|
+
const newInstructions = [];
|
151587
|
+
const deps = {
|
151588
|
+
kind: 'ArrayExpression',
|
151589
|
+
elements: effectDeps,
|
151590
|
+
loc: GeneratedSource,
|
151591
|
+
};
|
151592
|
+
const depsPlace = createTemporaryPlace(fn.env, GeneratedSource);
|
151593
|
+
depsPlace.effect = exports.Effect.Read;
|
151588
151594
|
const fnExpr = fnExpressions.get(value.args[0].identifier.id);
|
151589
151595
|
if (fnExpr != null) {
|
151590
151596
|
const scopeInfo =
|
@@ -151602,8 +151608,6 @@ function inferEffectDependencies(fn) {
|
|
151602
151608
|
loc: fnExpr.loc,
|
151603
151609
|
});
|
151604
151610
|
}
|
151605
|
-
const effectDeps = [];
|
151606
|
-
const newInstructions = [];
|
151607
151611
|
for (const dep of scopeInfo.deps) {
|
151608
151612
|
const {place: place, instructions: instructions} =
|
151609
151613
|
writeDependencyToInstructions(
|
@@ -151615,13 +151619,21 @@ function inferEffectDependencies(fn) {
|
|
151615
151619
|
newInstructions.push(...instructions);
|
151616
151620
|
effectDeps.push(place);
|
151617
151621
|
}
|
151618
|
-
|
151619
|
-
|
151620
|
-
elements: effectDeps,
|
151622
|
+
newInstructions.push({
|
151623
|
+
id: makeInstructionId(0),
|
151621
151624
|
loc: GeneratedSource,
|
151622
|
-
|
151623
|
-
|
151624
|
-
|
151625
|
+
lvalue: Object.assign(Object.assign({}, depsPlace), {
|
151626
|
+
effect: exports.Effect.Mutate,
|
151627
|
+
}),
|
151628
|
+
value: deps,
|
151629
|
+
});
|
151630
|
+
value.args.push(
|
151631
|
+
Object.assign(Object.assign({}, depsPlace), {
|
151632
|
+
effect: exports.Effect.Freeze,
|
151633
|
+
})
|
151634
|
+
);
|
151635
|
+
rewriteInstrs.set(instr.id, newInstructions);
|
151636
|
+
} else if (loadGlobals.has(value.args[0].identifier.id)) {
|
151625
151637
|
newInstructions.push({
|
151626
151638
|
id: makeInstructionId(0),
|
151627
151639
|
loc: GeneratedSource,
|
package/package.json
CHANGED