webpack-gc-i18n-plugin 1.1.11 → 1.1.12
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/customLoader/index.cjs +39 -0
- package/dist/customLoader/index.cjs.map +1 -1
- package/dist/customLoader/index.mjs +39 -0
- package/dist/customLoader/index.mjs.map +1 -1
- package/dist/index.cjs +39 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +39 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1628,6 +1628,7 @@ function StringLiteralFn (insertOption) {
|
|
|
1628
1628
|
|
|
1629
1629
|
// 防止导入语句,只处理那些当前节点不是键值对的键的字符串字面量,调用语句判断当前调用语句是否包含需要过滤的调用语句
|
|
1630
1630
|
if (isTranslateCall(parent) || types__namespace.isImportDeclaration(parent) || parent.key === node || types__namespace.isCallExpression(parent) && extractFnName && (option.excludedCall.includes(extractFnName) || extractFnName?.split('.')?.pop() && option.excludedCall.includes(extractFnName?.split('.')?.pop() || ''))) return;
|
|
1631
|
+
const vueVNodeCallPath = getVueCompiledVNodeCallPath(path);
|
|
1631
1632
|
let replaceNode;
|
|
1632
1633
|
if (option.deepScan && checkNeedSplit(value)) {
|
|
1633
1634
|
replaceNode = convertToTemplateLiteral(splitByRegex(value, getOriginRegex()), insertOption);
|
|
@@ -1646,9 +1647,47 @@ function StringLiteralFn (insertOption) {
|
|
|
1646
1647
|
});
|
|
1647
1648
|
}
|
|
1648
1649
|
path.replaceWith(replaceNode);
|
|
1650
|
+
markVueCompiledVNodeDynamic(vueVNodeCallPath);
|
|
1649
1651
|
}
|
|
1650
1652
|
};
|
|
1651
1653
|
}
|
|
1654
|
+
function getVueCompiledVNodeCallPath(path) {
|
|
1655
|
+
const callPath = path.parentPath;
|
|
1656
|
+
if (!callPath || !types__namespace.isCallExpression(callPath.node)) return;
|
|
1657
|
+
if (!isVueVNodeCreateCall(callPath.node)) return;
|
|
1658
|
+
if (path.listKey !== 'arguments' || path.key !== 2) return;
|
|
1659
|
+
return callPath;
|
|
1660
|
+
}
|
|
1661
|
+
function markVueCompiledVNodeDynamic(callPath) {
|
|
1662
|
+
if (!callPath || !types__namespace.isCallExpression(callPath.node)) return;
|
|
1663
|
+
const patchFlag = callPath.node.arguments[3];
|
|
1664
|
+
if (isCachedPatchFlag(patchFlag)) {
|
|
1665
|
+
const textPatchFlag = types__namespace.numericLiteral(1);
|
|
1666
|
+
textPatchFlag.leadingComments = null;
|
|
1667
|
+
textPatchFlag.innerComments = null;
|
|
1668
|
+
textPatchFlag.trailingComments = null;
|
|
1669
|
+
callPath.node.arguments[3] = textPatchFlag;
|
|
1670
|
+
}
|
|
1671
|
+
const logicalPath = callPath.findParent(parentPath => {
|
|
1672
|
+
const node = parentPath.node;
|
|
1673
|
+
if (!types__namespace.isLogicalExpression(node) || node.operator !== '||') return false;
|
|
1674
|
+
const right = node.right;
|
|
1675
|
+
return types__namespace.isAssignmentExpression(right) && right.operator === '=' && right.right === callPath.node && isVueRenderCacheMember(node.left) && isVueRenderCacheMember(right.left);
|
|
1676
|
+
});
|
|
1677
|
+
if (logicalPath) {
|
|
1678
|
+
logicalPath.replaceWith(callPath.node);
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
function isCachedPatchFlag(node) {
|
|
1682
|
+
return types__namespace.isNumericLiteral(node) && node.value === -1 || types__namespace.isUnaryExpression(node) && node.operator === '-' && types__namespace.isNumericLiteral(node.argument) && node.argument.value === 1;
|
|
1683
|
+
}
|
|
1684
|
+
function isVueVNodeCreateCall(node) {
|
|
1685
|
+
const callee = node.callee;
|
|
1686
|
+
return types__namespace.isIdentifier(callee) && ['_createElementVNode', '_createVNode', 'createElementVNode', 'createVNode'].includes(callee.name);
|
|
1687
|
+
}
|
|
1688
|
+
function isVueRenderCacheMember(node) {
|
|
1689
|
+
return types__namespace.isMemberExpression(node) && types__namespace.isIdentifier(node.object) && node.object.name === '_cache';
|
|
1690
|
+
}
|
|
1652
1691
|
function isTranslateCall(node) {
|
|
1653
1692
|
if (!types__namespace.isCallExpression(node)) return false;
|
|
1654
1693
|
const callee = node.callee;
|