weapp-vite 1.8.2 → 1.8.3

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,7 @@
1
1
  import { PackageJson } from 'pkg-types';
2
2
  import { RollupOutput, RollupWatcher } from 'rollup';
3
- import { P as ProjectConfig, E as Entry, A as AppEntry, S as SubPackageMetaValue, R as ResolvedAlias, M as MpPlatform, C as CompilerContextOptions, a as SubPackage } from './config-D4m0SOty.js';
3
+ import { R as ResolvedValue } from './types-Cvkpy1-u.js';
4
+ import { P as ProjectConfig, E as Entry, A as AppEntry, S as SubPackageMetaValue, R as ResolvedAlias, M as MpPlatform, C as CompilerContextOptions, a as SubPackage } from './config-D1TnAC7f.js';
4
5
  import { InlineConfig } from 'vite';
5
6
  import { Options } from 'tsup';
6
7
 
@@ -31,7 +32,10 @@ declare class CompilerContext {
31
32
  private rollupWatcherMap;
32
33
  entriesSet: Set<string>;
33
34
  entries: Entry[];
34
- potentialComponentMap: Map<string, Entry>;
35
+ potentialComponentMap: Map<string, {
36
+ entry: Entry;
37
+ value: ResolvedValue;
38
+ }>;
35
39
  appEntry?: AppEntry;
36
40
  subPackageMeta: Record<string, SubPackageMetaValue>;
37
41
  aliasEntries: ResolvedAlias[];
@@ -1,6 +1,7 @@
1
1
  import { PackageJson } from 'pkg-types';
2
2
  import { RollupOutput, RollupWatcher } from 'rollup';
3
- import { P as ProjectConfig, E as Entry, A as AppEntry, S as SubPackageMetaValue, R as ResolvedAlias, M as MpPlatform, C as CompilerContextOptions, a as SubPackage } from './config-D4m0SOty.cjs';
3
+ import { R as ResolvedValue } from './types-Cvkpy1-u.cjs';
4
+ import { P as ProjectConfig, E as Entry, A as AppEntry, S as SubPackageMetaValue, R as ResolvedAlias, M as MpPlatform, C as CompilerContextOptions, a as SubPackage } from './config-nZhQe_5k.cjs';
4
5
  import { InlineConfig } from 'vite';
5
6
  import { Options } from 'tsup';
6
7
 
@@ -31,7 +32,10 @@ declare class CompilerContext {
31
32
  private rollupWatcherMap;
32
33
  entriesSet: Set<string>;
33
34
  entries: Entry[];
34
- potentialComponentMap: Map<string, Entry>;
35
+ potentialComponentMap: Map<string, {
36
+ entry: Entry;
37
+ value: ResolvedValue;
38
+ }>;
35
39
  appEntry?: AppEntry;
36
40
  subPackageMeta: Record<string, SubPackageMetaValue>;
37
41
  aliasEntries: ResolvedAlias[];
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/auto-import-components/resolvers/index.ts
21
+ var resolvers_exports = {};
22
+ __export(resolvers_exports, {
23
+ TDesignResolver: () => TDesignResolver
24
+ });
25
+ module.exports = __toCommonJS(resolvers_exports);
26
+
27
+ // src/auto-import-components/resolvers/tdesign.ts
28
+ var TDesignResolver = () => {
29
+ const prefix = "t-";
30
+ const components = [
31
+ // 基础
32
+ "button",
33
+ "divider",
34
+ "fab",
35
+ "icon",
36
+ "row",
37
+ "col",
38
+ "link",
39
+ // 导航
40
+ "back-top",
41
+ "drawer",
42
+ "indexes",
43
+ "indexes-anchor",
44
+ "navbar",
45
+ "side-bar",
46
+ "side-bar-item",
47
+ "steps",
48
+ "step-item",
49
+ "tab-bar",
50
+ "tab-bar-item",
51
+ "tabs",
52
+ "tab-panel",
53
+ // 输入
54
+ "calendar",
55
+ "cascader",
56
+ "checkbox",
57
+ "checkbox-group",
58
+ "color-picker",
59
+ "date-time-picker",
60
+ "input",
61
+ "picker",
62
+ "picker-item",
63
+ "radio",
64
+ "radio-group",
65
+ "rate",
66
+ "search",
67
+ "slider",
68
+ "stepper",
69
+ "switch",
70
+ "textarea",
71
+ "tree-select",
72
+ "upload",
73
+ // 数据展示
74
+ "avatar",
75
+ "avatar-group",
76
+ "badge",
77
+ "cell",
78
+ "cell-group",
79
+ "collapse",
80
+ "collapse-panel",
81
+ "count-down",
82
+ "empty",
83
+ "footer",
84
+ "grid",
85
+ "grid-item",
86
+ "image",
87
+ "image-viewer",
88
+ "progress",
89
+ "result",
90
+ "skeleton",
91
+ "sticky",
92
+ "swiper",
93
+ "swiper-nav",
94
+ "tag",
95
+ "check-tag",
96
+ // 反馈
97
+ "action-sheet",
98
+ "dialog",
99
+ "dropdown-menu",
100
+ "dropdown-item",
101
+ "guide",
102
+ "loading",
103
+ "message",
104
+ "notice-bar",
105
+ "overlay",
106
+ "popup",
107
+ "pull-down-refresh",
108
+ "swipe-cell"
109
+ ];
110
+ const map = components.reduce((acc, cur) => {
111
+ acc[`${prefix}${cur}`] = `tdesign-miniprogram/${cur}/${cur}`;
112
+ return acc;
113
+ }, {});
114
+ return (componentName) => {
115
+ const from = map[componentName];
116
+ if (from) {
117
+ return {
118
+ name: componentName,
119
+ from
120
+ };
121
+ }
122
+ };
123
+ };
124
+ // Annotate the CommonJS export names for ESM import in node:
125
+ 0 && (module.exports = {
126
+ TDesignResolver
127
+ });
@@ -0,0 +1,6 @@
1
+ import { C as CreateResolver } from '../types-Cvkpy1-u.cjs';
2
+ export { R as ResolvedValue, a as Resolver } from '../types-Cvkpy1-u.cjs';
3
+
4
+ declare const TDesignResolver: CreateResolver;
5
+
6
+ export { CreateResolver, TDesignResolver };
@@ -0,0 +1,6 @@
1
+ import { C as CreateResolver } from '../types-Cvkpy1-u.js';
2
+ export { R as ResolvedValue, a as Resolver } from '../types-Cvkpy1-u.js';
3
+
4
+ declare const TDesignResolver: CreateResolver;
5
+
6
+ export { CreateResolver, TDesignResolver };
@@ -0,0 +1,111 @@
1
+ import {
2
+ init_esm_shims
3
+ } from "../chunk-D64WYHZN.mjs";
4
+
5
+ // src/auto-import-components/resolvers/index.ts
6
+ init_esm_shims();
7
+
8
+ // src/auto-import-components/resolvers/tdesign.ts
9
+ init_esm_shims();
10
+ var TDesignResolver = () => {
11
+ const prefix = "t-";
12
+ const components = [
13
+ // 基础
14
+ "button",
15
+ "divider",
16
+ "fab",
17
+ "icon",
18
+ "row",
19
+ "col",
20
+ "link",
21
+ // 导航
22
+ "back-top",
23
+ "drawer",
24
+ "indexes",
25
+ "indexes-anchor",
26
+ "navbar",
27
+ "side-bar",
28
+ "side-bar-item",
29
+ "steps",
30
+ "step-item",
31
+ "tab-bar",
32
+ "tab-bar-item",
33
+ "tabs",
34
+ "tab-panel",
35
+ // 输入
36
+ "calendar",
37
+ "cascader",
38
+ "checkbox",
39
+ "checkbox-group",
40
+ "color-picker",
41
+ "date-time-picker",
42
+ "input",
43
+ "picker",
44
+ "picker-item",
45
+ "radio",
46
+ "radio-group",
47
+ "rate",
48
+ "search",
49
+ "slider",
50
+ "stepper",
51
+ "switch",
52
+ "textarea",
53
+ "tree-select",
54
+ "upload",
55
+ // 数据展示
56
+ "avatar",
57
+ "avatar-group",
58
+ "badge",
59
+ "cell",
60
+ "cell-group",
61
+ "collapse",
62
+ "collapse-panel",
63
+ "count-down",
64
+ "empty",
65
+ "footer",
66
+ "grid",
67
+ "grid-item",
68
+ "image",
69
+ "image-viewer",
70
+ "progress",
71
+ "result",
72
+ "skeleton",
73
+ "sticky",
74
+ "swiper",
75
+ "swiper-nav",
76
+ "tag",
77
+ "check-tag",
78
+ // 反馈
79
+ "action-sheet",
80
+ "dialog",
81
+ "dropdown-menu",
82
+ "dropdown-item",
83
+ "guide",
84
+ "loading",
85
+ "message",
86
+ "notice-bar",
87
+ "overlay",
88
+ "popup",
89
+ "pull-down-refresh",
90
+ "swipe-cell"
91
+ ];
92
+ const map = components.reduce((acc, cur) => {
93
+ acc[`${prefix}${cur}`] = `tdesign-miniprogram/${cur}/${cur}`;
94
+ return acc;
95
+ }, {});
96
+ return (componentName) => {
97
+ const from = map[componentName];
98
+ if (from) {
99
+ return {
100
+ name: componentName,
101
+ from
102
+ };
103
+ }
104
+ };
105
+ };
106
+
107
+ // src/auto-import-components/resolvers/types.ts
108
+ init_esm_shims();
109
+ export {
110
+ TDesignResolver
111
+ };
@@ -27,9 +27,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  mod
28
28
  ));
29
29
 
30
- // ../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.9.3_jiti@2.4.0_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/esm_shims.js
30
+ // ../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.10.0_jiti@2.4.0_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/esm_shims.js
31
31
  var init_esm_shims = __esm({
32
- "../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.9.3_jiti@2.4.0_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/esm_shims.js"() {
32
+ "../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.10.0_jiti@2.4.0_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/esm_shims.js"() {
33
33
  "use strict";
34
34
  }
35
35
  });
@@ -2,7 +2,7 @@ import {
2
2
  __commonJS,
3
3
  __toESM,
4
4
  init_esm_shims
5
- } from "./chunk-ZZXLQPEB.mjs";
5
+ } from "./chunk-D64WYHZN.mjs";
6
6
 
7
7
  // ../../node_modules/.pnpm/debounce@2.2.0/node_modules/debounce/index.js
8
8
  var require_debounce = __commonJS({
@@ -90,7 +90,7 @@ var require_debounce = __commonJS({
90
90
  init_esm_shims();
91
91
 
92
92
  // package.json
93
- var version = "1.8.2";
93
+ var version = "1.8.3";
94
94
 
95
95
  // src/constants.ts
96
96
  var VERSION = version;
@@ -660,7 +660,7 @@ function processWxml(wxml, options) {
660
660
  currentTagName = "";
661
661
  attrs = {};
662
662
  importAttrs = void 0;
663
- tagStartIndex = -1;
663
+ tagStartIndex = 0;
664
664
  },
665
665
  ontext(data) {
666
666
  if (currentTagName === "wxs" && jsExtensions.includes(attrs.lang)) {
@@ -673,7 +673,8 @@ ${res.code}`);
673
673
  }
674
674
  },
675
675
  {
676
- lowerCaseTags: false
676
+ lowerCaseTags: false,
677
+ xmlMode: true
677
678
  }
678
679
  );
679
680
  parser.write(
@@ -940,7 +941,9 @@ function vitePluginWeapp(ctx, subPackageMeta) {
940
941
  if (appEntry.sitemapJsonPath) {
941
942
  this.addWatchFile(appEntry.sitemapJsonPath);
942
943
  if (appEntry.sitemapJson) {
943
- const fileName = jsonFileRemoveJsExtension(ctx.relativeSrcRoot(ctx.relativeCwd(appEntry.sitemapJsonPath)));
944
+ const fileName = jsonFileRemoveJsExtension(
945
+ ctx.relativeSrcRoot(ctx.relativeCwd(appEntry.sitemapJsonPath))
946
+ );
944
947
  this.emitFile({
945
948
  type: "asset",
946
949
  fileName,
@@ -954,7 +957,9 @@ function vitePluginWeapp(ctx, subPackageMeta) {
954
957
  if (appEntry.themeJsonPath) {
955
958
  this.addWatchFile(appEntry.themeJsonPath);
956
959
  if (appEntry.themeJson) {
957
- const fileName = jsonFileRemoveJsExtension(ctx.relativeSrcRoot(ctx.relativeCwd(appEntry.themeJsonPath)));
960
+ const fileName = jsonFileRemoveJsExtension(
961
+ ctx.relativeSrcRoot(ctx.relativeCwd(appEntry.themeJsonPath))
962
+ );
958
963
  this.emitFile({
959
964
  type: "asset",
960
965
  fileName,
@@ -1269,8 +1274,8 @@ async function loadDefaultConfig() {
1269
1274
  this.inlineConfig.plugins?.push(tsconfigPaths(this.inlineConfig.weapp?.tsconfigPaths));
1270
1275
  this.aliasEntries = getAliasEntries(this.inlineConfig.weapp?.jsonAlias);
1271
1276
  if (this.inlineConfig.weapp?.enhance) {
1272
- if (Array.isArray(this.inlineConfig.weapp.enhance.autoImportComponents?.dirs)) {
1273
- this.autoImportFilter = pm(this.inlineConfig.weapp.enhance.autoImportComponents.dirs, {
1277
+ if (Array.isArray(this.inlineConfig.weapp.enhance.autoImportComponents?.globs)) {
1278
+ this.autoImportFilter = pm(this.inlineConfig.weapp.enhance.autoImportComponents.globs, {
1274
1279
  cwd: this.cwd,
1275
1280
  windows: true,
1276
1281
  posixSlashes: true
@@ -1625,7 +1630,13 @@ var CompilerContext = class {
1625
1630
  logger_default.warn(`\u53D1\u73B0\u7EC4\u4EF6\u91CD\u540D! \u8DF3\u8FC7\u7EC4\u4EF6 ${this.relativeCwd(baseName)} \u7684\u81EA\u52A8\u5F15\u5165`);
1626
1631
  return;
1627
1632
  }
1628
- this.potentialComponentMap.set(componentName, partialEntry);
1633
+ this.potentialComponentMap.set(componentName, {
1634
+ entry: partialEntry,
1635
+ value: {
1636
+ name: componentName,
1637
+ from: `/${this.relativeSrcRoot(this.relativeCwd(removeExtension3(partialEntry.jsonPath)))}`
1638
+ }
1639
+ });
1629
1640
  }
1630
1641
  }
1631
1642
  }
@@ -1770,12 +1781,24 @@ var CompilerContext = class {
1770
1781
  const depComponentNames = Object.keys(hit);
1771
1782
  debug2?.(this.potentialComponentMap, jsonFragment.json.usingComponents);
1772
1783
  for (const depComponentName of depComponentNames) {
1773
- const componentEntry2 = this.potentialComponentMap.get(depComponentName);
1774
- if (componentEntry2 && componentEntry2.jsonPath) {
1775
- if (isObject5(jsonFragment.json.usingComponents) && Reflect.has(jsonFragment.json.usingComponents, depComponentName)) {
1776
- continue;
1784
+ const res = this.potentialComponentMap.get(depComponentName);
1785
+ if (res) {
1786
+ const { entry: componentEntry2, value } = res;
1787
+ if (componentEntry2 && componentEntry2.jsonPath) {
1788
+ if (isObject5(jsonFragment.json.usingComponents) && Reflect.has(jsonFragment.json.usingComponents, value.name)) {
1789
+ continue;
1790
+ }
1791
+ set2(jsonFragment.json, `usingComponents.${value.name}`, value.from);
1792
+ }
1793
+ } else if (Array.isArray(this.inlineConfig.weapp?.enhance?.autoImportComponents?.resolvers)) {
1794
+ for (const resolver of this.inlineConfig.weapp.enhance.autoImportComponents.resolvers) {
1795
+ const value = resolver(depComponentName);
1796
+ if (value) {
1797
+ if (!(isObject5(jsonFragment.json.usingComponents) && Reflect.has(jsonFragment.json.usingComponents, value.name))) {
1798
+ set2(jsonFragment.json, `usingComponents.${value.name}`, value.from);
1799
+ }
1800
+ }
1777
1801
  }
1778
- set2(jsonFragment.json, `usingComponents.${depComponentName}`, `/${this.relativeSrcRoot(this.relativeCwd(removeExtension3(componentEntry2.jsonPath)))}`);
1779
1802
  }
1780
1803
  }
1781
1804
  }
@@ -1796,8 +1819,8 @@ var CompilerContext = class {
1796
1819
  }
1797
1820
  // eslint-disable-next-line ts/no-unused-vars
1798
1821
  autoImportFilter(id, meta) {
1799
- if (this.inlineConfig.weapp?.enhance?.autoImportComponents?.dirs) {
1800
- const isMatch = pm2(this.inlineConfig.weapp.enhance.autoImportComponents.dirs, {
1822
+ if (this.inlineConfig.weapp?.enhance?.autoImportComponents?.globs) {
1823
+ const isMatch = pm2(this.inlineConfig.weapp.enhance.autoImportComponents.globs, {
1801
1824
  cwd: this.cwd
1802
1825
  });
1803
1826
  return isMatch(id);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  init_esm_shims
3
- } from "./chunk-ZZXLQPEB.mjs";
3
+ } from "./chunk-D64WYHZN.mjs";
4
4
 
5
5
  // src/config.ts
6
6
  init_esm_shims();
package/dist/cli.cjs CHANGED
@@ -28,9 +28,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  mod
29
29
  ));
30
30
 
31
- // ../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.9.3_jiti@2.4.0_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/cjs_shims.js
31
+ // ../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.10.0_jiti@2.4.0_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/cjs_shims.js
32
32
  var init_cjs_shims = __esm({
33
- "../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.9.3_jiti@2.4.0_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/cjs_shims.js"() {
33
+ "../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.10.0_jiti@2.4.0_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/cjs_shims.js"() {
34
34
  "use strict";
35
35
  }
36
36
  });
@@ -130,7 +130,7 @@ var import_weapp_ide_cli = require("weapp-ide-cli");
130
130
  init_cjs_shims();
131
131
 
132
132
  // package.json
133
- var version = "1.8.2";
133
+ var version = "1.8.3";
134
134
 
135
135
  // src/constants.ts
136
136
  var VERSION = version;
@@ -704,7 +704,7 @@ function processWxml(wxml, options) {
704
704
  currentTagName = "";
705
705
  attrs = {};
706
706
  importAttrs = void 0;
707
- tagStartIndex = -1;
707
+ tagStartIndex = 0;
708
708
  },
709
709
  ontext(data) {
710
710
  if (currentTagName === "wxs" && jsExtensions.includes(attrs.lang)) {
@@ -717,7 +717,8 @@ ${res.code}`);
717
717
  }
718
718
  },
719
719
  {
720
- lowerCaseTags: false
720
+ lowerCaseTags: false,
721
+ xmlMode: true
721
722
  }
722
723
  );
723
724
  parser.write(
@@ -984,7 +985,9 @@ function vitePluginWeapp(ctx, subPackageMeta) {
984
985
  if (appEntry.sitemapJsonPath) {
985
986
  this.addWatchFile(appEntry.sitemapJsonPath);
986
987
  if (appEntry.sitemapJson) {
987
- const fileName = jsonFileRemoveJsExtension(ctx.relativeSrcRoot(ctx.relativeCwd(appEntry.sitemapJsonPath)));
988
+ const fileName = jsonFileRemoveJsExtension(
989
+ ctx.relativeSrcRoot(ctx.relativeCwd(appEntry.sitemapJsonPath))
990
+ );
988
991
  this.emitFile({
989
992
  type: "asset",
990
993
  fileName,
@@ -998,7 +1001,9 @@ function vitePluginWeapp(ctx, subPackageMeta) {
998
1001
  if (appEntry.themeJsonPath) {
999
1002
  this.addWatchFile(appEntry.themeJsonPath);
1000
1003
  if (appEntry.themeJson) {
1001
- const fileName = jsonFileRemoveJsExtension(ctx.relativeSrcRoot(ctx.relativeCwd(appEntry.themeJsonPath)));
1004
+ const fileName = jsonFileRemoveJsExtension(
1005
+ ctx.relativeSrcRoot(ctx.relativeCwd(appEntry.themeJsonPath))
1006
+ );
1002
1007
  this.emitFile({
1003
1008
  type: "asset",
1004
1009
  fileName,
@@ -1313,8 +1318,8 @@ async function loadDefaultConfig() {
1313
1318
  this.inlineConfig.plugins?.push((0, import_vite_tsconfig_paths.default)(this.inlineConfig.weapp?.tsconfigPaths));
1314
1319
  this.aliasEntries = getAliasEntries(this.inlineConfig.weapp?.jsonAlias);
1315
1320
  if (this.inlineConfig.weapp?.enhance) {
1316
- if (Array.isArray(this.inlineConfig.weapp.enhance.autoImportComponents?.dirs)) {
1317
- this.autoImportFilter = (0, import_picomatch.default)(this.inlineConfig.weapp.enhance.autoImportComponents.dirs, {
1321
+ if (Array.isArray(this.inlineConfig.weapp.enhance.autoImportComponents?.globs)) {
1322
+ this.autoImportFilter = (0, import_picomatch.default)(this.inlineConfig.weapp.enhance.autoImportComponents.globs, {
1318
1323
  cwd: this.cwd,
1319
1324
  windows: true,
1320
1325
  posixSlashes: true
@@ -1672,7 +1677,13 @@ var CompilerContext = class {
1672
1677
  logger_default.warn(`\u53D1\u73B0\u7EC4\u4EF6\u91CD\u540D! \u8DF3\u8FC7\u7EC4\u4EF6 ${this.relativeCwd(baseName)} \u7684\u81EA\u52A8\u5F15\u5165`);
1673
1678
  return;
1674
1679
  }
1675
- this.potentialComponentMap.set(componentName, partialEntry);
1680
+ this.potentialComponentMap.set(componentName, {
1681
+ entry: partialEntry,
1682
+ value: {
1683
+ name: componentName,
1684
+ from: `/${this.relativeSrcRoot(this.relativeCwd((0, import_shared13.removeExtension)(partialEntry.jsonPath)))}`
1685
+ }
1686
+ });
1676
1687
  }
1677
1688
  }
1678
1689
  }
@@ -1817,12 +1828,24 @@ var CompilerContext = class {
1817
1828
  const depComponentNames = Object.keys(hit);
1818
1829
  debug2?.(this.potentialComponentMap, jsonFragment.json.usingComponents);
1819
1830
  for (const depComponentName of depComponentNames) {
1820
- const componentEntry2 = this.potentialComponentMap.get(depComponentName);
1821
- if (componentEntry2 && componentEntry2.jsonPath) {
1822
- if ((0, import_shared13.isObject)(jsonFragment.json.usingComponents) && Reflect.has(jsonFragment.json.usingComponents, depComponentName)) {
1823
- continue;
1831
+ const res = this.potentialComponentMap.get(depComponentName);
1832
+ if (res) {
1833
+ const { entry: componentEntry2, value } = res;
1834
+ if (componentEntry2 && componentEntry2.jsonPath) {
1835
+ if ((0, import_shared13.isObject)(jsonFragment.json.usingComponents) && Reflect.has(jsonFragment.json.usingComponents, value.name)) {
1836
+ continue;
1837
+ }
1838
+ (0, import_shared13.set)(jsonFragment.json, `usingComponents.${value.name}`, value.from);
1839
+ }
1840
+ } else if (Array.isArray(this.inlineConfig.weapp?.enhance?.autoImportComponents?.resolvers)) {
1841
+ for (const resolver of this.inlineConfig.weapp.enhance.autoImportComponents.resolvers) {
1842
+ const value = resolver(depComponentName);
1843
+ if (value) {
1844
+ if (!((0, import_shared13.isObject)(jsonFragment.json.usingComponents) && Reflect.has(jsonFragment.json.usingComponents, value.name))) {
1845
+ (0, import_shared13.set)(jsonFragment.json, `usingComponents.${value.name}`, value.from);
1846
+ }
1847
+ }
1824
1848
  }
1825
- (0, import_shared13.set)(jsonFragment.json, `usingComponents.${depComponentName}`, `/${this.relativeSrcRoot(this.relativeCwd((0, import_shared13.removeExtension)(componentEntry2.jsonPath)))}`);
1826
1849
  }
1827
1850
  }
1828
1851
  }
@@ -1843,8 +1866,8 @@ var CompilerContext = class {
1843
1866
  }
1844
1867
  // eslint-disable-next-line ts/no-unused-vars
1845
1868
  autoImportFilter(id, meta) {
1846
- if (this.inlineConfig.weapp?.enhance?.autoImportComponents?.dirs) {
1847
- const isMatch = (0, import_picomatch2.default)(this.inlineConfig.weapp.enhance.autoImportComponents.dirs, {
1869
+ if (this.inlineConfig.weapp?.enhance?.autoImportComponents?.globs) {
1870
+ const isMatch = (0, import_picomatch2.default)(this.inlineConfig.weapp.enhance.autoImportComponents.globs, {
1848
1871
  cwd: this.cwd
1849
1872
  });
1850
1873
  return isMatch(id);
package/dist/cli.mjs CHANGED
@@ -2,11 +2,11 @@ import {
2
2
  VERSION,
3
3
  createCompilerContext,
4
4
  logger_default
5
- } from "./chunk-D2PBHZAB.mjs";
6
- import "./chunk-67O7U5RB.mjs";
5
+ } from "./chunk-DC4L5OGS.mjs";
6
+ import "./chunk-WG52HBNS.mjs";
7
7
  import {
8
8
  init_esm_shims
9
- } from "./chunk-ZZXLQPEB.mjs";
9
+ } from "./chunk-D64WYHZN.mjs";
10
10
 
11
11
  // src/cli.ts
12
12
  init_esm_shims();
@@ -3,6 +3,7 @@ import { Theme, Sitemap, App, Page, Component } from '@weapp-core/schematics';
3
3
  import { PackageJson } from 'pkg-types';
4
4
  import { Options } from 'tsup';
5
5
  import { PluginOptions } from 'vite-tsconfig-paths';
6
+ import { a as Resolver } from './types-Cvkpy1-u.js';
6
7
 
7
8
  interface Alias {
8
9
  find: string | RegExp;
@@ -59,7 +60,8 @@ interface CopyOptions {
59
60
  }
60
61
  type CopyGlobs = string[] | ((subPackageMeta?: SubPackageMetaValue | undefined) => string[]);
61
62
  interface AutoImportComponents {
62
- dirs?: string[];
63
+ globs?: string[];
64
+ resolvers?: Resolver[];
63
65
  }
64
66
  interface EnhanceOptions {
65
67
  /**
@@ -3,6 +3,7 @@ import { Theme, Sitemap, App, Page, Component } from '@weapp-core/schematics';
3
3
  import { PackageJson } from 'pkg-types';
4
4
  import { Options } from 'tsup';
5
5
  import { PluginOptions } from 'vite-tsconfig-paths';
6
+ import { a as Resolver } from './types-Cvkpy1-u.cjs';
6
7
 
7
8
  interface Alias {
8
9
  find: string | RegExp;
@@ -59,7 +60,8 @@ interface CopyOptions {
59
60
  }
60
61
  type CopyGlobs = string[] | ((subPackageMeta?: SubPackageMetaValue | undefined) => string[]);
61
62
  interface AutoImportComponents {
62
- dirs?: string[];
63
+ globs?: string[];
64
+ resolvers?: Resolver[];
63
65
  }
64
66
  interface EnhanceOptions {
65
67
  /**
package/dist/config.d.cts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { UserConfig, UserConfigExport, UserConfigFnObject } from 'vite';
2
- export { d as defineConfig } from './config-D4m0SOty.cjs';
2
+ export { d as defineConfig } from './config-nZhQe_5k.cjs';
3
3
  import '@weapp-core/schematics';
4
4
  import 'pkg-types';
5
5
  import 'tsup';
6
6
  import 'vite-tsconfig-paths';
7
+ import './types-Cvkpy1-u.cjs';
package/dist/config.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { UserConfig, UserConfigExport, UserConfigFnObject } from 'vite';
2
- export { d as defineConfig } from './config-D4m0SOty.js';
2
+ export { d as defineConfig } from './config-D1TnAC7f.js';
3
3
  import '@weapp-core/schematics';
4
4
  import 'pkg-types';
5
5
  import 'tsup';
6
6
  import 'vite-tsconfig-paths';
7
+ import './types-Cvkpy1-u.js';
package/dist/config.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  defineConfig
3
- } from "./chunk-67O7U5RB.mjs";
4
- import "./chunk-ZZXLQPEB.mjs";
3
+ } from "./chunk-WG52HBNS.mjs";
4
+ import "./chunk-D64WYHZN.mjs";
5
5
  export {
6
6
  defineConfig
7
7
  };
package/dist/index.cjs CHANGED
@@ -33,9 +33,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
33
  ));
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
 
36
- // ../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.9.3_jiti@2.4.0_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/cjs_shims.js
36
+ // ../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.10.0_jiti@2.4.0_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/cjs_shims.js
37
37
  var init_cjs_shims = __esm({
38
- "../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.9.3_jiti@2.4.0_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/cjs_shims.js"() {
38
+ "../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.10.0_jiti@2.4.0_postcss@8.4.49_tsx@4.19.2_typescript@5.7.2_yaml@2.6.1/node_modules/tsup/assets/cjs_shims.js"() {
39
39
  "use strict";
40
40
  }
41
41
  });
@@ -703,7 +703,7 @@ function processWxml(wxml, options) {
703
703
  currentTagName = "";
704
704
  attrs = {};
705
705
  importAttrs = void 0;
706
- tagStartIndex = -1;
706
+ tagStartIndex = 0;
707
707
  },
708
708
  ontext(data) {
709
709
  if (currentTagName === "wxs" && jsExtensions.includes(attrs.lang)) {
@@ -716,7 +716,8 @@ ${res.code}`);
716
716
  }
717
717
  },
718
718
  {
719
- lowerCaseTags: false
719
+ lowerCaseTags: false,
720
+ xmlMode: true
720
721
  }
721
722
  );
722
723
  parser.write(
@@ -983,7 +984,9 @@ function vitePluginWeapp(ctx, subPackageMeta) {
983
984
  if (appEntry.sitemapJsonPath) {
984
985
  this.addWatchFile(appEntry.sitemapJsonPath);
985
986
  if (appEntry.sitemapJson) {
986
- const fileName = jsonFileRemoveJsExtension(ctx.relativeSrcRoot(ctx.relativeCwd(appEntry.sitemapJsonPath)));
987
+ const fileName = jsonFileRemoveJsExtension(
988
+ ctx.relativeSrcRoot(ctx.relativeCwd(appEntry.sitemapJsonPath))
989
+ );
987
990
  this.emitFile({
988
991
  type: "asset",
989
992
  fileName,
@@ -997,7 +1000,9 @@ function vitePluginWeapp(ctx, subPackageMeta) {
997
1000
  if (appEntry.themeJsonPath) {
998
1001
  this.addWatchFile(appEntry.themeJsonPath);
999
1002
  if (appEntry.themeJson) {
1000
- const fileName = jsonFileRemoveJsExtension(ctx.relativeSrcRoot(ctx.relativeCwd(appEntry.themeJsonPath)));
1003
+ const fileName = jsonFileRemoveJsExtension(
1004
+ ctx.relativeSrcRoot(ctx.relativeCwd(appEntry.themeJsonPath))
1005
+ );
1001
1006
  this.emitFile({
1002
1007
  type: "asset",
1003
1008
  fileName,
@@ -1312,8 +1317,8 @@ async function loadDefaultConfig() {
1312
1317
  this.inlineConfig.plugins?.push((0, import_vite_tsconfig_paths.default)(this.inlineConfig.weapp?.tsconfigPaths));
1313
1318
  this.aliasEntries = getAliasEntries(this.inlineConfig.weapp?.jsonAlias);
1314
1319
  if (this.inlineConfig.weapp?.enhance) {
1315
- if (Array.isArray(this.inlineConfig.weapp.enhance.autoImportComponents?.dirs)) {
1316
- this.autoImportFilter = (0, import_picomatch.default)(this.inlineConfig.weapp.enhance.autoImportComponents.dirs, {
1320
+ if (Array.isArray(this.inlineConfig.weapp.enhance.autoImportComponents?.globs)) {
1321
+ this.autoImportFilter = (0, import_picomatch.default)(this.inlineConfig.weapp.enhance.autoImportComponents.globs, {
1317
1322
  cwd: this.cwd,
1318
1323
  windows: true,
1319
1324
  posixSlashes: true
@@ -1671,7 +1676,13 @@ var CompilerContext = class {
1671
1676
  logger_default.warn(`\u53D1\u73B0\u7EC4\u4EF6\u91CD\u540D! \u8DF3\u8FC7\u7EC4\u4EF6 ${this.relativeCwd(baseName)} \u7684\u81EA\u52A8\u5F15\u5165`);
1672
1677
  return;
1673
1678
  }
1674
- this.potentialComponentMap.set(componentName, partialEntry);
1679
+ this.potentialComponentMap.set(componentName, {
1680
+ entry: partialEntry,
1681
+ value: {
1682
+ name: componentName,
1683
+ from: `/${this.relativeSrcRoot(this.relativeCwd((0, import_shared13.removeExtension)(partialEntry.jsonPath)))}`
1684
+ }
1685
+ });
1675
1686
  }
1676
1687
  }
1677
1688
  }
@@ -1816,12 +1827,24 @@ var CompilerContext = class {
1816
1827
  const depComponentNames = Object.keys(hit);
1817
1828
  debug2?.(this.potentialComponentMap, jsonFragment.json.usingComponents);
1818
1829
  for (const depComponentName of depComponentNames) {
1819
- const componentEntry2 = this.potentialComponentMap.get(depComponentName);
1820
- if (componentEntry2 && componentEntry2.jsonPath) {
1821
- if ((0, import_shared13.isObject)(jsonFragment.json.usingComponents) && Reflect.has(jsonFragment.json.usingComponents, depComponentName)) {
1822
- continue;
1830
+ const res = this.potentialComponentMap.get(depComponentName);
1831
+ if (res) {
1832
+ const { entry: componentEntry2, value } = res;
1833
+ if (componentEntry2 && componentEntry2.jsonPath) {
1834
+ if ((0, import_shared13.isObject)(jsonFragment.json.usingComponents) && Reflect.has(jsonFragment.json.usingComponents, value.name)) {
1835
+ continue;
1836
+ }
1837
+ (0, import_shared13.set)(jsonFragment.json, `usingComponents.${value.name}`, value.from);
1838
+ }
1839
+ } else if (Array.isArray(this.inlineConfig.weapp?.enhance?.autoImportComponents?.resolvers)) {
1840
+ for (const resolver of this.inlineConfig.weapp.enhance.autoImportComponents.resolvers) {
1841
+ const value = resolver(depComponentName);
1842
+ if (value) {
1843
+ if (!((0, import_shared13.isObject)(jsonFragment.json.usingComponents) && Reflect.has(jsonFragment.json.usingComponents, value.name))) {
1844
+ (0, import_shared13.set)(jsonFragment.json, `usingComponents.${value.name}`, value.from);
1845
+ }
1846
+ }
1823
1847
  }
1824
- (0, import_shared13.set)(jsonFragment.json, `usingComponents.${depComponentName}`, `/${this.relativeSrcRoot(this.relativeCwd((0, import_shared13.removeExtension)(componentEntry2.jsonPath)))}`);
1825
1848
  }
1826
1849
  }
1827
1850
  }
@@ -1842,8 +1865,8 @@ var CompilerContext = class {
1842
1865
  }
1843
1866
  // eslint-disable-next-line ts/no-unused-vars
1844
1867
  autoImportFilter(id, meta) {
1845
- if (this.inlineConfig.weapp?.enhance?.autoImportComponents?.dirs) {
1846
- const isMatch = (0, import_picomatch2.default)(this.inlineConfig.weapp.enhance.autoImportComponents.dirs, {
1868
+ if (this.inlineConfig.weapp?.enhance?.autoImportComponents?.globs) {
1869
+ const isMatch = (0, import_picomatch2.default)(this.inlineConfig.weapp.enhance.autoImportComponents.globs, {
1847
1870
  cwd: this.cwd
1848
1871
  });
1849
1872
  return isMatch(id);
package/dist/index.d.cts CHANGED
@@ -1,10 +1,11 @@
1
- import { C as CompilerContextOptions } from './config-D4m0SOty.cjs';
2
- import { C as CompilerContext } from './CompilerContext-D4FME90S.cjs';
1
+ import { C as CompilerContextOptions } from './config-nZhQe_5k.cjs';
2
+ import { C as CompilerContext } from './CompilerContext-J434RJfW.cjs';
3
3
  import 'vite';
4
4
  import '@weapp-core/schematics';
5
5
  import 'pkg-types';
6
6
  import 'tsup';
7
7
  import 'vite-tsconfig-paths';
8
+ import './types-Cvkpy1-u.cjs';
8
9
  import 'rollup';
9
10
 
10
11
  interface CreateCompilerContextOptions {
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- import { C as CompilerContextOptions } from './config-D4m0SOty.js';
2
- import { C as CompilerContext } from './CompilerContext-CG21uxpV.js';
1
+ import { C as CompilerContextOptions } from './config-D1TnAC7f.js';
2
+ import { C as CompilerContext } from './CompilerContext-DCxTV9m_.js';
3
3
  import 'vite';
4
4
  import '@weapp-core/schematics';
5
5
  import 'pkg-types';
6
6
  import 'tsup';
7
7
  import 'vite-tsconfig-paths';
8
+ import './types-Cvkpy1-u.js';
8
9
  import 'rollup';
9
10
 
10
11
  interface CreateCompilerContextOptions {
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  CompilerContext,
3
3
  createCompilerContext
4
- } from "./chunk-D2PBHZAB.mjs";
5
- import "./chunk-67O7U5RB.mjs";
4
+ } from "./chunk-DC4L5OGS.mjs";
5
+ import "./chunk-WG52HBNS.mjs";
6
6
  import {
7
7
  init_esm_shims
8
- } from "./chunk-ZZXLQPEB.mjs";
8
+ } from "./chunk-D64WYHZN.mjs";
9
9
 
10
10
  // src/index.ts
11
11
  init_esm_shims();
package/dist/json.d.cts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { App, Page, Component, Sitemap, Theme } from '@weapp-core/schematics';
2
2
  export { App, Component, Page, Sitemap, Theme } from '@weapp-core/schematics';
3
- import { C as CompilerContext } from './CompilerContext-D4FME90S.cjs';
3
+ import { C as CompilerContext } from './CompilerContext-J434RJfW.cjs';
4
4
  import 'pkg-types';
5
5
  import 'rollup';
6
- import './config-D4m0SOty.cjs';
6
+ import './types-Cvkpy1-u.cjs';
7
+ import './config-nZhQe_5k.cjs';
7
8
  import 'vite';
8
9
  import 'tsup';
9
10
  import 'vite-tsconfig-paths';
package/dist/json.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { App, Page, Component, Sitemap, Theme } from '@weapp-core/schematics';
2
2
  export { App, Component, Page, Sitemap, Theme } from '@weapp-core/schematics';
3
- import { C as CompilerContext } from './CompilerContext-CG21uxpV.js';
3
+ import { C as CompilerContext } from './CompilerContext-DCxTV9m_.js';
4
4
  import 'pkg-types';
5
5
  import 'rollup';
6
- import './config-D4m0SOty.js';
6
+ import './types-Cvkpy1-u.js';
7
+ import './config-D1TnAC7f.js';
7
8
  import 'vite';
8
9
  import 'tsup';
9
10
  import 'vite-tsconfig-paths';
package/dist/json.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  init_esm_shims
3
- } from "./chunk-ZZXLQPEB.mjs";
3
+ } from "./chunk-D64WYHZN.mjs";
4
4
 
5
5
  // src/json.ts
6
6
  init_esm_shims();
@@ -0,0 +1,8 @@
1
+ interface ResolvedValue {
2
+ name: string;
3
+ from: string;
4
+ }
5
+ type Resolver = (componentName: string) => ResolvedValue | void;
6
+ type CreateResolver<T = any> = (options?: T) => Resolver;
7
+
8
+ export type { CreateResolver as C, ResolvedValue as R, Resolver as a };
@@ -0,0 +1,8 @@
1
+ interface ResolvedValue {
2
+ name: string;
3
+ from: string;
4
+ }
5
+ type Resolver = (componentName: string) => ResolvedValue | void;
6
+ type CreateResolver<T = any> = (options?: T) => Resolver;
7
+
8
+ export type { CreateResolver as C, ResolvedValue as R, Resolver as a };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite",
3
3
  "type": "module",
4
- "version": "1.8.2",
4
+ "version": "1.8.3",
5
5
  "description": "weapp-vite 一个现代化的小程序打包工具",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -40,11 +40,19 @@
40
40
  "import": "./dist/json.mjs",
41
41
  "require": "./dist/json.cjs"
42
42
  },
43
+ "./auto-import-components/resolvers": {
44
+ "types": "./dist/auto-import-components/resolvers.d.ts",
45
+ "import": "./dist/auto-import-components/resolvers.mjs",
46
+ "require": "./dist/auto-import-components/resolvers.cjs"
47
+ },
43
48
  "./client": {
44
49
  "types": "./client.d.ts"
45
50
  },
46
51
  "./package.json": "./package.json"
47
52
  },
53
+ "//---": {
54
+ "./auto-import-components/resolvers": "./src/auto-import-components/resolvers/index.ts"
55
+ },
48
56
  "bin": {
49
57
  "weapp-vite": "bin/weapp-vite.js",
50
58
  "weapp-vite-esm": "bin/weapp-vite-esm.js",
@@ -81,10 +89,10 @@
81
89
  "vite": "^5.4.11",
82
90
  "vite-tsconfig-paths": "^5.1.3",
83
91
  "@weapp-core/init": "^1.1.11",
92
+ "@weapp-core/schematics": "^1.0.7",
84
93
  "@weapp-core/logger": "^1.0.1",
85
- "@weapp-core/shared": "^1.0.4",
86
94
  "weapp-ide-cli": "^2.0.6",
87
- "@weapp-core/schematics": "^1.0.7"
95
+ "@weapp-core/shared": "^1.0.4"
88
96
  },
89
97
  "publishConfig": {
90
98
  "access": "public",