@wevu/compiler 6.16.12 → 6.16.13
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 +75 -21
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import os from "node:os";
|
|
|
13
13
|
import process from "node:process";
|
|
14
14
|
import { collectFeatureFlagsFromCode, collectJsxImportedComponentsAndDefaultExportFromBabelAst, collectJsxTemplateTagsFromBabelExpression, getRenderPropertyFromComponentOptions, parseJsLikeWithEngine, resolveRenderExpressionFromComponentOptions, toStaticObjectKey, unwrapTypeScriptExpression } from "@weapp-vite/ast";
|
|
15
15
|
import { LRUCache } from "lru-cache";
|
|
16
|
-
import { WEVU_CLASS_STYLE_RUNTIME_FILE, WEVU_CLASS_STYLE_RUNTIME_MODULE, WEVU_EXPRESSION_ERROR_IDENTIFIER, WEVU_INLINE_HANDLER, WEVU_INLINE_MAP_KEY, WEVU_IS_PAGE_KEY, WEVU_LAYOUT_HOSTS_KEY, WEVU_LAYOUT_HOST_ID_PREFIX, WEVU_LAYOUT_HOST_REF_PREFIX, WEVU_MODEL_HANDLER, WEVU_OWNER_HANDLER, WEVU_PROPS_KEY, WEVU_SLOT_NAMES_ATTR, WEVU_SLOT_NAMES_PROP,
|
|
16
|
+
import { WEVU_CLASS_STYLE_RUNTIME_FILE, WEVU_CLASS_STYLE_RUNTIME_MODULE, WEVU_EXPRESSION_ERROR_IDENTIFIER, WEVU_INLINE_HANDLER, WEVU_INLINE_MAP_KEY, WEVU_IS_PAGE_KEY, WEVU_LAYOUT_HOSTS_KEY, WEVU_LAYOUT_HOST_ID_PREFIX, WEVU_LAYOUT_HOST_REF_PREFIX, WEVU_MODEL_HANDLER, WEVU_OWNER_HANDLER, WEVU_PROPS_KEY, WEVU_SLOT_NAMES_ATTR, WEVU_SLOT_NAMES_PROP, WEVU_SLOT_OWNER_ID_ATTR, WEVU_SLOT_OWNER_ID_KEY, WEVU_SLOT_OWNER_ID_PROP, WEVU_SLOT_OWNER_KEY, WEVU_SLOT_OWNER_PROXY_KEY, WEVU_SLOT_PROPS_ATTR, WEVU_SLOT_PROPS_DATA_KEY, WEVU_SLOT_PROPS_KEY, WEVU_SLOT_SCOPE_ATTR, WEVU_SLOT_SCOPE_KEY, WEVU_TEMPLATE_REFS_KEY } from "@weapp-core/constants";
|
|
17
17
|
import { compileScript, parse } from "vue/compiler-sfc";
|
|
18
18
|
import { fileURLToPath } from "node:url";
|
|
19
19
|
import { parse as parse$1 } from "@vue/compiler-dom";
|
|
@@ -5623,7 +5623,7 @@ function normalizeJsExpressionWithContext(exp, context, options) {
|
|
|
5623
5623
|
const base = createThisMemberAccess(WEVU_SLOT_PROPS_DATA_KEY);
|
|
5624
5624
|
replacement = createUnrefCall(prop ? createMemberAccess(base, prop) : base);
|
|
5625
5625
|
} else if (name === WEVU_SLOT_OWNER_KEY || name === WEVU_SLOT_PROPS_DATA_KEY || name === WEVU_SLOT_PROPS_KEY || name === WEVU_SLOT_SCOPE_KEY) replacement = createUnrefCall(createThisMemberAccess(name));
|
|
5626
|
-
else replacement = createUnrefCall(createMemberAccess(createThisMemberAccess(
|
|
5626
|
+
else replacement = createUnrefCall(createMemberAccess(createThisMemberAccess(WEVU_SLOT_OWNER_PROXY_KEY), name));
|
|
5627
5627
|
else replacement = createUnrefCall(createIdentifierAccessWithPropsFallback(name));
|
|
5628
5628
|
const parent = path.parentPath;
|
|
5629
5629
|
if (parent.isObjectProperty() && parent.node.shorthand && parent.node.key === path.node) {
|
|
@@ -6324,12 +6324,13 @@ function parseSlotPropsExpression(exp, context) {
|
|
|
6324
6324
|
function collectSlotBindingExpression(node, context) {
|
|
6325
6325
|
let bindObjectExp = null;
|
|
6326
6326
|
const namedBindings = [];
|
|
6327
|
+
const hasForDirective = node.props.some((prop) => prop.type === NodeTypes.DIRECTIVE && prop.name === "for");
|
|
6327
6328
|
for (const prop of node.props) {
|
|
6328
6329
|
if (prop.type === NodeTypes.ATTRIBUTE && prop.name === "name") continue;
|
|
6329
6330
|
if (prop.type === NodeTypes.DIRECTIVE && prop.name === "bind") {
|
|
6330
6331
|
if (prop.arg?.type === NodeTypes.SIMPLE_EXPRESSION) {
|
|
6331
6332
|
const rawExpValue = getBindDirectiveExpression(prop);
|
|
6332
|
-
if (prop.arg.content === "name") continue;
|
|
6333
|
+
if (prop.arg.content === "name" || hasForDirective && prop.arg.content === "key") continue;
|
|
6333
6334
|
if (rawExpValue) namedBindings.push({
|
|
6334
6335
|
key: prop.arg.content,
|
|
6335
6336
|
value: normalizeWxmlExpressionWithContext(rawExpValue, context)
|
|
@@ -6552,13 +6553,13 @@ function transformSlotElement(node, context, transformNode) {
|
|
|
6552
6553
|
if (!slotPropsExp && slotPresentExp) slotTag = `${context.platform.wrapIf(slotPresentExp, slotTag, (exp) => renderMustache(exp, context))}${context.platform.wrapElse(fallbackContent)}`;
|
|
6553
6554
|
else if (!slotPropsExp) slotTag = `<slot${slotAttrString}>${fallbackContent}</slot>`;
|
|
6554
6555
|
}
|
|
6555
|
-
if (!slotPropsExp && (context.scopedSlotsRequireProps || slotNameInfo.type !== "default")) return slotTag;
|
|
6556
|
+
if (!slotPropsExp && (context.scopedSlotsRequireProps || slotNameInfo.type !== "default" && context.scopedSlotsCompiler !== "augmented")) return slotTag;
|
|
6556
6557
|
const genericKey = `scoped-slots-${resolveSlotKey(context, slotNameInfo)}`;
|
|
6557
6558
|
context.componentGenerics[genericKey] = true;
|
|
6558
6559
|
slotPropsExp = slotPropsExp ?? "[]";
|
|
6559
6560
|
const scopedAttrs = [
|
|
6560
6561
|
`${context.platform.directives.ifAttr}="${renderMustache(WEVU_SLOT_OWNER_ID_PROP, context)}"`,
|
|
6561
|
-
`${
|
|
6562
|
+
`${WEVU_SLOT_OWNER_ID_ATTR}="${renderMustache(WEVU_SLOT_OWNER_ID_PROP, context)}"`,
|
|
6562
6563
|
`${WEVU_SLOT_PROPS_ATTR}="${renderMustache(slotPropsExp, context)}"`
|
|
6563
6564
|
];
|
|
6564
6565
|
if (context.slotMultipleInstance) scopedAttrs.push(`${WEVU_SLOT_SCOPE_ATTR}="${renderMustache(WEVU_SLOT_SCOPE_KEY, context)}"`);
|
|
@@ -6613,11 +6614,12 @@ function hasDirectComponentSlotChild(children, context) {
|
|
|
6613
6614
|
function isWevuComponentTag(node, context) {
|
|
6614
6615
|
return context.wevuComponentTags ? context.wevuComponentTags.has(node.tag) : /^[A-Z]/.test(node.tag);
|
|
6615
6616
|
}
|
|
6616
|
-
function
|
|
6617
|
-
if (context.scopedSlotsRequireProps
|
|
6618
|
-
if (context.scopedSlotsCompiler !== "augmented" && !isWevuComponentTag(ownerNode, context)) return false;
|
|
6617
|
+
function shouldAugmentPlainSlot(decl, context, ownerNode) {
|
|
6618
|
+
if (context.scopedSlotsRequireProps) return false;
|
|
6619
6619
|
if (context.rewriteScopedSlot && !isWevuComponentTag(ownerNode, context)) return false;
|
|
6620
6620
|
if (context.scopedSlotsCompiler === "augmented") return true;
|
|
6621
|
+
if (!decl.implicitDefault) return false;
|
|
6622
|
+
if (!isWevuComponentTag(ownerNode, context)) return false;
|
|
6621
6623
|
return hasDirectComponentSlotChild(decl.children, context);
|
|
6622
6624
|
}
|
|
6623
6625
|
function resolveTemplateSlotCondition(node, context) {
|
|
@@ -6656,6 +6658,14 @@ function pushSlotNamesAttr(attrs, slotNames, context) {
|
|
|
6656
6658
|
function shouldExposePlainSlotPresence(node) {
|
|
6657
6659
|
return node.tag === "component";
|
|
6658
6660
|
}
|
|
6661
|
+
function renderPlainSlotContentInSourceOrder(renderItems, plainSlotDeclarations, implicitDefaultDeclaration, context, transformNode) {
|
|
6662
|
+
const plainSlots = new Set(plainSlotDeclarations);
|
|
6663
|
+
const shouldRenderImplicitDefault = implicitDefaultDeclaration ? plainSlots.has(implicitDefaultDeclaration) : false;
|
|
6664
|
+
return renderItems.map((item) => {
|
|
6665
|
+
if (item.type === "declaration") return plainSlots.has(item.declaration) ? renderSlotFallback(item.declaration, context, transformNode) : "";
|
|
6666
|
+
return shouldRenderImplicitDefault ? transformNode(item.child, context) : "";
|
|
6667
|
+
}).join("");
|
|
6668
|
+
}
|
|
6659
6669
|
function shouldTransformAsComponentWithSlots(node, context, resolvedTag = resolveTemplateTagName(node.tag, context)) {
|
|
6660
6670
|
const slotDirective = findSlotDirective(node);
|
|
6661
6671
|
const templateSlotChildren = node.children.filter((child) => child.type === NodeTypes.ELEMENT && child.tag === "template" && findSlotDirective(child));
|
|
@@ -6669,25 +6679,41 @@ function transformComponentWithSlots(node, context, transformNode, options) {
|
|
|
6669
6679
|
const slotDeclarations = [];
|
|
6670
6680
|
const slotDirective = findSlotDirective(node);
|
|
6671
6681
|
const nonTemplateChildren = [];
|
|
6682
|
+
const renderItems = [];
|
|
6672
6683
|
for (const child of node.children) {
|
|
6673
6684
|
if (child.type === NodeTypes.ELEMENT && child.tag === "template") {
|
|
6674
6685
|
const templateSlot = findSlotDirective(child);
|
|
6675
6686
|
if (templateSlot) {
|
|
6676
|
-
const
|
|
6677
|
-
slotDeclarations.push(
|
|
6687
|
+
const declaration = buildSlotDeclaration(resolveSlotNameFromDirective(templateSlot), templateSlot.exp?.type === NodeTypes.SIMPLE_EXPRESSION ? templateSlot.exp.content : void 0, child.children, context, { condition: resolveTemplateSlotCondition(child, context) });
|
|
6688
|
+
slotDeclarations.push(declaration);
|
|
6689
|
+
renderItems.push({
|
|
6690
|
+
type: "declaration",
|
|
6691
|
+
declaration
|
|
6692
|
+
});
|
|
6678
6693
|
continue;
|
|
6679
6694
|
}
|
|
6680
6695
|
}
|
|
6681
6696
|
nonTemplateChildren.push(child);
|
|
6697
|
+
if (isRenderableSlotChild(child)) renderItems.push({
|
|
6698
|
+
type: "default-child",
|
|
6699
|
+
child
|
|
6700
|
+
});
|
|
6682
6701
|
}
|
|
6683
6702
|
const defaultSlotChildren = nonTemplateChildren.filter(isRenderableSlotChild);
|
|
6703
|
+
let implicitDefaultDeclaration;
|
|
6684
6704
|
if (slotDirective) {
|
|
6685
6705
|
if (slotDeclarations.length) context.warnings.push("组件上的 v-slot 与 <template v-slot> 不能同时使用;仅使用组件上的 v-slot。");
|
|
6686
6706
|
slotDeclarations.length = 0;
|
|
6687
6707
|
slotDeclarations.push(buildSlotDeclaration(resolveSlotNameFromDirective(slotDirective), slotDirective.exp?.type === NodeTypes.SIMPLE_EXPRESSION ? slotDirective.exp.content : void 0, node.children, context));
|
|
6688
6708
|
} else if (slotDeclarations.length && defaultSlotChildren.length) if (slotDeclarations.some((decl) => decl.name.type === "default" || decl.name.type === "static" && decl.name.value === "default")) context.warnings.push("存在显式的 v-slot:default,默认插槽内容将被忽略。");
|
|
6689
|
-
else
|
|
6690
|
-
|
|
6709
|
+
else {
|
|
6710
|
+
implicitDefaultDeclaration = buildSlotDeclaration({ type: "default" }, void 0, defaultSlotChildren, context, { implicitDefault: true });
|
|
6711
|
+
slotDeclarations.push(implicitDefaultDeclaration);
|
|
6712
|
+
}
|
|
6713
|
+
else if (!slotDeclarations.length && defaultSlotChildren.length && !context.scopedSlotsRequireProps && !hasLegacySlotAttribute(defaultSlotChildren)) {
|
|
6714
|
+
implicitDefaultDeclaration = buildSlotDeclaration({ type: "default" }, void 0, defaultSlotChildren, context, { implicitDefault: true });
|
|
6715
|
+
slotDeclarations.push(implicitDefaultDeclaration);
|
|
6716
|
+
}
|
|
6691
6717
|
if (!slotDeclarations.length) {
|
|
6692
6718
|
const { attrs, vTextExp } = collectElementAttributes(node, context, {
|
|
6693
6719
|
skipSlotDirective: true,
|
|
@@ -6704,7 +6730,7 @@ function transformComponentWithSlots(node, context, transformNode, options) {
|
|
|
6704
6730
|
}
|
|
6705
6731
|
const scopedSlotDeclarations = [];
|
|
6706
6732
|
const plainSlotDeclarations = [];
|
|
6707
|
-
for (const decl of slotDeclarations) if (Object.keys(decl.props).length > 0 ||
|
|
6733
|
+
for (const decl of slotDeclarations) if (Object.keys(decl.props).length > 0 || shouldAugmentPlainSlot(decl, context, node)) scopedSlotDeclarations.push(decl);
|
|
6708
6734
|
else plainSlotDeclarations.push(decl);
|
|
6709
6735
|
const slotNames = [];
|
|
6710
6736
|
const slotGenericAttrs = [];
|
|
@@ -6735,11 +6761,12 @@ function transformComponentWithSlots(node, context, transformNode, options) {
|
|
|
6735
6761
|
if (scopedSlotDeclarations.length) {
|
|
6736
6762
|
const scopePropsExp = buildScopePropsExpression(context);
|
|
6737
6763
|
if (scopePropsExp) mergedAttrs.push(`${WEVU_SLOT_SCOPE_ATTR}="${renderMustache(scopePropsExp, context)}"`);
|
|
6738
|
-
|
|
6764
|
+
const ownerIdExp = context.rewriteScopedSlot ? `${WEVU_SLOT_OWNER_ID_PROP} || ${WEVU_SLOT_OWNER_ID_KEY} || ''` : `${WEVU_SLOT_OWNER_ID_KEY} || ''`;
|
|
6765
|
+
mergedAttrs.push(`${WEVU_SLOT_OWNER_ID_ATTR}="${renderMustache(ownerIdExp, context)}"`);
|
|
6739
6766
|
}
|
|
6740
6767
|
const attrString = mergedAttrs.length ? ` ${mergedAttrs.join(" ")}` : "";
|
|
6741
6768
|
const { tag } = node;
|
|
6742
|
-
const plainSlotContent = plainSlotDeclarations.map((decl) => renderSlotFallback(decl, context, transformNode)).join("");
|
|
6769
|
+
const plainSlotContent = slotDirective ? plainSlotDeclarations.map((decl) => renderSlotFallback(decl, context, transformNode)).join("") : renderPlainSlotContentInSourceOrder(renderItems, plainSlotDeclarations, implicitDefaultDeclaration, context, transformNode);
|
|
6743
6770
|
return plainSlotContent ? `<${tag}${attrString}>${plainSlotContent}</${tag}>` : `<${tag}${attrString} />`;
|
|
6744
6771
|
}
|
|
6745
6772
|
function transformComponentWithSlotsFallback(node, context, transformNode, options) {
|
|
@@ -6747,24 +6774,37 @@ function transformComponentWithSlotsFallback(node, context, transformNode, optio
|
|
|
6747
6774
|
const slotDeclarations = [];
|
|
6748
6775
|
const slotDirective = findSlotDirective(node);
|
|
6749
6776
|
const nonTemplateChildren = [];
|
|
6777
|
+
const renderItems = [];
|
|
6750
6778
|
for (const child of node.children) {
|
|
6751
6779
|
if (child.type === NodeTypes.ELEMENT && child.tag === "template") {
|
|
6752
6780
|
const templateSlot = findSlotDirective(child);
|
|
6753
6781
|
if (templateSlot) {
|
|
6754
|
-
const
|
|
6755
|
-
slotDeclarations.push(
|
|
6782
|
+
const declaration = buildSlotDeclaration(resolveSlotNameFromDirective(templateSlot), templateSlot.exp?.type === NodeTypes.SIMPLE_EXPRESSION ? templateSlot.exp.content : void 0, child.children, context, { condition: resolveTemplateSlotCondition(child, context) });
|
|
6783
|
+
slotDeclarations.push(declaration);
|
|
6784
|
+
renderItems.push({
|
|
6785
|
+
type: "declaration",
|
|
6786
|
+
declaration
|
|
6787
|
+
});
|
|
6756
6788
|
continue;
|
|
6757
6789
|
}
|
|
6758
6790
|
}
|
|
6759
6791
|
nonTemplateChildren.push(child);
|
|
6792
|
+
if (isRenderableSlotChild(child)) renderItems.push({
|
|
6793
|
+
type: "default-child",
|
|
6794
|
+
child
|
|
6795
|
+
});
|
|
6760
6796
|
}
|
|
6761
6797
|
const defaultSlotChildren = nonTemplateChildren.filter(isRenderableSlotChild);
|
|
6798
|
+
let implicitDefaultDeclaration;
|
|
6762
6799
|
if (slotDirective) {
|
|
6763
6800
|
if (slotDeclarations.length) context.warnings.push("组件上的 v-slot 与 <template v-slot> 不能同时使用;仅使用组件上的 v-slot。");
|
|
6764
6801
|
slotDeclarations.length = 0;
|
|
6765
6802
|
slotDeclarations.push(buildSlotDeclaration(resolveSlotNameFromDirective(slotDirective), slotDirective.exp?.type === NodeTypes.SIMPLE_EXPRESSION ? slotDirective.exp.content : void 0, node.children, context));
|
|
6766
6803
|
} else if (slotDeclarations.length && defaultSlotChildren.length) if (slotDeclarations.some((decl) => decl.name.type === "default" || decl.name.type === "static" && decl.name.value === "default")) context.warnings.push("存在显式的 v-slot:default,默认插槽内容将被忽略。");
|
|
6767
|
-
else
|
|
6804
|
+
else {
|
|
6805
|
+
implicitDefaultDeclaration = buildSlotDeclaration({ type: "default" }, void 0, defaultSlotChildren, context);
|
|
6806
|
+
slotDeclarations.push(implicitDefaultDeclaration);
|
|
6807
|
+
}
|
|
6768
6808
|
if (!slotDeclarations.length) {
|
|
6769
6809
|
const { attrs, vTextExp } = collectElementAttributes(node, context, {
|
|
6770
6810
|
skipSlotDirective: true,
|
|
@@ -6780,7 +6820,7 @@ function transformComponentWithSlotsFallback(node, context, transformNode, optio
|
|
|
6780
6820
|
return children ? `<${tag}${attrString}>${children}</${tag}>` : `<${tag}${attrString} />`;
|
|
6781
6821
|
}
|
|
6782
6822
|
if (slotDeclarations.some((decl) => Object.keys(decl.props).length)) context.warnings.push("已禁用作用域插槽参数,插槽绑定将被忽略。");
|
|
6783
|
-
const renderedSlots = slotDeclarations.map((decl) => renderSlotFallback(decl, context, transformNode)).join("");
|
|
6823
|
+
const renderedSlots = slotDirective ? slotDeclarations.map((decl) => renderSlotFallback(decl, context, transformNode)).join("") : renderPlainSlotContentInSourceOrder(renderItems, slotDeclarations, implicitDefaultDeclaration, context, transformNode);
|
|
6784
6824
|
const { attrs } = collectElementAttributes(node, context, {
|
|
6785
6825
|
skipSlotDirective: true,
|
|
6786
6826
|
forInfo: options?.forInfo,
|
|
@@ -6849,6 +6889,9 @@ function transformNormalElement(node, context, transformNode) {
|
|
|
6849
6889
|
//#region src/plugins/vue/compiler/template/elements/tag-structural.ts
|
|
6850
6890
|
const REGEX_SPECIAL_CHARS_RE = /[.*+?^${}()|[\]\\]/g;
|
|
6851
6891
|
function resolveConditionExpression$1(rawExpValue, context, hint) {
|
|
6892
|
+
return (context.rewriteScopedSlot || shouldFallbackToRuntimeBinding(rawExpValue) ? registerRuntimeBindingExpression(rawExpValue, context, { hint }) : null) ?? normalizeWxmlExpressionWithContext(rawExpValue, context);
|
|
6893
|
+
}
|
|
6894
|
+
function resolveListExpression(rawExpValue, context, hint) {
|
|
6852
6895
|
return (shouldFallbackToRuntimeBinding(rawExpValue) ? registerRuntimeBindingExpression(rawExpValue, context, { hint }) : null) ?? normalizeWxmlExpressionWithContext(rawExpValue, context);
|
|
6853
6896
|
}
|
|
6854
6897
|
function transformIfElement(node, context, transformNode) {
|
|
@@ -6892,7 +6935,7 @@ function transformForElement(node, context, transformNode) {
|
|
|
6892
6935
|
}
|
|
6893
6936
|
}
|
|
6894
6937
|
if (context.classStyleRuntime === "js" && !forInfo.index) forInfo.index = `__wv_index_${context.forIndexSeed++}`;
|
|
6895
|
-
const listExp = forInfo.listExp ?
|
|
6938
|
+
const listExp = forInfo.listExp ? resolveListExpression(forInfo.listExp, context, "v-for 列表") : void 0;
|
|
6896
6939
|
const listExpAst = forInfo.listExp ? normalizeJsExpressionWithContext(forInfo.listExp, context, { hint: "v-for 列表" }) : void 0;
|
|
6897
6940
|
const scopedForInfo = listExp ? {
|
|
6898
6941
|
...forInfo,
|
|
@@ -6915,6 +6958,16 @@ function transformForElement(node, context, transformNode) {
|
|
|
6915
6958
|
props: otherProps
|
|
6916
6959
|
};
|
|
6917
6960
|
const extraAttrs = listExp ? context.platform.forAttrs(listExp, renderTemplateMustache, forInfo.item, forInfo.index) : [];
|
|
6961
|
+
if (elementWithoutFor.tag === "slot") {
|
|
6962
|
+
const content = transformSlotElement({
|
|
6963
|
+
...elementWithoutFor,
|
|
6964
|
+
props: elementWithoutFor.props.filter((prop) => {
|
|
6965
|
+
return !(prop.type === NodeTypes.DIRECTIVE && prop.name === "bind" && prop.arg?.type === NodeTypes.SIMPLE_EXPRESSION && prop.arg.content === "key");
|
|
6966
|
+
})
|
|
6967
|
+
}, context, transformNode);
|
|
6968
|
+
const attrString = extraAttrs.length ? ` ${extraAttrs.join(" ")}` : "";
|
|
6969
|
+
return attrString ? `<block${attrString}>${content}</block>` : content;
|
|
6970
|
+
}
|
|
6918
6971
|
const resolvedTag = resolveTemplateTagName(elementWithoutFor.tag, context);
|
|
6919
6972
|
if (shouldTransformAsComponentWithSlots(elementWithoutFor, context, resolvedTag)) return transformComponentWithSlots(elementWithoutFor, context, transformNode, {
|
|
6920
6973
|
extraAttrs,
|
|
@@ -6938,7 +6991,7 @@ function transformForElement(node, context, transformNode) {
|
|
|
6938
6991
|
const TEMPLATE_OPEN_RE = /<template/g;
|
|
6939
6992
|
const TEMPLATE_CLOSE_RE = /<\/template>/g;
|
|
6940
6993
|
function resolveConditionExpression(rawExpValue, context, hint) {
|
|
6941
|
-
return (shouldFallbackToRuntimeBinding(rawExpValue) ? registerRuntimeBindingExpression(rawExpValue, context, { hint }) : null) ?? normalizeWxmlExpressionWithContext(rawExpValue, context);
|
|
6994
|
+
return (context.rewriteScopedSlot || shouldFallbackToRuntimeBinding(rawExpValue) ? registerRuntimeBindingExpression(rawExpValue, context, { hint }) : null) ?? normalizeWxmlExpressionWithContext(rawExpValue, context);
|
|
6942
6995
|
}
|
|
6943
6996
|
function transformTransitionElement(node, context, transformNode) {
|
|
6944
6997
|
context.warnings.push("<transition> 组件:过渡效果需要动画库或运行时支持,仅渲染子节点。");
|
|
@@ -7012,6 +7065,7 @@ function transformElement(node, context, transformNode) {
|
|
|
7012
7065
|
if (tag === "slot") {
|
|
7013
7066
|
const { type } = isStructuralDirective(node);
|
|
7014
7067
|
if (type === "if") return transformIfElement(node, context, transformNode);
|
|
7068
|
+
if (type === "for") return transformForElement(node, context, transformNode);
|
|
7015
7069
|
return transformSlotElement(node, context, transformNode);
|
|
7016
7070
|
}
|
|
7017
7071
|
if (tag === "component") return transformComponentElement(node, context, transformNode);
|
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.13",
|
|
5
5
|
"description": "wevu 编译器基础包,面向小程序模板的编译与转换",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"merge": "^2.1.1",
|
|
51
51
|
"pathe": "^2.0.3",
|
|
52
52
|
"vue": "^3.5.34",
|
|
53
|
-
"@weapp-core/constants": "^0.1.
|
|
53
|
+
"@weapp-core/constants": "^0.1.7",
|
|
54
54
|
"@weapp-core/shared": "3.0.4",
|
|
55
|
-
"@weapp-vite/ast": "6.16.
|
|
55
|
+
"@weapp-vite/ast": "6.16.13",
|
|
56
56
|
"rolldown-require": "2.0.15"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|