weapp-vite 6.0.0-alpha.0 → 6.0.0-alpha.2

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkEL4WI75Zcjs = require('./chunk-EL4WI75Z.cjs');
3
+ var _chunkKBGC6ODZcjs = require('./chunk-KBGC6ODZ.cjs');
4
4
  require('./chunk-IEICAJDZ.cjs');
5
5
  require('./chunk-E34K6TPD.cjs');
6
6
  require('./chunk-SJSLFDTA.cjs');
@@ -25,7 +25,7 @@ function createGetter(resolver) {
25
25
  get: resolver
26
26
  };
27
27
  }
28
- var ctx = _chunkEL4WI75Zcjs.getCompilerContext.call(void 0, );
28
+ var ctx = _chunkKBGC6ODZcjs.getCompilerContext.call(void 0, );
29
29
  var service = ctx.autoRoutesService;
30
30
  var routes = {};
31
31
  Object.defineProperties(routes, {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getCompilerContext
3
- } from "./chunk-4P5KX3LT.mjs";
3
+ } from "./chunk-IHHBS4DF.mjs";
4
4
  import "./chunk-MK4LDVBT.mjs";
5
5
  import "./chunk-YXFADQPY.mjs";
6
6
  import "./chunk-O6633IWP.mjs";
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkEL4WI75Zcjs = require('./chunk-EL4WI75Z.cjs');
5
+ var _chunkKBGC6ODZcjs = require('./chunk-KBGC6ODZ.cjs');
6
6
 
7
7
 
8
8
  var _chunkTZGJRA2Ycjs = require('./chunk-TZGJRA2Y.cjs');
@@ -12,10 +12,10 @@ _chunkTZGJRA2Ycjs.init_cjs_shims.call(void 0, );
12
12
  async function createCompilerContext(options) {
13
13
  const key = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _ => _.key]), () => ( "default"));
14
14
  if (!_optionalChain([options, 'optionalAccess', _2 => _2.key])) {
15
- _chunkEL4WI75Zcjs.resetCompilerContext.call(void 0, key);
15
+ _chunkKBGC6ODZcjs.resetCompilerContext.call(void 0, key);
16
16
  }
17
- _chunkEL4WI75Zcjs.setActiveCompilerContextKey.call(void 0, key);
18
- const ctx = _chunkEL4WI75Zcjs.getCompilerContext.call(void 0, key);
17
+ _chunkKBGC6ODZcjs.setActiveCompilerContextKey.call(void 0, key);
18
+ const ctx = _chunkKBGC6ODZcjs.getCompilerContext.call(void 0, key);
19
19
  const { configService, scanService, autoRoutesService } = ctx;
20
20
  await configService.load(options);
21
21
  if (autoRoutesService) {
@@ -2,7 +2,7 @@ import {
2
2
  getCompilerContext,
3
3
  resetCompilerContext,
4
4
  setActiveCompilerContextKey
5
- } from "./chunk-4P5KX3LT.mjs";
5
+ } from "./chunk-IHHBS4DF.mjs";
6
6
  import {
7
7
  init_esm_shims
8
8
  } from "./chunk-5CBZRYDL.mjs";
@@ -16310,9 +16310,9 @@ pp$5.parseArrowExpression = function(node, params, isAsync, forInit) {
16310
16310
  return this.finishNode(node, "ArrowFunctionExpression");
16311
16311
  };
16312
16312
  pp$5.parseFunctionBody = function(node, isArrowFunction, isMethod, forInit) {
16313
- var isExpression = isArrowFunction && this.type !== types$1.braceL;
16313
+ var isExpression2 = isArrowFunction && this.type !== types$1.braceL;
16314
16314
  var oldStrict = this.strict, useStrict = false;
16315
- if (isExpression) {
16315
+ if (isExpression2) {
16316
16316
  node.body = this.parseMaybeAssign(forInit);
16317
16317
  node.expression = true;
16318
16318
  this.checkParams(node, false);
@@ -24420,7 +24420,7 @@ function getSourceFromVirtualId(id) {
24420
24420
  // src/plugins/vue/transform.ts
24421
24421
  init_esm_shims();
24422
24422
  var import_merge = __toESM(require_src(), 1);
24423
- import generateModule from "@babel/generator";
24423
+ import generateModule2 from "@babel/generator";
24424
24424
  import { parse as babelParse2 } from "@babel/parser";
24425
24425
  import traverseModule from "@babel/traverse";
24426
24426
  import * as t3 from "@babel/types";
@@ -24537,13 +24537,163 @@ function generateHash(str) {
24537
24537
 
24538
24538
  // src/plugins/vue/compiler/template.ts
24539
24539
  init_esm_shims();
24540
- import generate from "@babel/generator";
24540
+ import generateModule from "@babel/generator";
24541
24541
  import { parse as babelParse } from "@babel/parser";
24542
24542
  import * as t2 from "@babel/types";
24543
24543
  import {
24544
24544
  NodeTypes,
24545
24545
  baseParse as parse9
24546
24546
  } from "@vue/compiler-core";
24547
+ var generate = generateModule.default ?? generateModule;
24548
+ function generateExpression(node) {
24549
+ const { code } = generate(node, {
24550
+ compact: true,
24551
+ jsescOption: { quotes: "single" }
24552
+ });
24553
+ return code;
24554
+ }
24555
+ function parseBabelExpression(exp) {
24556
+ try {
24557
+ const ast = babelParse(`(${exp})`, {
24558
+ sourceType: "module",
24559
+ plugins: ["typescript"]
24560
+ });
24561
+ const stmt = ast.program.body[0];
24562
+ if (!stmt || !("expression" in stmt)) {
24563
+ return null;
24564
+ }
24565
+ return stmt.expression;
24566
+ } catch {
24567
+ return null;
24568
+ }
24569
+ }
24570
+ function normalizeClassBindingExpression(exp, context) {
24571
+ const ast = parseBabelExpression(exp);
24572
+ if (!ast) {
24573
+ return [normalizeWxmlExpression(exp)];
24574
+ }
24575
+ const out = [];
24576
+ const pushExpr = (node) => {
24577
+ out.push(normalizeWxmlExpression(generateExpression(node)));
24578
+ };
24579
+ const visit = (node) => {
24580
+ if (!node) {
24581
+ return;
24582
+ }
24583
+ if (t2.isArrayExpression(node)) {
24584
+ for (const el of node.elements) {
24585
+ if (!el) {
24586
+ continue;
24587
+ }
24588
+ if (t2.isSpreadElement(el)) {
24589
+ context.warnings.push("Spread syntax in :class is not supported in mini-programs, ignoring it");
24590
+ continue;
24591
+ }
24592
+ if (t2.isExpression(el)) {
24593
+ visit(el);
24594
+ }
24595
+ }
24596
+ return;
24597
+ }
24598
+ if (t2.isObjectExpression(node)) {
24599
+ for (const prop of node.properties) {
24600
+ if (t2.isSpreadElement(prop)) {
24601
+ context.warnings.push("Spread syntax in :class object is not supported in mini-programs, ignoring it");
24602
+ continue;
24603
+ }
24604
+ if (!t2.isObjectProperty(prop)) {
24605
+ continue;
24606
+ }
24607
+ const value = prop.value;
24608
+ if (!t2.isExpression(value)) {
24609
+ continue;
24610
+ }
24611
+ const test = value;
24612
+ if (prop.computed) {
24613
+ const keyExpr = prop.key;
24614
+ if (!t2.isExpression(keyExpr)) {
24615
+ continue;
24616
+ }
24617
+ pushExpr(t2.conditionalExpression(test, keyExpr, t2.stringLiteral("")));
24618
+ } else if (t2.isIdentifier(prop.key)) {
24619
+ pushExpr(t2.conditionalExpression(test, t2.stringLiteral(prop.key.name), t2.stringLiteral("")));
24620
+ } else if (t2.isStringLiteral(prop.key)) {
24621
+ pushExpr(t2.conditionalExpression(test, t2.stringLiteral(prop.key.value), t2.stringLiteral("")));
24622
+ }
24623
+ }
24624
+ return;
24625
+ }
24626
+ pushExpr(node);
24627
+ };
24628
+ visit(ast);
24629
+ if (!out.length) {
24630
+ return [normalizeWxmlExpression(exp)];
24631
+ }
24632
+ return out;
24633
+ }
24634
+ function renderClassAttribute(staticClass, classExpressions) {
24635
+ const parts = [];
24636
+ if (staticClass?.trim()) {
24637
+ parts.push(staticClass.trim());
24638
+ }
24639
+ for (const exp of classExpressions ?? []) {
24640
+ if (!exp) {
24641
+ continue;
24642
+ }
24643
+ parts.push(`{{${exp}}}`);
24644
+ }
24645
+ return `class="${parts.join(" ")}"`;
24646
+ }
24647
+ function renderStyleAttribute(staticStyle, dynamicStyleExp, vShowExp) {
24648
+ let merged = "";
24649
+ if (staticStyle?.trim()) {
24650
+ merged += staticStyle.trim();
24651
+ }
24652
+ if (merged && !/;\s*$/.test(merged)) {
24653
+ merged += ";";
24654
+ }
24655
+ if (dynamicStyleExp) {
24656
+ const expValue = normalizeWxmlExpression(dynamicStyleExp);
24657
+ merged += `{{${expValue}}}`;
24658
+ }
24659
+ if (vShowExp) {
24660
+ const hiddenStyle = merged ? ";display: none" : "display: none";
24661
+ merged += `{{${vShowExp} ? '' : '${hiddenStyle}'}}`;
24662
+ }
24663
+ return `style="${merged}"`;
24664
+ }
24665
+ function parseInlineHandler(exp) {
24666
+ try {
24667
+ const ast = babelParse(`(${exp})`, {
24668
+ sourceType: "module",
24669
+ plugins: ["typescript"]
24670
+ });
24671
+ const stmt = ast.program.body[0];
24672
+ if (!stmt || !("expression" in stmt)) {
24673
+ return null;
24674
+ }
24675
+ const expression = stmt.expression;
24676
+ if (!t2.isCallExpression(expression) || !t2.isIdentifier(expression.callee)) {
24677
+ return null;
24678
+ }
24679
+ const name = expression.callee.name;
24680
+ const args = [];
24681
+ for (const arg of expression.arguments) {
24682
+ if (t2.isIdentifier(arg) && arg.name === "$event") {
24683
+ args.push("$event");
24684
+ } else if (t2.isStringLiteral(arg) || t2.isNumericLiteral(arg) || t2.isBooleanLiteral(arg)) {
24685
+ args.push(arg.value);
24686
+ } else if (t2.isNullLiteral(arg)) {
24687
+ args.push(null);
24688
+ } else {
24689
+ return null;
24690
+ }
24691
+ }
24692
+ return { name, args };
24693
+ } catch {
24694
+ return null;
24695
+ }
24696
+ }
24547
24697
  function templateLiteralToConcat(node) {
24548
24698
  const segments = [];
24549
24699
  node.quasis.forEach((quasi, index) => {
@@ -24640,23 +24790,63 @@ function transformElement(node, context) {
24640
24790
  function transformNormalElement(node, context) {
24641
24791
  const { tag, props } = node;
24642
24792
  const attrs = [];
24793
+ let staticClass;
24794
+ let dynamicClassExp;
24795
+ let staticStyle;
24796
+ let dynamicStyleExp;
24797
+ let vShowExp;
24798
+ let vTextExp;
24643
24799
  for (const prop of props) {
24644
24800
  if (prop.type === NodeTypes.ATTRIBUTE) {
24801
+ if (prop.name === "class" && prop.value?.type === NodeTypes.TEXT) {
24802
+ staticClass = prop.value.content;
24803
+ continue;
24804
+ }
24805
+ if (prop.name === "style" && prop.value?.type === NodeTypes.TEXT) {
24806
+ staticStyle = prop.value.content;
24807
+ continue;
24808
+ }
24645
24809
  const attr = transformAttribute(prop, context);
24646
24810
  if (attr) {
24647
24811
  attrs.push(attr);
24648
24812
  }
24649
24813
  } else if (prop.type === NodeTypes.DIRECTIVE) {
24814
+ if (prop.name === "bind" && prop.arg?.type === NodeTypes.SIMPLE_EXPRESSION && prop.arg.content === "class" && prop.exp?.type === NodeTypes.SIMPLE_EXPRESSION) {
24815
+ dynamicClassExp = prop.exp.content;
24816
+ continue;
24817
+ }
24818
+ if (prop.name === "bind" && prop.arg?.type === NodeTypes.SIMPLE_EXPRESSION && prop.arg.content === "style" && prop.exp?.type === NodeTypes.SIMPLE_EXPRESSION) {
24819
+ dynamicStyleExp = prop.exp.content;
24820
+ continue;
24821
+ }
24822
+ if (prop.name === "show" && prop.exp?.type === NodeTypes.SIMPLE_EXPRESSION) {
24823
+ vShowExp = normalizeWxmlExpression(prop.exp.content);
24824
+ continue;
24825
+ }
24826
+ if (prop.name === "text" && prop.exp?.type === NodeTypes.SIMPLE_EXPRESSION) {
24827
+ vTextExp = normalizeWxmlExpression(prop.exp.content);
24828
+ continue;
24829
+ }
24650
24830
  const dir = transformDirective(prop, context, node);
24651
24831
  if (dir) {
24652
24832
  attrs.push(dir);
24653
24833
  }
24654
24834
  }
24655
24835
  }
24836
+ if (staticClass || dynamicClassExp) {
24837
+ const expressions = dynamicClassExp ? normalizeClassBindingExpression(dynamicClassExp, context) : void 0;
24838
+ attrs.unshift(renderClassAttribute(staticClass, expressions));
24839
+ }
24840
+ if (staticStyle || dynamicStyleExp || vShowExp) {
24841
+ attrs.unshift(renderStyleAttribute(staticStyle, dynamicStyleExp, vShowExp));
24842
+ }
24656
24843
  let children = "";
24657
24844
  if (node.children.length > 0) {
24658
24845
  children = node.children.map((child) => transformNode(child, context)).join("");
24659
24846
  }
24847
+ if (vTextExp !== void 0) {
24848
+ children = `{{${vTextExp}}}`;
24849
+ }
24660
24850
  const attrString = attrs.length ? ` ${attrs.join(" ")}` : "";
24661
24851
  return children ? `<${tag}${attrString}>${children}</${tag}>` : `<${tag}${attrString} />`;
24662
24852
  }
@@ -24672,6 +24862,7 @@ function transformAttribute(node, _context) {
24672
24862
  }
24673
24863
  function transformDirective(node, context, elementNode, forInfo) {
24674
24864
  const { name, exp, arg } = node;
24865
+ const isSimpleHandler = (value) => /^[A-Z_$][\w$]*$/i.test(value);
24675
24866
  if (name === "bind") {
24676
24867
  if (!arg) {
24677
24868
  return null;
@@ -24709,6 +24900,8 @@ function transformDirective(node, context, elementNode, forInfo) {
24709
24900
  }
24710
24901
  const rawExpValue = exp.type === NodeTypes.SIMPLE_EXPRESSION ? exp.content : "";
24711
24902
  const expValue = normalizeWxmlExpression(rawExpValue);
24903
+ const isInlineExpression = rawExpValue && !isSimpleHandler(rawExpValue);
24904
+ const inlineHandler = isInlineExpression ? parseInlineHandler(rawExpValue) : null;
24712
24905
  const eventMap = {
24713
24906
  click: "tap",
24714
24907
  dblclick: "tap",
@@ -24732,6 +24925,19 @@ function transformDirective(node, context, elementNode, forInfo) {
24732
24925
  longpress: "longpress"
24733
24926
  };
24734
24927
  const wxEvent = eventMap[argValue] || argValue;
24928
+ if (inlineHandler) {
24929
+ const argsJson = JSON.stringify(inlineHandler.args);
24930
+ const escapedArgs = argsJson.replace(/"/g, "&quot;");
24931
+ return [
24932
+ `data-wv-handler="${inlineHandler.name}"`,
24933
+ `data-wv-args="${escapedArgs}"`,
24934
+ `bind${wxEvent}="__weapp_vite_inline"`
24935
+ ].join(" ");
24936
+ }
24937
+ if (isInlineExpression) {
24938
+ const escaped = rawExpValue.replace(/"/g, "&quot;");
24939
+ return `data-wv-inline="${escaped}" bind${wxEvent}="__weapp_vite_inline"`;
24940
+ }
24735
24941
  return `bind${wxEvent}="${expValue}"`;
24736
24942
  }
24737
24943
  if (name === "model") {
@@ -24748,20 +24954,12 @@ function transformDirective(node, context, elementNode, forInfo) {
24748
24954
  }
24749
24955
  const rawExpValue = exp.type === NodeTypes.SIMPLE_EXPRESSION ? exp.content : "";
24750
24956
  const expValue = normalizeWxmlExpression(rawExpValue);
24751
- return `style="{{display: ${expValue} ? '' : 'none'}}"`;
24957
+ return `style="{{${expValue} ? '' : 'display: none'}}"`;
24752
24958
  }
24753
24959
  if (name === "html") {
24754
24960
  context.warnings.push("v-html is not supported in mini-programs, use rich-text component instead");
24755
24961
  return null;
24756
24962
  }
24757
- if (name === "text") {
24758
- if (!exp) {
24759
- return null;
24760
- }
24761
- const rawExpValue = exp.type === NodeTypes.SIMPLE_EXPRESSION ? exp.content : "";
24762
- const expValue = normalizeWxmlExpression(rawExpValue);
24763
- return `>{{${expValue}}`;
24764
- }
24765
24963
  if (name === "cloak") {
24766
24964
  return null;
24767
24965
  }
@@ -24946,35 +25144,92 @@ function transformKeepAliveElement(node, context) {
24946
25144
  }
24947
25145
  function transformTemplateElement(node, context) {
24948
25146
  let slotDirective;
25147
+ let nameAttr = "";
25148
+ let isAttr = "";
25149
+ let dataAttr = "";
25150
+ let hasOtherDirective = false;
25151
+ let structuralDirective;
24949
25152
  for (const prop of node.props) {
24950
25153
  if (prop.type === NodeTypes.DIRECTIVE && prop.name === "slot") {
24951
25154
  slotDirective = prop;
24952
25155
  break;
24953
25156
  }
25157
+ if (prop.type === NodeTypes.DIRECTIVE) {
25158
+ hasOtherDirective = true;
25159
+ if (!structuralDirective && (prop.name === "if" || prop.name === "else-if" || prop.name === "else" || prop.name === "for")) {
25160
+ structuralDirective = prop;
25161
+ }
25162
+ }
25163
+ if (prop.type === NodeTypes.ATTRIBUTE && prop.name === "name") {
25164
+ nameAttr = prop.value && prop.value.type === NodeTypes.TEXT ? prop.value.content : "";
25165
+ }
25166
+ if (prop.type === NodeTypes.ATTRIBUTE && prop.name === "is") {
25167
+ isAttr = prop.value && prop.value.type === NodeTypes.TEXT ? prop.value.content : "";
25168
+ }
25169
+ if (prop.type === NodeTypes.ATTRIBUTE && prop.name === "data") {
25170
+ dataAttr = prop.value && prop.value.type === NodeTypes.TEXT ? prop.value.content : "";
25171
+ }
24954
25172
  }
24955
- if (!slotDirective) {
24956
- context.warnings.push(
24957
- "<template> element without v-slot is not supported in mini-programs, converting to <block>"
24958
- );
24959
- return transformNormalElement(node, context).replace(/<template/g, "<block").replace(/<\/template>/g, "</block>");
24960
- }
24961
- const slotName = slotDirective.arg ? slotDirective.arg.type === NodeTypes.SIMPLE_EXPRESSION ? slotDirective.arg.content : "" : "";
24962
- const slotProps = slotDirective.exp ? slotDirective.exp.type === NodeTypes.SIMPLE_EXPRESSION ? slotDirective.exp.content : "" : "";
24963
25173
  const children = node.children.map((child) => transformNode(child, context)).join("");
25174
+ if (!slotDirective && !nameAttr && !isAttr && !dataAttr) {
25175
+ if (structuralDirective?.name === "for") {
25176
+ return transformForElement({ ...node, tag: "block" }, context);
25177
+ }
25178
+ if (structuralDirective && (structuralDirective.name === "if" || structuralDirective.name === "else-if" || structuralDirective.name === "else")) {
25179
+ const dir = structuralDirective;
25180
+ const base = node.props.filter((prop) => prop !== dir);
25181
+ const fakeNode = { ...node, tag: "block", props: base };
25182
+ if (dir.name === "if" && dir.exp) {
25183
+ const rawExpValue = dir.exp.type === NodeTypes.SIMPLE_EXPRESSION ? dir.exp.content : "";
25184
+ const expValue = normalizeWxmlExpression(rawExpValue);
25185
+ return `<block wx:if="{{${expValue}}}">${children}</block>`;
25186
+ }
25187
+ if (dir.name === "else-if" && dir.exp) {
25188
+ const rawExpValue = dir.exp.type === NodeTypes.SIMPLE_EXPRESSION ? dir.exp.content : "";
25189
+ const expValue = normalizeWxmlExpression(rawExpValue);
25190
+ return `<block wx:elif="{{${expValue}}}">${children}</block>`;
25191
+ }
25192
+ if (dir.name === "else") {
25193
+ return `<block wx:else>${children}</block>`;
25194
+ }
25195
+ return transformIfElement(fakeNode, context);
25196
+ }
25197
+ if (hasOtherDirective) {
25198
+ return transformNormalElement(node, context).replace(/<template/g, "<block").replace(/<\/template>/g, "</block>");
25199
+ }
25200
+ return children;
25201
+ }
24964
25202
  const attrs = [];
24965
- if (slotName) {
24966
- attrs.push(`slot="${slotName}"`);
24967
- } else {
24968
- attrs.push('slot=""');
25203
+ if (nameAttr) {
25204
+ attrs.push(`name="${nameAttr}"`);
24969
25205
  }
24970
- if (slotProps) {
24971
- context.warnings.push(
24972
- `Scoped slots with v-slot="${slotProps}" require runtime support. Generated code may need adjustment.`
24973
- );
24974
- attrs.push(`data="${slotProps}"`);
25206
+ if (isAttr) {
25207
+ attrs.push(`is="${isAttr}"`);
25208
+ }
25209
+ if (dataAttr) {
25210
+ attrs.push(`data="${dataAttr}"`);
25211
+ }
25212
+ if (slotDirective) {
25213
+ const slotName = slotDirective.arg ? slotDirective.arg.type === NodeTypes.SIMPLE_EXPRESSION ? slotDirective.arg.content : "" : "";
25214
+ const slotProps = slotDirective.exp ? slotDirective.exp.type === NodeTypes.SIMPLE_EXPRESSION ? slotDirective.exp.content : "" : "";
25215
+ if (slotName) {
25216
+ attrs.push(`slot="${slotName}"`);
25217
+ } else {
25218
+ attrs.push('slot=""');
25219
+ }
25220
+ if (slotProps) {
25221
+ context.warnings.push(
25222
+ `Scoped slots with v-slot="${slotProps}" require runtime support. Generated code may need adjustment.`
25223
+ );
25224
+ attrs.push(`data="${slotProps}"`);
25225
+ }
25226
+ }
25227
+ if (!slotDirective && !nameAttr && !isAttr && !dataAttr) {
25228
+ return children;
24975
25229
  }
24976
25230
  const attrString = attrs.length ? ` ${attrs.join(" ")}` : "";
24977
- return `<template${attrString}>${children}</template>`;
25231
+ const tagName = slotDirective ? "block" : "template";
25232
+ return `<${tagName}${attrString}>${children}</${tagName}>`;
24978
25233
  }
24979
25234
  function parseForExpression(exp) {
24980
25235
  const match2 = exp.match(/^\(([^,]+),\s*([^,]+),\s*([^)]+)\)\s+in\s+(.+)$/);
@@ -25115,7 +25370,7 @@ function compileVueTemplateToWxml(template, filename) {
25115
25370
 
25116
25371
  // src/plugins/vue/transform.ts
25117
25372
  var RUNTIME_IMPORT_PATH = "wevu";
25118
- var generate2 = generateModule.default ?? generateModule;
25373
+ var generate2 = generateModule2.default ?? generateModule2;
25119
25374
  var traverse2 = traverseModule.default ?? traverseModule;
25120
25375
  function isDefineComponentCall(node, aliases) {
25121
25376
  return t3.isIdentifier(node.callee) && aliases.has(node.callee.name);
@@ -25556,6 +25811,10 @@ async function compileVueFile(source, filename) {
25556
25811
  throw new Error(`Failed to parse ${filename}: ${error.message}`);
25557
25812
  }
25558
25813
  const result = {};
25814
+ result.meta = {
25815
+ hasScriptSetup: !!descriptor.scriptSetup,
25816
+ hasSetupOption: !!descriptor.script && /\bsetup\s*\(/.test(descriptor.script.content)
25817
+ };
25559
25818
  const isAppFile = /[\\/]app\.vue$/.test(filename);
25560
25819
  if (descriptor.script || descriptor.scriptSetup) {
25561
25820
  const scriptCompiled = compileScript(descriptor, {
@@ -25649,7 +25908,7 @@ function createVueTransformPlugin(ctx) {
25649
25908
  };
25650
25909
  } catch (error) {
25651
25910
  const message = error instanceof Error ? error.message : String(error);
25652
- console.error(`[Vue transform] Error transforming ${filename}: ${message}`);
25911
+ logger_default.error(`[Vue transform] Error transforming ${filename}: ${message}`);
25653
25912
  throw error;
25654
25913
  }
25655
25914
  },
@@ -25665,6 +25924,8 @@ function createVueTransformPlugin(ctx) {
25665
25924
  if (!relativeBase) {
25666
25925
  continue;
25667
25926
  }
25927
+ const isAppVue = /[\\/]app\.vue$/.test(filename);
25928
+ const shouldEmitComponentJson = !isAppVue;
25668
25929
  if (result.template) {
25669
25930
  const wxmlFileName = `${relativeBase}.wxml`;
25670
25931
  if (!bundle[wxmlFileName]) {
@@ -25685,14 +25946,32 @@ function createVueTransformPlugin(ctx) {
25685
25946
  });
25686
25947
  }
25687
25948
  }
25688
- if (result.config) {
25949
+ if (result.config || shouldEmitComponentJson) {
25689
25950
  const jsonFileName = `${relativeBase}.json`;
25690
25951
  const existing = bundle[jsonFileName];
25952
+ const defaultConfig = shouldEmitComponentJson ? { component: true } : void 0;
25953
+ let nextConfig;
25954
+ if (result.config) {
25955
+ try {
25956
+ nextConfig = JSON.parse(result.config);
25957
+ } catch {
25958
+ nextConfig = void 0;
25959
+ }
25960
+ }
25961
+ if (defaultConfig) {
25962
+ nextConfig = { ...defaultConfig, ...nextConfig ?? {} };
25963
+ nextConfig.component = true;
25964
+ }
25965
+ if (!nextConfig && defaultConfig) {
25966
+ nextConfig = defaultConfig;
25967
+ }
25968
+ if (!nextConfig) {
25969
+ continue;
25970
+ }
25691
25971
  if (existing && existing.type === "asset") {
25692
25972
  try {
25693
25973
  const existingConfig = JSON.parse(existing.source.toString());
25694
- const newConfig = JSON.parse(result.config);
25695
- const merged = { ...existingConfig, ...newConfig };
25974
+ const merged = { ...existingConfig, ...nextConfig };
25696
25975
  this.emitFile({
25697
25976
  type: "asset",
25698
25977
  fileName: jsonFileName,
@@ -25702,14 +25981,14 @@ function createVueTransformPlugin(ctx) {
25702
25981
  this.emitFile({
25703
25982
  type: "asset",
25704
25983
  fileName: jsonFileName,
25705
- source: result.config
25984
+ source: JSON.stringify(nextConfig, null, 2)
25706
25985
  });
25707
25986
  }
25708
25987
  } else if (!bundle[jsonFileName]) {
25709
25988
  this.emitFile({
25710
25989
  type: "asset",
25711
25990
  fileName: jsonFileName,
25712
- source: result.config
25991
+ source: JSON.stringify(nextConfig, null, 2)
25713
25992
  });
25714
25993
  }
25715
25994
  }
@@ -25770,16 +26049,26 @@ function createVueTransformPlugin(ctx) {
25770
26049
  source: result.style
25771
26050
  });
25772
26051
  }
25773
- if (result.config && !bundle[`${relativeBase}.json`]) {
26052
+ if (!bundle[`${relativeBase}.json`]) {
26053
+ let nextConfig;
26054
+ if (result.config) {
26055
+ try {
26056
+ nextConfig = JSON.parse(result.config);
26057
+ } catch {
26058
+ nextConfig = void 0;
26059
+ }
26060
+ }
26061
+ nextConfig = { component: true, ...nextConfig ?? {} };
26062
+ nextConfig.component = true;
25774
26063
  this.emitFile({
25775
26064
  type: "asset",
25776
26065
  fileName: `${relativeBase}.json`,
25777
- source: result.config
26066
+ source: JSON.stringify(nextConfig, null, 2)
25778
26067
  });
25779
26068
  }
25780
26069
  } catch (error) {
25781
26070
  const message = error instanceof Error ? error.message : String(error);
25782
- console.error(`[Vue transform] Error compiling ${vuePath}: ${message}`);
26071
+ logger_default.error(`[Vue transform] Error compiling ${vuePath}: ${message}`);
25783
26072
  }
25784
26073
  }
25785
26074
  },