@wevu/compiler 6.16.47 → 6.17.0
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.mjs +44 -23
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -490,6 +490,10 @@ function rewriteJsLikeImportsForTempDir(source, fromDir, tempDir) {
|
|
|
490
490
|
const sourceNode = p.node?.source;
|
|
491
491
|
if (sourceNode && t.isStringLiteral(sourceNode)) rewriteLiteral(sourceNode, sourceNode.value);
|
|
492
492
|
},
|
|
493
|
+
ImportExpression(p) {
|
|
494
|
+
const sourceNode = p.node?.source;
|
|
495
|
+
if (sourceNode && t.isStringLiteral(sourceNode)) rewriteLiteral(sourceNode, sourceNode.value);
|
|
496
|
+
},
|
|
493
497
|
CallExpression(p) {
|
|
494
498
|
const callee = p.node?.callee;
|
|
495
499
|
if (!callee) return;
|
|
@@ -1517,6 +1521,11 @@ function getCallCalleeName(callee) {
|
|
|
1517
1521
|
object: callee.object.name,
|
|
1518
1522
|
property: callee.property.name
|
|
1519
1523
|
};
|
|
1524
|
+
if (t.isOptionalMemberExpression(callee) && !callee.computed && t.isIdentifier(callee.object) && t.isIdentifier(callee.property)) return {
|
|
1525
|
+
type: "member",
|
|
1526
|
+
object: callee.object.name,
|
|
1527
|
+
property: callee.property.name
|
|
1528
|
+
};
|
|
1520
1529
|
return null;
|
|
1521
1530
|
}
|
|
1522
1531
|
function collectCalledBindingsFromFunctionBody(fn, engine = "babel") {
|
|
@@ -1562,6 +1571,23 @@ function collectCalledBindingsFromFunctionBody(fn, engine = "babel") {
|
|
|
1562
1571
|
}
|
|
1563
1572
|
//#endregion
|
|
1564
1573
|
//#region src/plugins/wevu/pageFeatures/reachability/hooks.ts
|
|
1574
|
+
function getMemberHookName(callee) {
|
|
1575
|
+
if (t.isMemberExpression(callee) && !callee.computed && t.isIdentifier(callee.object) && t.isIdentifier(callee.property)) return {
|
|
1576
|
+
object: callee.object.name,
|
|
1577
|
+
hook: callee.property.name
|
|
1578
|
+
};
|
|
1579
|
+
if (t.isOptionalMemberExpression(callee) && !callee.computed && t.isIdentifier(callee.object) && t.isIdentifier(callee.property)) return {
|
|
1580
|
+
object: callee.object.name,
|
|
1581
|
+
hook: callee.property.name
|
|
1582
|
+
};
|
|
1583
|
+
return null;
|
|
1584
|
+
}
|
|
1585
|
+
function addNamespaceHookFeature(module, callee, enabled) {
|
|
1586
|
+
const memberHook = getMemberHookName(callee);
|
|
1587
|
+
if (!memberHook || !module.wevuNamespaceLocals.has(memberHook.object)) return;
|
|
1588
|
+
const matched = WE_VU_PAGE_HOOK_TO_FEATURE[memberHook.hook];
|
|
1589
|
+
if (matched) enabled.add(matched);
|
|
1590
|
+
}
|
|
1565
1591
|
function collectWevuHookCallsInFunctionBody(module, fn) {
|
|
1566
1592
|
const enabled = /* @__PURE__ */ new Set();
|
|
1567
1593
|
if (module.engine === "oxc") {
|
|
@@ -1600,11 +1626,7 @@ function collectWevuHookCallsInFunctionBody(module, fn) {
|
|
|
1600
1626
|
if (matched) enabled.add(matched);
|
|
1601
1627
|
return;
|
|
1602
1628
|
}
|
|
1603
|
-
|
|
1604
|
-
if (!module.wevuNamespaceLocals.has(callee.object.name)) return;
|
|
1605
|
-
const matched = WE_VU_PAGE_HOOK_TO_FEATURE[callee.property.name];
|
|
1606
|
-
if (matched) enabled.add(matched);
|
|
1607
|
-
}
|
|
1629
|
+
addNamespaceHookFeature(module, callee, enabled);
|
|
1608
1630
|
} else if (t.isOptionalCallExpression(node)) {
|
|
1609
1631
|
const callee = node.callee;
|
|
1610
1632
|
if (t.isIdentifier(callee)) {
|
|
@@ -1612,11 +1634,7 @@ function collectWevuHookCallsInFunctionBody(module, fn) {
|
|
|
1612
1634
|
if (matched) enabled.add(matched);
|
|
1613
1635
|
return;
|
|
1614
1636
|
}
|
|
1615
|
-
|
|
1616
|
-
if (!module.wevuNamespaceLocals.has(callee.object.name)) return;
|
|
1617
|
-
const matched = WE_VU_PAGE_HOOK_TO_FEATURE[callee.property.name];
|
|
1618
|
-
if (matched) enabled.add(matched);
|
|
1619
|
-
}
|
|
1637
|
+
addNamespaceHookFeature(module, callee, enabled);
|
|
1620
1638
|
}
|
|
1621
1639
|
});
|
|
1622
1640
|
return enabled;
|
|
@@ -2475,6 +2493,18 @@ function stripOptionalFromPattern(pattern) {
|
|
|
2475
2493
|
}
|
|
2476
2494
|
//#endregion
|
|
2477
2495
|
//#region src/plugins/vue/transform/transformScript/macros/stripTypes.ts
|
|
2496
|
+
function stripTypeArguments(node) {
|
|
2497
|
+
let stripped = false;
|
|
2498
|
+
if (node.typeParameters) {
|
|
2499
|
+
node.typeParameters = null;
|
|
2500
|
+
stripped = true;
|
|
2501
|
+
}
|
|
2502
|
+
if (node.typeArguments) {
|
|
2503
|
+
node.typeArguments = null;
|
|
2504
|
+
stripped = true;
|
|
2505
|
+
}
|
|
2506
|
+
return stripped;
|
|
2507
|
+
}
|
|
2478
2508
|
function createStripTypesVisitors(state) {
|
|
2479
2509
|
return {
|
|
2480
2510
|
ExportNamedDeclaration(path) {
|
|
@@ -2506,16 +2536,10 @@ function createStripTypesVisitors(state) {
|
|
|
2506
2536
|
return;
|
|
2507
2537
|
}
|
|
2508
2538
|
}
|
|
2509
|
-
if (path.node
|
|
2510
|
-
path.node.typeParameters = null;
|
|
2511
|
-
state.transformed = true;
|
|
2512
|
-
}
|
|
2539
|
+
if (stripTypeArguments(path.node)) state.transformed = true;
|
|
2513
2540
|
},
|
|
2514
2541
|
NewExpression(path) {
|
|
2515
|
-
if (path.node
|
|
2516
|
-
path.node.typeParameters = null;
|
|
2517
|
-
state.transformed = true;
|
|
2518
|
-
}
|
|
2542
|
+
if (stripTypeArguments(path.node)) state.transformed = true;
|
|
2519
2543
|
},
|
|
2520
2544
|
ObjectProperty(path) {
|
|
2521
2545
|
if (t.isIdentifier(path.node.key, { name: "__name" }) || t.isStringLiteral(path.node.key, { value: "__name" })) {
|
|
@@ -2572,10 +2596,7 @@ function createStripTypesVisitors(state) {
|
|
|
2572
2596
|
path.node.returnType = null;
|
|
2573
2597
|
state.transformed = true;
|
|
2574
2598
|
}
|
|
2575
|
-
if (path.node
|
|
2576
|
-
path.node.typeParameters = null;
|
|
2577
|
-
state.transformed = true;
|
|
2578
|
-
}
|
|
2599
|
+
if (stripTypeArguments(path.node)) state.transformed = true;
|
|
2579
2600
|
for (const param of path.node.params) if (stripOptionalFromPattern(param)) state.transformed = true;
|
|
2580
2601
|
},
|
|
2581
2602
|
ClassMethod(path) {
|
|
@@ -9402,7 +9423,7 @@ function detectDefinePropsReservedName(scriptSetupCode) {
|
|
|
9402
9423
|
path.stop();
|
|
9403
9424
|
return;
|
|
9404
9425
|
}
|
|
9405
|
-
const typeParam = path.node.typeParameters?.params?.[0];
|
|
9426
|
+
const typeParam = (path.node.typeParameters ?? path.node.typeArguments)?.params?.[0];
|
|
9406
9427
|
if (typePropsContainReservedName(typeParam, typeScope)) {
|
|
9407
9428
|
result = { location: getDefinePropsLocation(path.node) };
|
|
9408
9429
|
path.stop();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wevu/compiler",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.17.0",
|
|
5
5
|
"description": "wevu 编译器基础包,面向小程序模板的编译与转换",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"vue": "^3.5.38",
|
|
53
53
|
"@weapp-core/constants": "0.1.12",
|
|
54
54
|
"@weapp-core/shared": "3.0.4",
|
|
55
|
-
"@weapp-vite/ast": "6.
|
|
55
|
+
"@weapp-vite/ast": "6.17.0",
|
|
56
56
|
"rolldown-require": "2.0.19"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|