@wevu/compiler 6.14.2 → 6.15.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.d.mts +1 -0
- package/dist/index.mjs +144 -58
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -250,6 +250,7 @@ interface ForParseResult {
|
|
|
250
250
|
*/
|
|
251
251
|
interface TemplateCompileOptions {
|
|
252
252
|
platform?: MiniProgramPlatform;
|
|
253
|
+
htmlTagToWxml?: boolean | Record<string, string>;
|
|
253
254
|
scopedSlotsCompiler?: ScopedSlotsCompilerMode;
|
|
254
255
|
scopedSlotsRequireProps?: boolean;
|
|
255
256
|
slotMultipleInstance?: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -412,12 +412,14 @@ function rewriteJsLikeImportsForTempDir(source, fromDir, tempDir) {
|
|
|
412
412
|
//#endregion
|
|
413
413
|
//#region src/plugins/vue/transform/wevuTempDir.ts
|
|
414
414
|
const PROJECT_WEVU_CONFIG_DIR = path.join(".weapp-vite", "wevu-config");
|
|
415
|
+
/**
|
|
416
|
+
* 优先把临时配置缓存放到项目内,避免宏求值时脱离项目根目录导致包名导入解析异常。
|
|
417
|
+
*/
|
|
415
418
|
function getWevuConfigCacheRoot() {
|
|
416
419
|
const env = process.env.WEAPP_VITE_WEVU_CONFIG_DIR?.trim();
|
|
417
420
|
if (env) return path.resolve(env);
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
if (fs.existsSync(projectCacheDir)) return projectCacheDir;
|
|
421
|
+
const projectRoot = process.cwd();
|
|
422
|
+
if (fs.existsSync(projectRoot)) return path.join(projectRoot, PROJECT_WEVU_CONFIG_DIR);
|
|
421
423
|
return path.join(os.tmpdir(), "weapp-vite", "wevu-config");
|
|
422
424
|
}
|
|
423
425
|
function resolveWevuConfigTempDir(fromDir) {
|
|
@@ -2176,18 +2178,19 @@ function createMacroVisitors(program, state) {
|
|
|
2176
2178
|
const setupExposeVisitors = createSetupExposeVisitors(state);
|
|
2177
2179
|
const stripTypesVisitors = createStripTypesVisitors(state);
|
|
2178
2180
|
const pageMetaVisitors = createPageMetaVisitors(state);
|
|
2179
|
-
|
|
2181
|
+
const mergedVisitors = {
|
|
2180
2182
|
...appSetupVisitors,
|
|
2181
2183
|
...setupExposeVisitors,
|
|
2182
2184
|
...stripTypesVisitors,
|
|
2183
|
-
...pageMetaVisitors
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2185
|
+
...pageMetaVisitors
|
|
2186
|
+
};
|
|
2187
|
+
mergedVisitors.CallExpression = (path) => {
|
|
2188
|
+
appSetupVisitors.CallExpression?.(path);
|
|
2189
|
+
setupExposeVisitors.CallExpression?.(path);
|
|
2190
|
+
stripTypesVisitors.CallExpression?.(path);
|
|
2191
|
+
if (!path.removed) pageMetaVisitors.CallExpression?.(path);
|
|
2190
2192
|
};
|
|
2193
|
+
return mergedVisitors;
|
|
2191
2194
|
}
|
|
2192
2195
|
//#endregion
|
|
2193
2196
|
//#region src/plugins/vue/transform/classStyleComputedBuilders.ts
|
|
@@ -2953,6 +2956,16 @@ function transformScript(source, options) {
|
|
|
2953
2956
|
};
|
|
2954
2957
|
}
|
|
2955
2958
|
//#endregion
|
|
2959
|
+
//#region src/inlineDataset.ts
|
|
2960
|
+
const NON_ALNUM_RE = /[^a-z0-9]+/gi;
|
|
2961
|
+
const LEADING_TRAILING_DASH_RE = /^-+|-+$/g;
|
|
2962
|
+
function normalizeEventDatasetSuffix(eventName) {
|
|
2963
|
+
return eventName.trim().replace(NON_ALNUM_RE, "-").replace(LEADING_TRAILING_DASH_RE, "").toLowerCase() || "event";
|
|
2964
|
+
}
|
|
2965
|
+
function createInlineExpressionId(seed) {
|
|
2966
|
+
return `i${seed.toString(36)}`;
|
|
2967
|
+
}
|
|
2968
|
+
//#endregion
|
|
2956
2969
|
//#region src/plugins/vue/compiler/template/expression/wxml.ts
|
|
2957
2970
|
function templateLiteralToConcat(node) {
|
|
2958
2971
|
const segments = [];
|
|
@@ -3132,7 +3145,7 @@ function collectExpressionScopeBindings(exp, context) {
|
|
|
3132
3145
|
}
|
|
3133
3146
|
function registerInlineExpression$1(exp, context) {
|
|
3134
3147
|
const scopeKeys = collectExpressionScopeBindings(exp, context);
|
|
3135
|
-
const id =
|
|
3148
|
+
const id = createInlineExpressionId(context.inlineExpressionSeed++);
|
|
3136
3149
|
context.inlineExpressions.push({
|
|
3137
3150
|
id,
|
|
3138
3151
|
expression: printExpression(exp),
|
|
@@ -3582,25 +3595,20 @@ function lowerEventName(name) {
|
|
|
3582
3595
|
if (!name) return name;
|
|
3583
3596
|
return name.replace(LEADING_UPPER_RE, (s) => s.toLowerCase()).replace(UPPER_CHAR_RE, (s) => s.toLowerCase());
|
|
3584
3597
|
}
|
|
3585
|
-
function
|
|
3598
|
+
function resolveMappedEventName(rawName, context) {
|
|
3586
3599
|
const resolveEvent = (name) => context.platform.mapEventName(lowerEventName(name));
|
|
3587
|
-
if (CAPTURE_BIND_EVENT_RE.test(rawName))
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
if (
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
}
|
|
3599
|
-
if (CATCH_EVENT_RE.test(rawName)) {
|
|
3600
|
-
const eventName = resolveEvent(rawName.slice(5));
|
|
3601
|
-
return context.platform.eventBindingAttr(`catch:${eventName}`);
|
|
3602
|
-
}
|
|
3603
|
-
const eventName = resolveEvent(rawName.slice(2));
|
|
3600
|
+
if (CAPTURE_BIND_EVENT_RE.test(rawName)) return resolveEvent(rawName.slice(11));
|
|
3601
|
+
if (CAPTURE_CATCH_EVENT_RE.test(rawName)) return resolveEvent(rawName.slice(12));
|
|
3602
|
+
if (MUT_BIND_EVENT_RE.test(rawName)) return resolveEvent(rawName.slice(7));
|
|
3603
|
+
if (CATCH_EVENT_RE.test(rawName)) return resolveEvent(rawName.slice(5));
|
|
3604
|
+
return resolveEvent(rawName.slice(2));
|
|
3605
|
+
}
|
|
3606
|
+
function toEventBindingName(rawName, context) {
|
|
3607
|
+
const eventName = resolveMappedEventName(rawName, context);
|
|
3608
|
+
if (CAPTURE_BIND_EVENT_RE.test(rawName)) return context.platform.eventBindingAttr(`capture-bind:${eventName}`);
|
|
3609
|
+
if (CAPTURE_CATCH_EVENT_RE.test(rawName)) return context.platform.eventBindingAttr(`capture-catch:${eventName}`);
|
|
3610
|
+
if (MUT_BIND_EVENT_RE.test(rawName)) return context.platform.eventBindingAttr(`mut-bind:${eventName}`);
|
|
3611
|
+
if (CATCH_EVENT_RE.test(rawName)) return context.platform.eventBindingAttr(`catch:${eventName}`);
|
|
3604
3612
|
return context.platform.eventBindingAttr(`bind:${eventName}`);
|
|
3605
3613
|
}
|
|
3606
3614
|
function readJsxAttributeExpression(value) {
|
|
@@ -3623,13 +3631,14 @@ function extractJsxKeyExpression(node) {
|
|
|
3623
3631
|
}
|
|
3624
3632
|
function compileEventAttribute(name, value, context) {
|
|
3625
3633
|
const bindAttr = toEventBindingName(name, context);
|
|
3634
|
+
const eventSuffix = normalizeEventDatasetSuffix(resolveMappedEventName(name, context));
|
|
3626
3635
|
const exp = readJsxAttributeExpression(value);
|
|
3627
3636
|
if (!exp) return [];
|
|
3628
3637
|
if (t.isStringLiteral(exp) && exp.value) return [`${bindAttr}="${escapeAttr(exp.value)}"`];
|
|
3629
3638
|
if (t.isIdentifier(exp)) return [`${bindAttr}="${escapeAttr(exp.name)}"`];
|
|
3630
3639
|
if (t.isMemberExpression(exp) && !exp.computed && t.isThisExpression(exp.object) && t.isIdentifier(exp.property)) return [`${bindAttr}="${escapeAttr(exp.property.name)}"`];
|
|
3631
3640
|
const inline = registerInlineExpression$1(exp, context);
|
|
3632
|
-
const attrs = [`data-
|
|
3641
|
+
const attrs = [`data-wi-${eventSuffix}="${inline.id}"`, `${bindAttr}="__weapp_vite_inline"`];
|
|
3633
3642
|
inline.scopeKeys.forEach((scopeKey, index) => {
|
|
3634
3643
|
attrs.push(`data-wv-s${index}="${renderMustache$1(scopeKey, context)}"`);
|
|
3635
3644
|
});
|
|
@@ -4589,6 +4598,64 @@ function getClassStyleWxsSource(options = {}) {
|
|
|
4589
4598
|
].join("\n");
|
|
4590
4599
|
}
|
|
4591
4600
|
//#endregion
|
|
4601
|
+
//#region src/plugins/vue/compiler/template/htmlTagMapping.ts
|
|
4602
|
+
const DEFAULT_HTML_TO_WXML_TAG_MAP = {
|
|
4603
|
+
a: "navigator",
|
|
4604
|
+
article: "view",
|
|
4605
|
+
aside: "view",
|
|
4606
|
+
b: "text",
|
|
4607
|
+
blockquote: "view",
|
|
4608
|
+
button: "button",
|
|
4609
|
+
code: "text",
|
|
4610
|
+
dd: "view",
|
|
4611
|
+
div: "view",
|
|
4612
|
+
dl: "view",
|
|
4613
|
+
dt: "view",
|
|
4614
|
+
em: "text",
|
|
4615
|
+
figcaption: "view",
|
|
4616
|
+
figure: "view",
|
|
4617
|
+
footer: "view",
|
|
4618
|
+
form: "form",
|
|
4619
|
+
h1: "view",
|
|
4620
|
+
h2: "view",
|
|
4621
|
+
h3: "view",
|
|
4622
|
+
h4: "view",
|
|
4623
|
+
h5: "view",
|
|
4624
|
+
h6: "view",
|
|
4625
|
+
header: "view",
|
|
4626
|
+
i: "text",
|
|
4627
|
+
img: "image",
|
|
4628
|
+
input: "input",
|
|
4629
|
+
label: "label",
|
|
4630
|
+
li: "view",
|
|
4631
|
+
main: "view",
|
|
4632
|
+
nav: "view",
|
|
4633
|
+
ol: "view",
|
|
4634
|
+
p: "view",
|
|
4635
|
+
pre: "view",
|
|
4636
|
+
section: "view",
|
|
4637
|
+
small: "text",
|
|
4638
|
+
span: "text",
|
|
4639
|
+
strong: "text",
|
|
4640
|
+
textarea: "textarea",
|
|
4641
|
+
u: "text",
|
|
4642
|
+
ul: "view"
|
|
4643
|
+
};
|
|
4644
|
+
function resolveHtmlTagToWxmlMap(value) {
|
|
4645
|
+
if (value === false) return;
|
|
4646
|
+
if (value === true || value === void 0) return { ...DEFAULT_HTML_TO_WXML_TAG_MAP };
|
|
4647
|
+
return {
|
|
4648
|
+
...DEFAULT_HTML_TO_WXML_TAG_MAP,
|
|
4649
|
+
...Object.fromEntries(Object.entries(value).map(([key, mapped]) => [key.toLowerCase(), mapped]))
|
|
4650
|
+
};
|
|
4651
|
+
}
|
|
4652
|
+
function resolveTemplateTagName(tag, context) {
|
|
4653
|
+
if (!tag) return tag;
|
|
4654
|
+
const lowerTag = tag.toLowerCase();
|
|
4655
|
+
if (tag !== lowerTag) return tag;
|
|
4656
|
+
return context.htmlTagToWxmlMap?.[lowerTag] ?? tag;
|
|
4657
|
+
}
|
|
4658
|
+
//#endregion
|
|
4592
4659
|
//#region src/plugins/vue/compiler/template/elements/forExpression.ts
|
|
4593
4660
|
const IDENTIFIER_RE$4 = /^[A-Z_$][\w$]*$/i;
|
|
4594
4661
|
const FOR_ITEM_ALIAS_PLACEHOLDER = "__wv_for_item__";
|
|
@@ -5283,7 +5350,7 @@ function registerInlineExpression(exp, context) {
|
|
|
5283
5350
|
const indexBindings = buildInlineIndexBindings(context);
|
|
5284
5351
|
const scopeResolvers = buildScopeResolvers(usedLocals, context, slotProps, indexBindings);
|
|
5285
5352
|
const asset = {
|
|
5286
|
-
id:
|
|
5353
|
+
id: createInlineExpressionId(context.inlineExpressionSeed++),
|
|
5287
5354
|
expression: updatedExpression,
|
|
5288
5355
|
scopeKeys: usedLocals
|
|
5289
5356
|
};
|
|
@@ -5778,11 +5845,6 @@ const isSimpleHandler = (value) => SIMPLE_IDENTIFIER_RE.test(value);
|
|
|
5778
5845
|
function shouldUseDetailPayload(options) {
|
|
5779
5846
|
return options?.isComponent === true;
|
|
5780
5847
|
}
|
|
5781
|
-
const NON_ALNUM_RE = /[^a-z0-9]+/gi;
|
|
5782
|
-
const LEADING_TRAILING_DASH_RE = /^-+|-+$/g;
|
|
5783
|
-
function normalizeEventDatasetSuffix(eventName) {
|
|
5784
|
-
return eventName.trim().replace(NON_ALNUM_RE, "-").replace(LEADING_TRAILING_DASH_RE, "").toLowerCase() || "event";
|
|
5785
|
-
}
|
|
5786
5848
|
const QUOTE_RE = /"/g;
|
|
5787
5849
|
function buildInlineScopeAttrs(scopeBindings, context) {
|
|
5788
5850
|
return scopeBindings.map((binding, index) => {
|
|
@@ -5819,14 +5881,14 @@ function transformOnDirective(node, context, options) {
|
|
|
5819
5881
|
const eventSuffix = normalizeEventDatasetSuffix(mappedEvent);
|
|
5820
5882
|
const eventPrefix = resolveEventPrefix(node.modifiers);
|
|
5821
5883
|
const bindAttr = context.platform.eventBindingAttr(`${eventPrefix}:${mappedEvent}`);
|
|
5822
|
-
const detailAttr = useDetailPayload ? `data-
|
|
5884
|
+
const detailAttr = useDetailPayload ? `data-wd-${eventSuffix}="1"` : "";
|
|
5823
5885
|
if (context.rewriteScopedSlot) {
|
|
5824
5886
|
if (inlineExpression) {
|
|
5825
5887
|
const scopeAttrs = buildInlineScopeAttrs(inlineExpression.scopeBindings, context);
|
|
5826
5888
|
const indexAttrs = buildInlineIndexAttrs(inlineExpression.indexBindings, context);
|
|
5827
5889
|
return [
|
|
5828
5890
|
detailAttr,
|
|
5829
|
-
`data-
|
|
5891
|
+
`data-wi-${eventSuffix}="${inlineExpression.id}"`,
|
|
5830
5892
|
...scopeAttrs,
|
|
5831
5893
|
...indexAttrs,
|
|
5832
5894
|
`${bindAttr}="__weapp_vite_owner"`
|
|
@@ -5834,7 +5896,7 @@ function transformOnDirective(node, context, options) {
|
|
|
5834
5896
|
}
|
|
5835
5897
|
if (!isInlineExpression && rawExpValue) return [
|
|
5836
5898
|
detailAttr,
|
|
5837
|
-
`data-
|
|
5899
|
+
`data-wh-${eventSuffix}="${rawExpValue}"`,
|
|
5838
5900
|
`${bindAttr}="__weapp_vite_owner"`
|
|
5839
5901
|
].filter(Boolean).join(" ");
|
|
5840
5902
|
if (isInlineExpression) {
|
|
@@ -5848,7 +5910,7 @@ function transformOnDirective(node, context, options) {
|
|
|
5848
5910
|
const indexAttrs = buildInlineIndexAttrs(inlineExpression.indexBindings, context);
|
|
5849
5911
|
return [
|
|
5850
5912
|
detailAttr,
|
|
5851
|
-
`data-
|
|
5913
|
+
`data-wi-${eventSuffix}="${inlineExpression.id}"`,
|
|
5852
5914
|
...scopeAttrs,
|
|
5853
5915
|
...indexAttrs,
|
|
5854
5916
|
`${bindAttr}="__weapp_vite_inline"`
|
|
@@ -5895,7 +5957,8 @@ function isBuiltinTag(tag) {
|
|
|
5895
5957
|
}
|
|
5896
5958
|
function collectElementAttributes(node, context, options) {
|
|
5897
5959
|
const { props } = node;
|
|
5898
|
-
const
|
|
5960
|
+
const resolvedTag = options?.resolvedTag ?? resolveTemplateTagName(node.tag, context);
|
|
5961
|
+
const isComponentElement = options?.isComponent ?? !isBuiltinTag(resolvedTag);
|
|
5899
5962
|
const attrs = options?.extraAttrs ? [...options.extraAttrs] : [];
|
|
5900
5963
|
let staticClass;
|
|
5901
5964
|
let staticId;
|
|
@@ -6399,11 +6462,11 @@ function transformComponentElement(node, context, transformNode) {
|
|
|
6399
6462
|
//#endregion
|
|
6400
6463
|
//#region src/plugins/vue/compiler/template/elements/tag-normal.ts
|
|
6401
6464
|
function transformNormalElement(node, context, transformNode) {
|
|
6402
|
-
const
|
|
6465
|
+
const tag = resolveTemplateTagName(node.tag, context);
|
|
6403
6466
|
const slotDirective = findSlotDirective(node);
|
|
6404
6467
|
const templateSlotChildren = node.children.filter((child) => child.type === NodeTypes.ELEMENT && child.tag === "template" && findSlotDirective(child));
|
|
6405
6468
|
if (slotDirective || templateSlotChildren.length > 0) return transformComponentWithSlots(node, context, transformNode);
|
|
6406
|
-
const { attrs, vTextExp } = collectElementAttributes(node, context);
|
|
6469
|
+
const { attrs, vTextExp } = collectElementAttributes(node, context, { resolvedTag: tag });
|
|
6407
6470
|
let children = "";
|
|
6408
6471
|
if (node.children.length > 0) children = node.children.map((child) => transformNode(child, context)).join("");
|
|
6409
6472
|
if (vTextExp !== void 0) children = renderMustache(vTextExp, context);
|
|
@@ -6488,12 +6551,13 @@ function transformForElement(node, context, transformNode) {
|
|
|
6488
6551
|
});
|
|
6489
6552
|
const { attrs, vTextExp } = collectElementAttributes(elementWithoutFor, context, {
|
|
6490
6553
|
forInfo,
|
|
6491
|
-
extraAttrs
|
|
6554
|
+
extraAttrs,
|
|
6555
|
+
resolvedTag: resolveTemplateTagName(elementWithoutFor.tag, context)
|
|
6492
6556
|
});
|
|
6493
6557
|
let children = "";
|
|
6494
6558
|
if (elementWithoutFor.children.length > 0) children = elementWithoutFor.children.map((child) => transformNode(child, context)).join("");
|
|
6495
6559
|
if (vTextExp !== void 0) children = renderMustache(vTextExp, context);
|
|
6496
|
-
const
|
|
6560
|
+
const tag = resolveTemplateTagName(elementWithoutFor.tag, context);
|
|
6497
6561
|
const attrString = attrs.length ? ` ${attrs.join(" ")}` : "";
|
|
6498
6562
|
return children ? `<${tag}${attrString}>${children}</${tag}>` : `<${tag}${attrString} />`;
|
|
6499
6563
|
}));
|
|
@@ -6642,6 +6706,7 @@ function compileVueTemplateToWxml(template, filename, options) {
|
|
|
6642
6706
|
const resolvedRuntime = runtimeMode === "auto" ? options?.wxsExtension ? "wxs" : "js" : runtimeMode === "wxs" && !options?.wxsExtension ? "js" : runtimeMode;
|
|
6643
6707
|
const wxsExtension = options?.wxsExtension;
|
|
6644
6708
|
const scopedSlotsRequireProps = options?.scopedSlotsRequireProps ?? options?.scopedSlotsCompiler !== "augmented";
|
|
6709
|
+
const htmlTagToWxmlMap = resolveHtmlTagToWxmlMap(options?.htmlTagToWxml);
|
|
6645
6710
|
try {
|
|
6646
6711
|
const ast = parse$1(template, {
|
|
6647
6712
|
isVoidTag: (tag) => HTML_VOID_TAGS.has(tag),
|
|
@@ -6654,6 +6719,7 @@ function compileVueTemplateToWxml(template, filename, options) {
|
|
|
6654
6719
|
filename,
|
|
6655
6720
|
warnings,
|
|
6656
6721
|
platform: options?.platform ?? wechatPlatform,
|
|
6722
|
+
htmlTagToWxmlMap,
|
|
6657
6723
|
scopedSlotsCompiler: options?.scopedSlotsCompiler ?? "auto",
|
|
6658
6724
|
scopedSlotsRequireProps,
|
|
6659
6725
|
slotMultipleInstance: options?.slotMultipleInstance ?? true,
|
|
@@ -7176,6 +7242,9 @@ async function inlineScriptSetupDefineOptionsArgs(content, filename, lang) {
|
|
|
7176
7242
|
const SETUP_CALL_RE = /\bsetup\s*\(/;
|
|
7177
7243
|
const DEFINE_OPTIONS_CALL_RE = /\bdefineOptions\s*\(/;
|
|
7178
7244
|
const APP_VUE_FILE_RE = /[\\/]app\.vue$/;
|
|
7245
|
+
const TEMPLATE_BLOCK_RE = /<template\b[\s\S]*?<\/template>/g;
|
|
7246
|
+
const TEMPLATE_IMPORT_META_RE = /\bimport\.meta\b/g;
|
|
7247
|
+
const TEMPLATE_IMPORT_META_PLACEHOLDER = "__im_meta__";
|
|
7179
7248
|
function resolveSfcScriptLangLabel(lang) {
|
|
7180
7249
|
return typeof lang === "string" && lang.length > 0 ? lang : "(default)";
|
|
7181
7250
|
}
|
|
@@ -7203,14 +7272,37 @@ function extractDefineOptionsHash(content) {
|
|
|
7203
7272
|
if (!macroSources.length) return;
|
|
7204
7273
|
return createHash("sha256").update(macroSources.join("\n")).digest("hex").slice(0, 12);
|
|
7205
7274
|
}
|
|
7275
|
+
function preprocessTemplateImportMeta(source) {
|
|
7276
|
+
return source.replace(TEMPLATE_BLOCK_RE, (block) => block.replace(TEMPLATE_IMPORT_META_RE, TEMPLATE_IMPORT_META_PLACEHOLDER));
|
|
7277
|
+
}
|
|
7278
|
+
function restoreTemplateImportMeta(content) {
|
|
7279
|
+
return content.replace(new RegExp(TEMPLATE_IMPORT_META_PLACEHOLDER, "g"), "import.meta");
|
|
7280
|
+
}
|
|
7281
|
+
function restoreTemplateImportMetaInDescriptor(descriptor) {
|
|
7282
|
+
if (!descriptor.template?.content?.includes(TEMPLATE_IMPORT_META_PLACEHOLDER)) return descriptor;
|
|
7283
|
+
return {
|
|
7284
|
+
...descriptor,
|
|
7285
|
+
template: {
|
|
7286
|
+
...descriptor.template,
|
|
7287
|
+
content: restoreTemplateImportMeta(descriptor.template.content)
|
|
7288
|
+
}
|
|
7289
|
+
};
|
|
7290
|
+
}
|
|
7291
|
+
function parseSfc(source, filename, ignoreEmpty) {
|
|
7292
|
+
const parsed = parse(preprocessTemplateImportMeta(source), {
|
|
7293
|
+
filename,
|
|
7294
|
+
ignoreEmpty
|
|
7295
|
+
});
|
|
7296
|
+
return {
|
|
7297
|
+
...parsed,
|
|
7298
|
+
descriptor: restoreTemplateImportMetaInDescriptor(parsed.descriptor)
|
|
7299
|
+
};
|
|
7300
|
+
}
|
|
7206
7301
|
async function parseVueFile(source, filename, options) {
|
|
7207
7302
|
const normalizedInputSource = normalizeLineEndings(source);
|
|
7208
7303
|
const normalizedSource = preprocessScriptSrc(preprocessScriptSetupSrc(normalizedInputSource));
|
|
7209
7304
|
let descriptorForCompileSource = normalizedSource;
|
|
7210
|
-
const { descriptor, errors } =
|
|
7211
|
-
filename,
|
|
7212
|
-
ignoreEmpty: normalizedSource === normalizedInputSource
|
|
7213
|
-
});
|
|
7305
|
+
const { descriptor, errors } = parseSfc(normalizedSource, filename, normalizedSource === normalizedInputSource);
|
|
7214
7306
|
restoreScriptSetupSrc(descriptor);
|
|
7215
7307
|
restoreScriptSrc(descriptor);
|
|
7216
7308
|
if (errors.length > 0) {
|
|
@@ -7258,10 +7350,7 @@ async function parseVueFile(source, filename, options) {
|
|
|
7258
7350
|
const startOffset = setupLoc.start.offset;
|
|
7259
7351
|
const endOffset = setupLoc.end.offset;
|
|
7260
7352
|
const nextSource = descriptorForCompileSource.slice(0, startOffset) + extracted.stripped + descriptorForCompileSource.slice(endOffset);
|
|
7261
|
-
const { descriptor: nextDescriptor, errors: nextErrors } =
|
|
7262
|
-
filename,
|
|
7263
|
-
ignoreEmpty: false
|
|
7264
|
-
});
|
|
7353
|
+
const { descriptor: nextDescriptor, errors: nextErrors } = parseSfc(nextSource, filename, false);
|
|
7265
7354
|
restoreScriptSetupSrc(nextDescriptor);
|
|
7266
7355
|
restoreScriptSrc(nextDescriptor);
|
|
7267
7356
|
if (nextErrors.length > 0) {
|
|
@@ -7298,10 +7387,7 @@ async function parseVueFile(source, filename, options) {
|
|
|
7298
7387
|
const startOffset = setupLoc.start.offset;
|
|
7299
7388
|
const endOffset = setupLoc.end.offset;
|
|
7300
7389
|
const nextSource = descriptorForCompileSource.slice(0, startOffset) + inlined.code + descriptorForCompileSource.slice(endOffset);
|
|
7301
|
-
const { descriptor: nextDescriptor, errors: nextErrors } =
|
|
7302
|
-
filename,
|
|
7303
|
-
ignoreEmpty: false
|
|
7304
|
-
});
|
|
7390
|
+
const { descriptor: nextDescriptor, errors: nextErrors } = parseSfc(nextSource, filename, false);
|
|
7305
7391
|
restoreScriptSetupSrc(nextDescriptor);
|
|
7306
7392
|
restoreScriptSrc(nextDescriptor);
|
|
7307
7393
|
if (nextErrors.length > 0) {
|
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.15.0",
|
|
5
5
|
"description": "wevu 编译器基础包,面向小程序模板的编译与转换",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -44,14 +44,14 @@
|
|
|
44
44
|
"@vue/compiler-core": "^3.5.32",
|
|
45
45
|
"@vue/compiler-dom": "^3.5.32",
|
|
46
46
|
"comment-json": "^4.6.2",
|
|
47
|
-
"lru-cache": "^11.3.
|
|
47
|
+
"lru-cache": "^11.3.3",
|
|
48
48
|
"magic-string": "^0.30.21",
|
|
49
49
|
"merge": "^2.1.1",
|
|
50
50
|
"pathe": "^2.0.3",
|
|
51
51
|
"vue": "^3.5.32",
|
|
52
52
|
"@weapp-core/shared": "3.0.3",
|
|
53
|
-
"@weapp-vite/ast": "6.
|
|
54
|
-
"rolldown-require": "2.0.
|
|
53
|
+
"@weapp-vite/ast": "6.15.0",
|
|
54
|
+
"rolldown-require": "2.0.13"
|
|
55
55
|
},
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public",
|