babel-plugin-react-compiler 0.0.0-experimental-3229e95-20250317 → 0.0.0-experimental-794db7b-20250319
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 +3 -0
- package/dist/index.js +121 -17
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -115430,6 +115430,9 @@ function printObjectPropertyKey(key2) {
|
|
115430
115430
|
case "computed": {
|
115431
115431
|
return `[${printPlace(key2.name)}]`;
|
115432
115432
|
}
|
115433
|
+
case "number": {
|
115434
|
+
return String(key2.name);
|
115435
|
+
}
|
115433
115436
|
}
|
115434
115437
|
}
|
115435
115438
|
function printInstructionValue(instrValue) {
|
@@ -119773,6 +119776,11 @@ function lowerObjectPropertyKey(builder, property) {
|
|
119773
119776
|
kind: "identifier",
|
119774
119777
|
name: key2.node.name
|
119775
119778
|
};
|
119779
|
+
} else if (key2.isNumericLiteral()) {
|
119780
|
+
return {
|
119781
|
+
kind: "identifier",
|
119782
|
+
name: String(key2.node.value)
|
119783
|
+
};
|
119776
119784
|
}
|
119777
119785
|
builder.errors.push({
|
119778
119786
|
reason: `(BuildHIR::lowerExpression) Expected Identifier, got ${key2.type} key in ObjectExpression`,
|
@@ -131129,6 +131137,9 @@ function codegenObjectPropertyKey(cx, key2) {
|
|
131129
131137
|
});
|
131130
131138
|
return expr;
|
131131
131139
|
}
|
131140
|
+
case "number": {
|
131141
|
+
return t4.numericLiteral(key2.name);
|
131142
|
+
}
|
131132
131143
|
}
|
131133
131144
|
}
|
131134
131145
|
function codegenArrayPattern(cx, pattern) {
|
@@ -139755,7 +139766,8 @@ function collectHoistablePropertyLoads(fn, temporaries, hoistableFromOptionals)
|
|
139755
139766
|
knownImmutableIdentifiers,
|
139756
139767
|
hoistableFromOptionals,
|
139757
139768
|
registry,
|
139758
|
-
nestedFnImmutableContext: null
|
139769
|
+
nestedFnImmutableContext: null,
|
139770
|
+
assumedInvokedFns: fn.env.config.enableTreatFunctionDepsAsConditional ? /* @__PURE__ */ new Set() : getAssumedInvokedFunctions(fn)
|
139759
139771
|
});
|
139760
139772
|
}
|
139761
139773
|
function collectHoistablePropertyLoadsImpl(fn, context) {
|
@@ -139893,23 +139905,25 @@ function collectNonNullsInBlocks(fn, context) {
|
|
139893
139905
|
if (maybeNonNull != null && isImmutableAtInstr(maybeNonNull.fullPath.identifier, instr.id, context)) {
|
139894
139906
|
assumedNonNullObjects.add(maybeNonNull);
|
139895
139907
|
}
|
139896
|
-
if (
|
139908
|
+
if (instr.value.kind === "FunctionExpression") {
|
139897
139909
|
const innerFn = instr.value.loweredFunc;
|
139898
|
-
|
139899
|
-
|
139900
|
-
|
139901
|
-
|
139902
|
-
|
139903
|
-
|
139904
|
-
|
139905
|
-
|
139906
|
-
|
139907
|
-
|
139908
|
-
|
139909
|
-
|
139910
|
-
|
139911
|
-
|
139912
|
-
|
139910
|
+
if (context.assumedInvokedFns.has(innerFn)) {
|
139911
|
+
const innerHoistableMap = collectHoistablePropertyLoadsImpl(
|
139912
|
+
innerFn.func,
|
139913
|
+
__spreadProps(__spreadValues({}, context), {
|
139914
|
+
nestedFnImmutableContext: (_a = context.nestedFnImmutableContext) != null ? _a : new Set(
|
139915
|
+
innerFn.func.context.filter(
|
139916
|
+
(place) => isImmutableAtInstr(place.identifier, instr.id, context)
|
139917
|
+
).map((place) => place.identifier.id)
|
139918
|
+
)
|
139919
|
+
})
|
139920
|
+
);
|
139921
|
+
const innerHoistables = assertNonNull(
|
139922
|
+
innerHoistableMap.get(innerFn.func.body.entry)
|
139923
|
+
);
|
139924
|
+
for (const entry of innerHoistables.assumedNonNullObjects) {
|
139925
|
+
assumedNonNullObjects.add(entry);
|
139926
|
+
}
|
139913
139927
|
}
|
139914
139928
|
}
|
139915
139929
|
}
|
@@ -140037,6 +140051,96 @@ function reduceMaybeOptionalChains(nodes, registry) {
|
|
140037
140051
|
}
|
140038
140052
|
} while (changed);
|
140039
140053
|
}
|
140054
|
+
function getAssumedInvokedFunctions(fn, temporaries = /* @__PURE__ */ new Map()) {
|
140055
|
+
var _a;
|
140056
|
+
const hoistableFunctions = /* @__PURE__ */ new Set();
|
140057
|
+
for (const block of fn.body.blocks.values()) {
|
140058
|
+
for (const { lvalue, value } of block.instructions) {
|
140059
|
+
if (value.kind === "FunctionExpression") {
|
140060
|
+
temporaries.set(lvalue.identifier.id, {
|
140061
|
+
fn: value.loweredFunc,
|
140062
|
+
mayInvoke: /* @__PURE__ */ new Set()
|
140063
|
+
});
|
140064
|
+
} else if (value.kind === "StoreLocal") {
|
140065
|
+
const lvalue2 = value.lvalue.place.identifier;
|
140066
|
+
const maybeLoweredFunc = temporaries.get(value.value.identifier.id);
|
140067
|
+
if (maybeLoweredFunc != null) {
|
140068
|
+
temporaries.set(lvalue2.id, maybeLoweredFunc);
|
140069
|
+
}
|
140070
|
+
} else if (value.kind === "LoadLocal") {
|
140071
|
+
const maybeLoweredFunc = temporaries.get(value.place.identifier.id);
|
140072
|
+
if (maybeLoweredFunc != null) {
|
140073
|
+
temporaries.set(lvalue.identifier.id, maybeLoweredFunc);
|
140074
|
+
}
|
140075
|
+
}
|
140076
|
+
}
|
140077
|
+
}
|
140078
|
+
for (const block of fn.body.blocks.values()) {
|
140079
|
+
for (const { lvalue, value } of block.instructions) {
|
140080
|
+
if (value.kind === "CallExpression") {
|
140081
|
+
const callee = value.callee;
|
140082
|
+
const maybeHook = getHookKind(fn.env, callee.identifier);
|
140083
|
+
const maybeLoweredFunc = temporaries.get(callee.identifier.id);
|
140084
|
+
if (maybeLoweredFunc != null) {
|
140085
|
+
hoistableFunctions.add(maybeLoweredFunc.fn);
|
140086
|
+
} else if (maybeHook != null) {
|
140087
|
+
for (const arg of value.args) {
|
140088
|
+
if (arg.kind === "Identifier") {
|
140089
|
+
const maybeLoweredFunc2 = temporaries.get(arg.identifier.id);
|
140090
|
+
if (maybeLoweredFunc2 != null) {
|
140091
|
+
hoistableFunctions.add(maybeLoweredFunc2.fn);
|
140092
|
+
}
|
140093
|
+
}
|
140094
|
+
}
|
140095
|
+
}
|
140096
|
+
} else if (value.kind === "JsxExpression") {
|
140097
|
+
for (const attr of value.props) {
|
140098
|
+
if (attr.kind === "JsxSpreadAttribute") {
|
140099
|
+
continue;
|
140100
|
+
}
|
140101
|
+
const maybeLoweredFunc = temporaries.get(attr.place.identifier.id);
|
140102
|
+
if (maybeLoweredFunc != null) {
|
140103
|
+
hoistableFunctions.add(maybeLoweredFunc.fn);
|
140104
|
+
}
|
140105
|
+
}
|
140106
|
+
for (const child of (_a = value.children) != null ? _a : []) {
|
140107
|
+
const maybeLoweredFunc = temporaries.get(child.identifier.id);
|
140108
|
+
if (maybeLoweredFunc != null) {
|
140109
|
+
hoistableFunctions.add(maybeLoweredFunc.fn);
|
140110
|
+
}
|
140111
|
+
}
|
140112
|
+
} else if (value.kind === "FunctionExpression") {
|
140113
|
+
const loweredFunc = value.loweredFunc.func;
|
140114
|
+
const lambdasCalled = getAssumedInvokedFunctions(
|
140115
|
+
loweredFunc,
|
140116
|
+
temporaries
|
140117
|
+
);
|
140118
|
+
const maybeLoweredFunc = temporaries.get(lvalue.identifier.id);
|
140119
|
+
if (maybeLoweredFunc != null) {
|
140120
|
+
for (const called of lambdasCalled) {
|
140121
|
+
maybeLoweredFunc.mayInvoke.add(called);
|
140122
|
+
}
|
140123
|
+
}
|
140124
|
+
}
|
140125
|
+
}
|
140126
|
+
if (block.terminal.kind === "return") {
|
140127
|
+
const maybeLoweredFunc = temporaries.get(
|
140128
|
+
block.terminal.value.identifier.id
|
140129
|
+
);
|
140130
|
+
if (maybeLoweredFunc != null) {
|
140131
|
+
hoistableFunctions.add(maybeLoweredFunc.fn);
|
140132
|
+
}
|
140133
|
+
}
|
140134
|
+
}
|
140135
|
+
for (const [_, { fn: fn2, mayInvoke }] of temporaries) {
|
140136
|
+
if (hoistableFunctions.has(fn2)) {
|
140137
|
+
for (const called of mayInvoke) {
|
140138
|
+
hoistableFunctions.add(called);
|
140139
|
+
}
|
140140
|
+
}
|
140141
|
+
}
|
140142
|
+
return hoistableFunctions;
|
140143
|
+
}
|
140040
140144
|
|
140041
140145
|
// src/Utils/Stack.ts
|
140042
140146
|
function empty() {
|
package/package.json
CHANGED