@wevu/compiler 6.16.18 → 6.16.19

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 CHANGED
@@ -449,6 +449,10 @@ interface CompileVueFileOptions {
449
449
  astEngine?: AstEngineName$1;
450
450
  isPage?: boolean;
451
451
  isApp?: boolean;
452
+ /**
453
+ * 是否压缩生成的 wevu 脚本输出。
454
+ */
455
+ minify?: boolean;
452
456
  warn?: (message: string) => void;
453
457
  autoUsingComponents?: AutoUsingComponentsOptions;
454
458
  autoImportTags?: AutoImportTagsOptions;
@@ -669,6 +673,10 @@ interface TransformScriptOptions {
669
673
  * wevu 默认值(仅用于 app.vue 注入)
670
674
  */
671
675
  wevuDefaults?: WevuDefaults;
676
+ /**
677
+ * 是否压缩生成的脚本代码。
678
+ */
679
+ minify?: boolean;
672
680
  /**
673
681
  * 编译期警告回调
674
682
  */
@@ -804,6 +812,7 @@ declare function injectWevuPageFeatureFlagsIntoOptionsObject(optionsObject: t.Ob
804
812
  */
805
813
  declare function injectWevuPageFeaturesInJs(source: string, options?: {
806
814
  astEngine?: AstEngineName$1;
815
+ minify?: boolean;
807
816
  }): {
808
817
  code: string;
809
818
  transformed: boolean;
@@ -816,6 +825,7 @@ declare function injectWevuPageFeaturesInJsWithResolver(source: string, options:
816
825
  id: string;
817
826
  resolver: ModuleResolver;
818
827
  astEngine?: AstEngineName$1;
828
+ minify?: boolean;
819
829
  }): Promise<{
820
830
  code: string;
821
831
  transformed: boolean;
package/dist/index.mjs CHANGED
@@ -1615,7 +1615,9 @@ function injectWevuPageFeaturesInJs(source, options) {
1615
1615
  transformed: false
1616
1616
  };
1617
1617
  const generated = generate(ast, {
1618
- retainLines: true,
1618
+ compact: options?.minify === true,
1619
+ minified: options?.minify === true,
1620
+ retainLines: options?.minify !== true,
1619
1621
  sourceMaps: true,
1620
1622
  sourceFileName: "inline.js"
1621
1623
  }, source);
@@ -1661,7 +1663,9 @@ async function injectWevuPageFeaturesInJsWithResolver(source, options) {
1661
1663
  transformed: false
1662
1664
  };
1663
1665
  const generated = generate(ast, {
1664
- retainLines: true,
1666
+ compact: options?.minify === true,
1667
+ minified: options?.minify === true,
1668
+ retainLines: options?.minify !== true,
1665
1669
  sourceMaps: true,
1666
1670
  sourceFileName: "inline.js"
1667
1671
  }, source);
@@ -2998,7 +3002,9 @@ function transformScript(source, options) {
2998
3002
  transformed: false
2999
3003
  };
3000
3004
  const generated = generate(ast, {
3001
- retainLines: true,
3005
+ compact: options?.minify === true,
3006
+ minified: options?.minify === true,
3007
+ retainLines: options?.minify !== true,
3002
3008
  sourceMaps: true,
3003
3009
  sourceFileName: "inline.ts"
3004
3010
  }, source);
@@ -3295,26 +3301,49 @@ function stripRenderOptionFromScript(source, filename, warn) {
3295
3301
  }
3296
3302
  //#endregion
3297
3303
  //#region src/plugins/vue/compiler/template/format.ts
3298
- const TOKEN_RE = /<[^>]+>/g;
3299
3304
  function tokenizeWxml(source) {
3300
3305
  const tokens = [];
3301
3306
  let index = 0;
3302
- for (const match of source.matchAll(TOKEN_RE)) {
3303
- const start = match.index ?? 0;
3307
+ while (index < source.length) {
3308
+ const start = source.indexOf("<", index);
3309
+ if (start < 0) {
3310
+ tokens.push({
3311
+ type: "text",
3312
+ value: source.slice(index)
3313
+ });
3314
+ break;
3315
+ }
3304
3316
  if (start > index) tokens.push({
3305
3317
  type: "text",
3306
3318
  value: source.slice(index, start)
3307
3319
  });
3320
+ let quote;
3321
+ let end = start + 1;
3322
+ for (; end < source.length; end++) {
3323
+ const char = source[end];
3324
+ if (quote) {
3325
+ if (char === quote) quote = void 0;
3326
+ continue;
3327
+ }
3328
+ if (char === "\"" || char === "'") {
3329
+ quote = char;
3330
+ continue;
3331
+ }
3332
+ if (char === ">") break;
3333
+ }
3334
+ if (end >= source.length) {
3335
+ tokens.push({
3336
+ type: "text",
3337
+ value: source.slice(start)
3338
+ });
3339
+ break;
3340
+ }
3308
3341
  tokens.push({
3309
3342
  type: "tag",
3310
- value: match[0]
3343
+ value: source.slice(start, end + 1)
3311
3344
  });
3312
- index = start + match[0].length;
3345
+ index = end + 1;
3313
3346
  }
3314
- if (index < source.length) tokens.push({
3315
- type: "text",
3316
- value: source.slice(index)
3317
- });
3318
3347
  return tokens.filter((token) => token.value.length > 0);
3319
3348
  }
3320
3349
  function isClosingTag(value) {
@@ -4110,6 +4139,7 @@ async function compileJsxFile(source, filename, options) {
4110
4139
  skipComponentTransform: options?.isApp,
4111
4140
  isApp: options?.isApp,
4112
4141
  isPage: options?.isPage,
4142
+ minify: options?.minify,
4113
4143
  warn: options?.warn,
4114
4144
  wevuDefaults: options?.wevuDefaults,
4115
4145
  inlineExpressions
@@ -8219,6 +8249,7 @@ async function compileScriptPhase(descriptor, descriptorForCompile, filename, op
8219
8249
  skipComponentTransform: isAppFile,
8220
8250
  isApp: isAppFile,
8221
8251
  isPage: options?.isPage === true,
8252
+ minify: options?.minify,
8222
8253
  warn: options?.warn,
8223
8254
  templateComponentMeta: Object.keys(autoComponentMeta).length ? autoComponentMeta : void 0,
8224
8255
  wevuDefaults: options?.wevuDefaults,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wevu/compiler",
3
3
  "type": "module",
4
- "version": "6.16.18",
4
+ "version": "6.16.19",
5
5
  "description": "wevu 编译器基础包,面向小程序模板的编译与转换",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -45,15 +45,15 @@
45
45
  "@vue/compiler-core": "^3.5.34",
46
46
  "@vue/compiler-dom": "^3.5.34",
47
47
  "comment-json": "^5.0.0",
48
- "lru-cache": "^11.4.0",
48
+ "lru-cache": "^11.5.0",
49
49
  "magic-string": "^0.30.21",
50
50
  "merge": "^2.1.1",
51
51
  "pathe": "^2.0.3",
52
52
  "vue": "^3.5.34",
53
53
  "@weapp-core/constants": "0.1.8",
54
54
  "@weapp-core/shared": "3.0.4",
55
- "@weapp-vite/ast": "6.16.18",
56
- "rolldown-require": "2.0.16"
55
+ "@weapp-vite/ast": "6.16.19",
56
+ "rolldown-require": "2.0.17"
57
57
  },
58
58
  "publishConfig": {
59
59
  "access": "public",