@wevu/compiler 6.16.30 → 6.16.31
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 +23 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -5936,6 +5936,22 @@ function collectForAliasMapping(context) {
|
|
|
5936
5936
|
}
|
|
5937
5937
|
return mapping;
|
|
5938
5938
|
}
|
|
5939
|
+
function isThisMemberChain(node) {
|
|
5940
|
+
if (!node) return false;
|
|
5941
|
+
if (t.isThisExpression(node)) return true;
|
|
5942
|
+
if (t.isMemberExpression(node)) return isThisMemberChain(node.object);
|
|
5943
|
+
return false;
|
|
5944
|
+
}
|
|
5945
|
+
function isUnrefCallArgument(node, parent) {
|
|
5946
|
+
return t.isCallExpression(parent) && t.isIdentifier(parent.callee, { name: "__wevuUnref" }) && parent.arguments.includes(node);
|
|
5947
|
+
}
|
|
5948
|
+
function isMemberCallTarget(node, parent) {
|
|
5949
|
+
return (t.isCallExpression(parent) || t.isOptionalCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node;
|
|
5950
|
+
}
|
|
5951
|
+
function shouldUnrefMemberAccess(node, parent) {
|
|
5952
|
+
if (isThisMemberChain(node) || isUnrefCallArgument(node, parent) || isMemberCallTarget(node, parent)) return false;
|
|
5953
|
+
return true;
|
|
5954
|
+
}
|
|
5939
5955
|
function normalizeJsExpressionWithContext(exp, context, options) {
|
|
5940
5956
|
const trimmed = exp.trim();
|
|
5941
5957
|
if (!trimmed) return null;
|
|
@@ -5990,6 +6006,11 @@ function normalizeJsExpressionWithContext(exp, context, options) {
|
|
|
5990
6006
|
path.replaceWith(replacement);
|
|
5991
6007
|
path.skip();
|
|
5992
6008
|
} });
|
|
6009
|
+
if (options?.unrefMemberAccess) traverse(ast, { MemberExpression: { exit(path) {
|
|
6010
|
+
if (!shouldUnrefMemberAccess(path.node, path.parentPath?.node)) return;
|
|
6011
|
+
path.replaceWith(createUnrefCall(t.cloneNode(path.node, true)));
|
|
6012
|
+
path.skip();
|
|
6013
|
+
} } });
|
|
5993
6014
|
const stmt = ast.program.body[0];
|
|
5994
6015
|
return (stmt && "expression" in stmt ? stmt.expression : null) || null;
|
|
5995
6016
|
}
|
|
@@ -6026,7 +6047,8 @@ function shouldFallbackToRuntimeBinding(exp) {
|
|
|
6026
6047
|
function registerRuntimeBindingExpression(exp, context, options) {
|
|
6027
6048
|
const expAst = normalizeJsExpressionWithContext(exp, context, {
|
|
6028
6049
|
...options,
|
|
6029
|
-
runtimePropAccess: "helper"
|
|
6050
|
+
runtimePropAccess: "helper",
|
|
6051
|
+
unrefMemberAccess: true
|
|
6030
6052
|
});
|
|
6031
6053
|
if (!expAst) return null;
|
|
6032
6054
|
const binding = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wevu/compiler",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.16.
|
|
4
|
+
"version": "6.16.31",
|
|
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.35",
|
|
53
53
|
"@weapp-core/constants": "0.1.12",
|
|
54
54
|
"@weapp-core/shared": "3.0.4",
|
|
55
|
-
"@weapp-vite/ast": "6.16.
|
|
55
|
+
"@weapp-vite/ast": "6.16.31",
|
|
56
56
|
"rolldown-require": "2.0.18"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|