babel-plugin-react-compiler 0.0.0-experimental-702922b-20241115 → 0.0.0-experimental-ce0575a-20241118
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 +114 -71
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -132806,7 +132806,7 @@ function lowerJsxElementName(builder, exprPath) {
|
|
132806
132806
|
}
|
132807
132807
|
}
|
132808
132808
|
function lowerJsxMemberExpression(builder, exprPath) {
|
132809
|
-
var _a, _b;
|
132809
|
+
var _a, _b, _c;
|
132810
132810
|
const loc =
|
132811
132811
|
(_a = exprPath.node.loc) !== null && _a !== void 0 ? _a : GeneratedSource;
|
132812
132812
|
const object = exprPath.get('object');
|
@@ -132820,7 +132820,15 @@ function lowerJsxMemberExpression(builder, exprPath) {
|
|
132820
132820
|
loc: (_b = object.node.loc) !== null && _b !== void 0 ? _b : null,
|
132821
132821
|
suggestions: null,
|
132822
132822
|
});
|
132823
|
-
|
132823
|
+
const kind = getLoadKind(builder, object);
|
132824
|
+
objectPlace = lowerValueToTemporary(builder, {
|
132825
|
+
kind: kind,
|
132826
|
+
place: lowerIdentifier(builder, object),
|
132827
|
+
loc:
|
132828
|
+
(_c = exprPath.node.loc) !== null && _c !== void 0
|
132829
|
+
? _c
|
132830
|
+
: GeneratedSource,
|
132831
|
+
});
|
132824
132832
|
}
|
132825
132833
|
const property = exprPath.get('property').node.name;
|
132826
132834
|
return lowerValueToTemporary(builder, {
|
@@ -136664,6 +136672,7 @@ const EnvironmentConfigSchema = z.object({
|
|
136664
136672
|
enablePreserveExistingManualUseMemo: z.boolean().default(false),
|
136665
136673
|
enableForest: z.boolean().default(false),
|
136666
136674
|
enableUseTypeAnnotations: z.boolean().default(false),
|
136675
|
+
enableFunctionDependencyRewrite: z.boolean().default(true),
|
136667
136676
|
inlineJsxTransform: ReactElementSymbolSchema.nullable().default(null),
|
136668
136677
|
validateHooksUsage: z.boolean().default(true),
|
136669
136678
|
validateRefAccessDuringRender: z.boolean().default(true),
|
@@ -140883,6 +140892,9 @@ function deadCodeElimination(fn) {
|
|
140883
140892
|
}
|
140884
140893
|
}
|
140885
140894
|
}
|
140895
|
+
retainWhere(fn.context, contextVar =>
|
140896
|
+
state.isIdOrNameUsed(contextVar.identifier)
|
140897
|
+
);
|
140886
140898
|
}
|
140887
140899
|
let State$2 = class State {
|
140888
140900
|
constructor() {
|
@@ -141644,28 +141656,41 @@ function createPropsProperties(
|
|
141644
141656
|
propAttributes.forEach(prop => {
|
141645
141657
|
switch (prop.kind) {
|
141646
141658
|
case 'JsxAttribute': {
|
141647
|
-
|
141648
|
-
|
141649
|
-
|
141650
|
-
|
141651
|
-
|
141652
|
-
|
141653
|
-
|
141654
|
-
|
141655
|
-
|
141656
|
-
|
141657
|
-
|
141658
|
-
|
141659
|
-
|
141660
|
-
|
141661
|
-
|
141662
|
-
|
141663
|
-
|
141664
|
-
|
141665
|
-
|
141666
|
-
|
141667
|
-
|
141668
|
-
|
141659
|
+
switch (prop.name) {
|
141660
|
+
case 'key': {
|
141661
|
+
keyProperty = {
|
141662
|
+
kind: 'ObjectProperty',
|
141663
|
+
key: {name: 'key', kind: 'string'},
|
141664
|
+
type: 'property',
|
141665
|
+
place: Object.assign({}, prop.place),
|
141666
|
+
};
|
141667
|
+
break;
|
141668
|
+
}
|
141669
|
+
case 'ref': {
|
141670
|
+
refProperty = {
|
141671
|
+
kind: 'ObjectProperty',
|
141672
|
+
key: {name: 'ref', kind: 'string'},
|
141673
|
+
type: 'property',
|
141674
|
+
place: Object.assign({}, prop.place),
|
141675
|
+
};
|
141676
|
+
const refPropProperty = {
|
141677
|
+
kind: 'ObjectProperty',
|
141678
|
+
key: {name: 'ref', kind: 'string'},
|
141679
|
+
type: 'property',
|
141680
|
+
place: Object.assign({}, prop.place),
|
141681
|
+
};
|
141682
|
+
props.push(refPropProperty);
|
141683
|
+
break;
|
141684
|
+
}
|
141685
|
+
default: {
|
141686
|
+
const attributeProperty = {
|
141687
|
+
kind: 'ObjectProperty',
|
141688
|
+
key: {name: prop.name, kind: 'string'},
|
141689
|
+
type: 'property',
|
141690
|
+
place: Object.assign({}, prop.place),
|
141691
|
+
};
|
141692
|
+
props.push(attributeProperty);
|
141693
|
+
}
|
141669
141694
|
}
|
141670
141695
|
break;
|
141671
141696
|
}
|
@@ -149872,12 +149897,18 @@ let Visitor$7 = class Visitor extends ReactiveFunctionVisitor {
|
|
149872
149897
|
visitPrunedScope(scopeBlock, state) {
|
149873
149898
|
this.traversePrunedScope(scopeBlock, state);
|
149874
149899
|
for (const [id, decl] of scopeBlock.scope.declarations) {
|
149875
|
-
if (
|
149900
|
+
if (
|
149901
|
+
!isPrimitiveType(decl.identifier) &&
|
149902
|
+
!isStableRefType(decl.identifier, state)
|
149903
|
+
) {
|
149876
149904
|
state.add(id);
|
149877
149905
|
}
|
149878
149906
|
}
|
149879
149907
|
}
|
149880
149908
|
};
|
149909
|
+
function isStableRefType(identifier, reactiveIdentifiers) {
|
149910
|
+
return isUseRefType(identifier) && !reactiveIdentifiers.has(identifier.id);
|
149911
|
+
}
|
149881
149912
|
function collectReactiveIdentifiers(fn) {
|
149882
149913
|
const visitor = new Visitor$7();
|
149883
149914
|
const state = new Set();
|
@@ -156337,6 +156368,7 @@ class Context {
|
|
156337
156368
|
this.visitDependency(nextDependency);
|
156338
156369
|
}
|
156339
156370
|
visitDependency(maybeDependency) {
|
156371
|
+
var _a;
|
156340
156372
|
const originalDeclaration = __classPrivateFieldGet(
|
156341
156373
|
this,
|
156342
156374
|
_Context_declarations,
|
@@ -156368,6 +156400,14 @@ class Context {
|
|
156368
156400
|
}
|
156369
156401
|
});
|
156370
156402
|
}
|
156403
|
+
if (
|
156404
|
+
isUseRefType(maybeDependency.identifier) &&
|
156405
|
+
((_a = maybeDependency.path.at(0)) === null || _a === void 0
|
156406
|
+
? void 0
|
156407
|
+
: _a.property) === 'current'
|
156408
|
+
) {
|
156409
|
+
maybeDependency = {identifier: maybeDependency.identifier, path: []};
|
156410
|
+
}
|
156371
156411
|
if (
|
156372
156412
|
__classPrivateFieldGet(
|
156373
156413
|
this,
|
@@ -156411,15 +156451,7 @@ class Context {
|
|
156411
156451
|
(_Context_checkValidDependency = function _Context_checkValidDependency(
|
156412
156452
|
maybeDependency
|
156413
156453
|
) {
|
156414
|
-
var _a
|
156415
|
-
if (
|
156416
|
-
isUseRefType(maybeDependency.identifier) &&
|
156417
|
-
((_a = maybeDependency.path.at(0)) === null || _a === void 0
|
156418
|
-
? void 0
|
156419
|
-
: _a.property) === 'current'
|
156420
|
-
) {
|
156421
|
-
return false;
|
156422
|
-
}
|
156454
|
+
var _a;
|
156423
156455
|
if (isRefValueType(maybeDependency.identifier)) {
|
156424
156456
|
return false;
|
156425
156457
|
}
|
@@ -156428,10 +156460,10 @@ class Context {
|
|
156428
156460
|
}
|
156429
156461
|
const identifier = maybeDependency.identifier;
|
156430
156462
|
const currentDeclaration =
|
156431
|
-
(
|
156463
|
+
(_a = __classPrivateFieldGet(this, _Context_reassignments, 'f').get(
|
156432
156464
|
identifier
|
156433
|
-
)) !== null &&
|
156434
|
-
?
|
156465
|
+
)) !== null && _a !== void 0
|
156466
|
+
? _a
|
156435
156467
|
: __classPrivateFieldGet(this, _Context_declarations, 'f').get(
|
156436
156468
|
identifier.declarationId
|
156437
156469
|
);
|
@@ -156514,46 +156546,57 @@ function collectDependencies(
|
|
156514
156546
|
}
|
156515
156547
|
}
|
156516
156548
|
const scopeTraversal = new ScopeBlockTraversal();
|
156517
|
-
|
156518
|
-
|
156519
|
-
|
156520
|
-
|
156521
|
-
(
|
156522
|
-
|
156523
|
-
: scopeBlockInfo.kind) === 'begin'
|
156524
|
-
) {
|
156525
|
-
context.enterScope(scopeBlockInfo.scope);
|
156526
|
-
} else if (
|
156527
|
-
(scopeBlockInfo === null || scopeBlockInfo === void 0
|
156528
|
-
? void 0
|
156529
|
-
: scopeBlockInfo.kind) === 'end'
|
156530
|
-
) {
|
156531
|
-
context.exitScope(
|
156532
|
-
scopeBlockInfo.scope,
|
156533
|
-
scopeBlockInfo === null || scopeBlockInfo === void 0
|
156549
|
+
const handleFunction = fn => {
|
156550
|
+
for (const [blockId, block] of fn.body.blocks) {
|
156551
|
+
scopeTraversal.recordScopes(block);
|
156552
|
+
const scopeBlockInfo = scopeTraversal.blockInfos.get(blockId);
|
156553
|
+
if (
|
156554
|
+
(scopeBlockInfo === null || scopeBlockInfo === void 0
|
156534
156555
|
? void 0
|
156535
|
-
: scopeBlockInfo.
|
156536
|
-
)
|
156537
|
-
|
156538
|
-
|
156539
|
-
|
156540
|
-
|
156541
|
-
|
156542
|
-
|
156556
|
+
: scopeBlockInfo.kind) === 'begin'
|
156557
|
+
) {
|
156558
|
+
context.enterScope(scopeBlockInfo.scope);
|
156559
|
+
} else if (
|
156560
|
+
(scopeBlockInfo === null || scopeBlockInfo === void 0
|
156561
|
+
? void 0
|
156562
|
+
: scopeBlockInfo.kind) === 'end'
|
156563
|
+
) {
|
156564
|
+
context.exitScope(scopeBlockInfo.scope, scopeBlockInfo.pruned);
|
156565
|
+
}
|
156566
|
+
for (const phi of block.phis) {
|
156567
|
+
for (const operand of phi.operands) {
|
156568
|
+
const maybeOptionalChain = temporaries.get(operand[1].identifier.id);
|
156569
|
+
if (maybeOptionalChain) {
|
156570
|
+
context.visitDependency(maybeOptionalChain);
|
156571
|
+
}
|
156543
156572
|
}
|
156544
156573
|
}
|
156545
|
-
|
156546
|
-
|
156547
|
-
|
156548
|
-
|
156574
|
+
for (const instr of block.instructions) {
|
156575
|
+
if (
|
156576
|
+
fn.env.config.enableFunctionDependencyRewrite &&
|
156577
|
+
(instr.value.kind === 'FunctionExpression' ||
|
156578
|
+
instr.value.kind === 'ObjectMethod')
|
156579
|
+
) {
|
156580
|
+
context.declare(instr.lvalue.identifier, {
|
156581
|
+
id: instr.id,
|
156582
|
+
scope: context.currentScope,
|
156583
|
+
});
|
156584
|
+
const wasInInnerFn = context.inInnerFn;
|
156585
|
+
context.inInnerFn = true;
|
156586
|
+
handleFunction(instr.value.loweredFunc.func);
|
156587
|
+
context.inInnerFn = wasInInnerFn;
|
156588
|
+
} else if (!processedInstrsInOptional.has(instr)) {
|
156589
|
+
handleInstruction(instr, context);
|
156590
|
+
}
|
156549
156591
|
}
|
156550
|
-
|
156551
|
-
|
156552
|
-
|
156553
|
-
|
156592
|
+
if (!processedInstrsInOptional.has(block.terminal)) {
|
156593
|
+
for (const place of eachTerminalOperand(block.terminal)) {
|
156594
|
+
context.visitOperand(place);
|
156595
|
+
}
|
156554
156596
|
}
|
156555
156597
|
}
|
156556
|
-
}
|
156598
|
+
};
|
156599
|
+
handleFunction(fn);
|
156557
156600
|
return context.deps;
|
156558
156601
|
}
|
156559
156602
|
function outlineJSX(fn) {
|
package/package.json
CHANGED