weapp-vite 1.6.7 → 1.6.8

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.
@@ -3,7 +3,7 @@ import logger from "@weapp-core/logger";
3
3
  var logger_default = logger;
4
4
 
5
5
  // package.json
6
- var version = "1.6.7";
6
+ var version = "1.6.8";
7
7
 
8
8
  // src/constants.ts
9
9
  var VERSION = version;
@@ -533,6 +533,9 @@ var CompilerContext = class {
533
533
  aliasEntries;
534
534
  platform;
535
535
  outputExtensions;
536
+ /**
537
+ * 不修改 ctx
538
+ */
536
539
  readCommentJson;
537
540
  /**
538
541
  * esbuild 定义的环境变量
@@ -777,7 +780,7 @@ var CompilerContext = class {
777
780
  // miniprogram_dist
778
781
  // miniprogram
779
782
  // https://developers.weixin.qq.com/miniprogram/dev/devtools/npm.html#%E8%87%AA%E5%AE%9A%E4%B9%89%E7%BB%84%E4%BB%B6%E7%9B%B8%E5%85%B3%E7%A4%BA%E4%BE%8B
780
- async buildNpm(options) {
783
+ async buildNpm(subPackage, options) {
781
784
  debug2?.("buildNpm start");
782
785
  const { build: tsupBuild } = await import("tsup");
783
786
  const isDependenciesCacheOutdate = await this.checkDependenciesCacheOutdate();
@@ -796,7 +799,7 @@ var CompilerContext = class {
796
799
  const packageJsonPath = path5.resolve(this.cwd, relation.packageJsonPath);
797
800
  if (await fs5.exists(packageJsonPath)) {
798
801
  const pkgJson = await fs5.readJson(packageJsonPath);
799
- const outDir = path5.resolve(this.cwd, relation.miniprogramNpmDistDir, "miniprogram_npm");
802
+ const outDir = path5.resolve(this.cwd, relation.miniprogramNpmDistDir, subPackage?.root ?? "", "miniprogram_npm");
800
803
  if (pkgJson.dependencies) {
801
804
  const dependencies = Object.keys(pkgJson.dependencies);
802
805
  if (dependencies.length > 0) {
@@ -858,7 +861,12 @@ var CompilerContext = class {
858
861
  await this.writeDependenciesCache();
859
862
  debug2?.("buildNpm end");
860
863
  }
861
- async usingComponentsHandler(entry, relDir) {
864
+ /**
865
+ * @deps [this.scanComponentEntry]
866
+ * @param entry
867
+ * @param relDir
868
+ */
869
+ async usingComponentsHandler(entry, relDir, subPackageMeta) {
862
870
  const { usingComponents } = entry.json;
863
871
  if (usingComponents) {
864
872
  for (const [, componentUrl] of Object.entries(usingComponents)) {
@@ -869,10 +877,10 @@ var CompilerContext = class {
869
877
  if (tokens[0] && isObject3(this.packageJson.dependencies) && Reflect.has(this.packageJson.dependencies, tokens[0])) {
870
878
  continue;
871
879
  } else if (tokens[0] === "") {
872
- await this.scanComponentEntry(componentUrl.substring(1), path5.resolve(this.cwd, this.srcRoot));
880
+ await this.scanComponentEntry(componentUrl.substring(1), path5.resolve(this.cwd, this.srcRoot), subPackageMeta);
873
881
  } else {
874
882
  const importee = resolveImportee(componentUrl, entry, this.aliasEntries);
875
- await this.scanComponentEntry(importee, relDir);
883
+ await this.scanComponentEntry(importee, relDir, subPackageMeta);
876
884
  }
877
885
  }
878
886
  }
@@ -882,6 +890,17 @@ var CompilerContext = class {
882
890
  this.entries.length = 0;
883
891
  this.subPackageMeta = {};
884
892
  }
893
+ // fork() {
894
+ // return new CompilerContext({
895
+ // cwd: this.cwd,
896
+ // inlineConfig: this.inlineConfig,
897
+ // isDev: this.isDev,
898
+ // mode: this.mode,
899
+ // packageJson: this.packageJson,
900
+ // platform: this.platform,
901
+ // projectConfig: this.projectConfig,
902
+ // })
903
+ // }
885
904
  async scanAppEntry() {
886
905
  debug2?.("scanAppEntry start");
887
906
  this.resetEntries();
@@ -933,14 +952,13 @@ var CompilerContext = class {
933
952
  entriesSet: /* @__PURE__ */ new Set(),
934
953
  subPackage: sub
935
954
  };
936
- const scanComponentEntry = this.scanComponentEntry.bind(meta);
937
955
  if (Array.isArray(sub.pages)) {
938
956
  for (const page of sub.pages) {
939
- await scanComponentEntry(path5.join(sub.root, page), appDirname);
957
+ await this.scanComponentEntry(path5.join(sub.root, page), appDirname, meta);
940
958
  }
941
959
  }
942
960
  if (sub.entry) {
943
- await scanComponentEntry(path5.join(sub.root, sub.entry), appDirname);
961
+ await this.scanComponentEntry(path5.join(sub.root, sub.entry), appDirname, meta);
944
962
  }
945
963
  this.subPackageMeta[sub.root] = meta;
946
964
  } else {
@@ -969,16 +987,20 @@ var CompilerContext = class {
969
987
  // pages
970
988
  // https://developers.weixin.qq.com/miniprogram/dev/framework/structure.html
971
989
  // 页面可以没有 JSON
972
- async scanComponentEntry(componentEntry, dirname) {
990
+ async scanComponentEntry(componentEntry, dirname, subPackageMeta) {
991
+ const meta = subPackageMeta ?? {
992
+ entriesSet: this.entriesSet,
993
+ entries: this.entries
994
+ };
973
995
  debug2?.("scanComponentEntry start", componentEntry);
974
996
  const baseName = removeExtension(path5.resolve(dirname, componentEntry));
975
997
  const jsEntry = await findJsEntry(baseName);
976
998
  const partialEntry = {
977
999
  path: jsEntry
978
1000
  };
979
- if (jsEntry && !this.entriesSet.has(jsEntry)) {
980
- this.entriesSet.add(jsEntry);
981
- this.entries.push(partialEntry);
1001
+ if (jsEntry && !meta.entriesSet.has(jsEntry)) {
1002
+ meta.entriesSet.add(jsEntry);
1003
+ meta.entries.push(partialEntry);
982
1004
  }
983
1005
  const configFile = await findJsonEntry(baseName);
984
1006
  if (configFile) {
@@ -992,7 +1014,7 @@ var CompilerContext = class {
992
1014
  partialEntry.jsonPath = jsonFragment.jsonPath;
993
1015
  }
994
1016
  if (isObject3(config)) {
995
- await this.usingComponentsHandler(jsonFragment, path5.dirname(configFile));
1017
+ await this.usingComponentsHandler(jsonFragment, path5.dirname(configFile), subPackageMeta);
996
1018
  }
997
1019
  }
998
1020
  debug2?.("scanComponentEntry end", componentEntry);
@@ -1017,6 +1039,7 @@ var CompilerContext = class {
1017
1039
  }
1018
1040
  }
1019
1041
  });
1042
+ await this.buildNpm(meta.subPackage);
1020
1043
  const output = await build(
1021
1044
  inlineConfig
1022
1045
  );
package/dist/cli.cjs CHANGED
@@ -22,7 +22,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  mod
23
23
  ));
24
24
 
25
- // ../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.7.40_jiti@2.3.1_postcss@8.4.47_tsx@4.19.2_typescript@5.6.3_yaml@2.6.0/node_modules/tsup/assets/cjs_shims.js
25
+ // ../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.7.42_jiti@2.3.1_postcss@8.4.47_tsx@4.19.2_typescript@5.6.3_yaml@2.6.0/node_modules/tsup/assets/cjs_shims.js
26
26
  var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
27
27
  var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
28
28
 
@@ -34,7 +34,7 @@ var import_vite3 = require("vite");
34
34
  var import_weapp_ide_cli = require("weapp-ide-cli");
35
35
 
36
36
  // package.json
37
- var version = "1.6.7";
37
+ var version = "1.6.8";
38
38
 
39
39
  // src/constants.ts
40
40
  var VERSION = version;
@@ -568,6 +568,9 @@ var CompilerContext = class {
568
568
  aliasEntries;
569
569
  platform;
570
570
  outputExtensions;
571
+ /**
572
+ * 不修改 ctx
573
+ */
571
574
  readCommentJson;
572
575
  /**
573
576
  * esbuild 定义的环境变量
@@ -812,7 +815,7 @@ var CompilerContext = class {
812
815
  // miniprogram_dist
813
816
  // miniprogram
814
817
  // https://developers.weixin.qq.com/miniprogram/dev/devtools/npm.html#%E8%87%AA%E5%AE%9A%E4%B9%89%E7%BB%84%E4%BB%B6%E7%9B%B8%E5%85%B3%E7%A4%BA%E4%BE%8B
815
- async buildNpm(options) {
818
+ async buildNpm(subPackage, options) {
816
819
  debug2?.("buildNpm start");
817
820
  const { build: tsupBuild } = await import("tsup");
818
821
  const isDependenciesCacheOutdate = await this.checkDependenciesCacheOutdate();
@@ -831,7 +834,7 @@ var CompilerContext = class {
831
834
  const packageJsonPath = import_pathe5.default.resolve(this.cwd, relation.packageJsonPath);
832
835
  if (await import_fs_extra5.default.exists(packageJsonPath)) {
833
836
  const pkgJson = await import_fs_extra5.default.readJson(packageJsonPath);
834
- const outDir = import_pathe5.default.resolve(this.cwd, relation.miniprogramNpmDistDir, "miniprogram_npm");
837
+ const outDir = import_pathe5.default.resolve(this.cwd, relation.miniprogramNpmDistDir, subPackage?.root ?? "", "miniprogram_npm");
835
838
  if (pkgJson.dependencies) {
836
839
  const dependencies = Object.keys(pkgJson.dependencies);
837
840
  if (dependencies.length > 0) {
@@ -893,7 +896,12 @@ var CompilerContext = class {
893
896
  await this.writeDependenciesCache();
894
897
  debug2?.("buildNpm end");
895
898
  }
896
- async usingComponentsHandler(entry, relDir) {
899
+ /**
900
+ * @deps [this.scanComponentEntry]
901
+ * @param entry
902
+ * @param relDir
903
+ */
904
+ async usingComponentsHandler(entry, relDir, subPackageMeta) {
897
905
  const { usingComponents } = entry.json;
898
906
  if (usingComponents) {
899
907
  for (const [, componentUrl] of Object.entries(usingComponents)) {
@@ -904,10 +912,10 @@ var CompilerContext = class {
904
912
  if (tokens[0] && (0, import_shared3.isObject)(this.packageJson.dependencies) && Reflect.has(this.packageJson.dependencies, tokens[0])) {
905
913
  continue;
906
914
  } else if (tokens[0] === "") {
907
- await this.scanComponentEntry(componentUrl.substring(1), import_pathe5.default.resolve(this.cwd, this.srcRoot));
915
+ await this.scanComponentEntry(componentUrl.substring(1), import_pathe5.default.resolve(this.cwd, this.srcRoot), subPackageMeta);
908
916
  } else {
909
917
  const importee = resolveImportee(componentUrl, entry, this.aliasEntries);
910
- await this.scanComponentEntry(importee, relDir);
918
+ await this.scanComponentEntry(importee, relDir, subPackageMeta);
911
919
  }
912
920
  }
913
921
  }
@@ -917,6 +925,17 @@ var CompilerContext = class {
917
925
  this.entries.length = 0;
918
926
  this.subPackageMeta = {};
919
927
  }
928
+ // fork() {
929
+ // return new CompilerContext({
930
+ // cwd: this.cwd,
931
+ // inlineConfig: this.inlineConfig,
932
+ // isDev: this.isDev,
933
+ // mode: this.mode,
934
+ // packageJson: this.packageJson,
935
+ // platform: this.platform,
936
+ // projectConfig: this.projectConfig,
937
+ // })
938
+ // }
920
939
  async scanAppEntry() {
921
940
  debug2?.("scanAppEntry start");
922
941
  this.resetEntries();
@@ -968,14 +987,13 @@ var CompilerContext = class {
968
987
  entriesSet: /* @__PURE__ */ new Set(),
969
988
  subPackage: sub
970
989
  };
971
- const scanComponentEntry = this.scanComponentEntry.bind(meta);
972
990
  if (Array.isArray(sub.pages)) {
973
991
  for (const page of sub.pages) {
974
- await scanComponentEntry(import_pathe5.default.join(sub.root, page), appDirname);
992
+ await this.scanComponentEntry(import_pathe5.default.join(sub.root, page), appDirname, meta);
975
993
  }
976
994
  }
977
995
  if (sub.entry) {
978
- await scanComponentEntry(import_pathe5.default.join(sub.root, sub.entry), appDirname);
996
+ await this.scanComponentEntry(import_pathe5.default.join(sub.root, sub.entry), appDirname, meta);
979
997
  }
980
998
  this.subPackageMeta[sub.root] = meta;
981
999
  } else {
@@ -1004,16 +1022,20 @@ var CompilerContext = class {
1004
1022
  // pages
1005
1023
  // https://developers.weixin.qq.com/miniprogram/dev/framework/structure.html
1006
1024
  // 页面可以没有 JSON
1007
- async scanComponentEntry(componentEntry, dirname) {
1025
+ async scanComponentEntry(componentEntry, dirname, subPackageMeta) {
1026
+ const meta = subPackageMeta ?? {
1027
+ entriesSet: this.entriesSet,
1028
+ entries: this.entries
1029
+ };
1008
1030
  debug2?.("scanComponentEntry start", componentEntry);
1009
1031
  const baseName = (0, import_shared3.removeExtension)(import_pathe5.default.resolve(dirname, componentEntry));
1010
1032
  const jsEntry = await findJsEntry(baseName);
1011
1033
  const partialEntry = {
1012
1034
  path: jsEntry
1013
1035
  };
1014
- if (jsEntry && !this.entriesSet.has(jsEntry)) {
1015
- this.entriesSet.add(jsEntry);
1016
- this.entries.push(partialEntry);
1036
+ if (jsEntry && !meta.entriesSet.has(jsEntry)) {
1037
+ meta.entriesSet.add(jsEntry);
1038
+ meta.entries.push(partialEntry);
1017
1039
  }
1018
1040
  const configFile = await findJsonEntry(baseName);
1019
1041
  if (configFile) {
@@ -1027,7 +1049,7 @@ var CompilerContext = class {
1027
1049
  partialEntry.jsonPath = jsonFragment.jsonPath;
1028
1050
  }
1029
1051
  if ((0, import_shared3.isObject)(config)) {
1030
- await this.usingComponentsHandler(jsonFragment, import_pathe5.default.dirname(configFile));
1052
+ await this.usingComponentsHandler(jsonFragment, import_pathe5.default.dirname(configFile), subPackageMeta);
1031
1053
  }
1032
1054
  }
1033
1055
  debug2?.("scanComponentEntry end", componentEntry);
@@ -1052,6 +1074,7 @@ var CompilerContext = class {
1052
1074
  }
1053
1075
  }
1054
1076
  });
1077
+ await this.buildNpm(meta.subPackage);
1055
1078
  const output = await (0, import_vite2.build)(
1056
1079
  inlineConfig
1057
1080
  );
@@ -1165,10 +1188,17 @@ function convertBase(v) {
1165
1188
  }
1166
1189
  return v;
1167
1190
  }
1191
+ async function openIde() {
1192
+ try {
1193
+ await (0, import_weapp_ide_cli.parse)(["open", "-p"]);
1194
+ } catch (error) {
1195
+ logger_default.error(error);
1196
+ }
1197
+ }
1168
1198
  cli.option("-c, --config <file>", `[string] use specified config file`).option("--base <path>", `[string] public base path (default: /)`, {
1169
1199
  type: [convertBase]
1170
1200
  }).option("-l, --logLevel <level>", `[string] info | warn | error | silent`).option("--clearScreen", `[boolean] allow/disable clear screen when logging`).option("-d, --debug [feat]", `[string | boolean] show debug logs`).option("-f, --filter <filter>", `[string] filter debug logs`).option("-m, --mode <mode>", `[string] set env mode`);
1171
- cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--skipNpm", `[boolean] if skip npm build`).action(async (root, options) => {
1201
+ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--skipNpm", `[boolean] if skip npm build`).option("-o, --open", `[boolean] open ide`).action(async (root, options) => {
1172
1202
  filterDuplicateOptions(options);
1173
1203
  const ctx = await createCompilerContext({
1174
1204
  cwd: root,
@@ -1176,9 +1206,12 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
1176
1206
  isDev: true
1177
1207
  });
1178
1208
  if (!options.skipNpm) {
1179
- await ctx.buildNpm({ sourcemap: true });
1209
+ await ctx.buildNpm(void 0, { sourcemap: true });
1180
1210
  }
1181
1211
  await ctx.build();
1212
+ if (options.open) {
1213
+ await openIde();
1214
+ }
1182
1215
  });
1183
1216
  cli.command("build [root]", "build for production").option("--target <target>", `[string] transpile target (default: 'modules')`).option("--outDir <dir>", `[string] output directory (default: dist)`).option(
1184
1217
  "--sourcemap [output]",
@@ -1189,7 +1222,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
1189
1222
  ).option(
1190
1223
  "--emptyOutDir",
1191
1224
  `[boolean] force empty outDir when it's outside of root`
1192
- ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--skipNpm", `[boolean] if skip npm build`).action(async (root, options) => {
1225
+ ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--skipNpm", `[boolean] if skip npm build`).option("-o, --open", `[boolean] open ide`).action(async (root, options) => {
1193
1226
  filterDuplicateOptions(options);
1194
1227
  const ctx = await createCompilerContext({
1195
1228
  cwd: root,
@@ -1199,6 +1232,9 @@ cli.command("build [root]", "build for production").option("--target <target>",
1199
1232
  if (!options.skipNpm) {
1200
1233
  await ctx.buildNpm();
1201
1234
  }
1235
+ if (options.open) {
1236
+ await openIde();
1237
+ }
1202
1238
  });
1203
1239
  cli.command("init").action(async () => {
1204
1240
  try {
@@ -1210,11 +1246,7 @@ cli.command("init").action(async () => {
1210
1246
  }
1211
1247
  });
1212
1248
  cli.command("open").action(async () => {
1213
- try {
1214
- await (0, import_weapp_ide_cli.parse)(["open", "-p"]);
1215
- } catch (error) {
1216
- logger_default.error(error);
1217
- }
1249
+ await openIde();
1218
1250
  });
1219
1251
  cli.command("npm").alias("build:npm").alias("build-npm").action(async () => {
1220
1252
  try {
package/dist/cli.mjs CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  VERSION,
3
3
  createCompilerContext,
4
4
  logger_default
5
- } from "./chunk-5PUUYFZM.mjs";
5
+ } from "./chunk-C7FRWINE.mjs";
6
6
  import "./chunk-444MQSSG.mjs";
7
7
 
8
8
  // src/cli.ts
@@ -96,10 +96,17 @@ function convertBase(v) {
96
96
  }
97
97
  return v;
98
98
  }
99
+ async function openIde() {
100
+ try {
101
+ await parse(["open", "-p"]);
102
+ } catch (error) {
103
+ logger_default.error(error);
104
+ }
105
+ }
99
106
  cli.option("-c, --config <file>", `[string] use specified config file`).option("--base <path>", `[string] public base path (default: /)`, {
100
107
  type: [convertBase]
101
108
  }).option("-l, --logLevel <level>", `[string] info | warn | error | silent`).option("--clearScreen", `[boolean] allow/disable clear screen when logging`).option("-d, --debug [feat]", `[string | boolean] show debug logs`).option("-f, --filter <filter>", `[string] filter debug logs`).option("-m, --mode <mode>", `[string] set env mode`);
102
- cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--skipNpm", `[boolean] if skip npm build`).action(async (root, options) => {
109
+ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--skipNpm", `[boolean] if skip npm build`).option("-o, --open", `[boolean] open ide`).action(async (root, options) => {
103
110
  filterDuplicateOptions(options);
104
111
  const ctx = await createCompilerContext({
105
112
  cwd: root,
@@ -107,9 +114,12 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
107
114
  isDev: true
108
115
  });
109
116
  if (!options.skipNpm) {
110
- await ctx.buildNpm({ sourcemap: true });
117
+ await ctx.buildNpm(void 0, { sourcemap: true });
111
118
  }
112
119
  await ctx.build();
120
+ if (options.open) {
121
+ await openIde();
122
+ }
113
123
  });
114
124
  cli.command("build [root]", "build for production").option("--target <target>", `[string] transpile target (default: 'modules')`).option("--outDir <dir>", `[string] output directory (default: dist)`).option(
115
125
  "--sourcemap [output]",
@@ -120,7 +130,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
120
130
  ).option(
121
131
  "--emptyOutDir",
122
132
  `[boolean] force empty outDir when it's outside of root`
123
- ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--skipNpm", `[boolean] if skip npm build`).action(async (root, options) => {
133
+ ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--skipNpm", `[boolean] if skip npm build`).option("-o, --open", `[boolean] open ide`).action(async (root, options) => {
124
134
  filterDuplicateOptions(options);
125
135
  const ctx = await createCompilerContext({
126
136
  cwd: root,
@@ -130,6 +140,9 @@ cli.command("build [root]", "build for production").option("--target <target>",
130
140
  if (!options.skipNpm) {
131
141
  await ctx.buildNpm();
132
142
  }
143
+ if (options.open) {
144
+ await openIde();
145
+ }
133
146
  });
134
147
  cli.command("init").action(async () => {
135
148
  try {
@@ -141,11 +154,7 @@ cli.command("init").action(async () => {
141
154
  }
142
155
  });
143
156
  cli.command("open").action(async () => {
144
- try {
145
- await parse(["open", "-p"]);
146
- } catch (error) {
147
- logger_default.error(error);
148
- }
157
+ await openIde();
149
158
  });
150
159
  cli.command("npm").alias("build:npm").alias("build-npm").action(async () => {
151
160
  try {
@@ -131,4 +131,4 @@ declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
131
131
  declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
132
132
  declare function defineConfig(config: UserConfigExport): UserConfigExport;
133
133
 
134
- export { type AppEntry as A, type CompilerContextOptions as C, type Entry as E, type MpPlatform as M, type ProjectConfig as P, type ResolvedAlias as R, type SubPackageMetaValue as S, defineConfig as d };
134
+ export { type AppEntry as A, type CompilerContextOptions as C, type Entry as E, type MpPlatform as M, type ProjectConfig as P, type ResolvedAlias as R, type SubPackageMetaValue as S, type SubPackage as a, defineConfig as d };
@@ -131,4 +131,4 @@ declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
131
131
  declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
132
132
  declare function defineConfig(config: UserConfigExport): UserConfigExport;
133
133
 
134
- export { type AppEntry as A, type CompilerContextOptions as C, type Entry as E, type MpPlatform as M, type ProjectConfig as P, type ResolvedAlias as R, type SubPackageMetaValue as S, defineConfig as d };
134
+ export { type AppEntry as A, type CompilerContextOptions as C, type Entry as E, type MpPlatform as M, type ProjectConfig as P, type ResolvedAlias as R, type SubPackageMetaValue as S, type SubPackage as a, defineConfig as d };
package/dist/config.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { UserConfig, UserConfigExport, UserConfigFnObject } from 'vite';
2
- export { d as defineConfig } from './config-BeFRKLxC.cjs';
2
+ export { d as defineConfig } from './config-DMYZNPWv.cjs';
3
3
  import '@weapp-core/schematics';
4
4
  import 'pkg-types';
5
5
  import 'tsup';
package/dist/config.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { UserConfig, UserConfigExport, UserConfigFnObject } from 'vite';
2
- export { d as defineConfig } from './config-BeFRKLxC.js';
2
+ export { d as defineConfig } from './config-DMYZNPWv.js';
3
3
  import '@weapp-core/schematics';
4
4
  import 'pkg-types';
5
5
  import 'tsup';
package/dist/index.cjs CHANGED
@@ -35,7 +35,7 @@ __export(src_exports, {
35
35
  });
36
36
  module.exports = __toCommonJS(src_exports);
37
37
 
38
- // ../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.7.40_jiti@2.3.1_postcss@8.4.47_tsx@4.19.2_typescript@5.6.3_yaml@2.6.0/node_modules/tsup/assets/cjs_shims.js
38
+ // ../../node_modules/.pnpm/tsup@8.3.5_@swc+core@1.7.42_jiti@2.3.1_postcss@8.4.47_tsx@4.19.2_typescript@5.6.3_yaml@2.6.0/node_modules/tsup/assets/cjs_shims.js
39
39
  var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
40
40
  var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
41
41
 
@@ -570,6 +570,9 @@ var CompilerContext = class {
570
570
  aliasEntries;
571
571
  platform;
572
572
  outputExtensions;
573
+ /**
574
+ * 不修改 ctx
575
+ */
573
576
  readCommentJson;
574
577
  /**
575
578
  * esbuild 定义的环境变量
@@ -814,7 +817,7 @@ var CompilerContext = class {
814
817
  // miniprogram_dist
815
818
  // miniprogram
816
819
  // https://developers.weixin.qq.com/miniprogram/dev/devtools/npm.html#%E8%87%AA%E5%AE%9A%E4%B9%89%E7%BB%84%E4%BB%B6%E7%9B%B8%E5%85%B3%E7%A4%BA%E4%BE%8B
817
- async buildNpm(options) {
820
+ async buildNpm(subPackage, options) {
818
821
  debug2?.("buildNpm start");
819
822
  const { build: tsupBuild } = await import("tsup");
820
823
  const isDependenciesCacheOutdate = await this.checkDependenciesCacheOutdate();
@@ -833,7 +836,7 @@ var CompilerContext = class {
833
836
  const packageJsonPath = import_pathe5.default.resolve(this.cwd, relation.packageJsonPath);
834
837
  if (await import_fs_extra5.default.exists(packageJsonPath)) {
835
838
  const pkgJson = await import_fs_extra5.default.readJson(packageJsonPath);
836
- const outDir = import_pathe5.default.resolve(this.cwd, relation.miniprogramNpmDistDir, "miniprogram_npm");
839
+ const outDir = import_pathe5.default.resolve(this.cwd, relation.miniprogramNpmDistDir, subPackage?.root ?? "", "miniprogram_npm");
837
840
  if (pkgJson.dependencies) {
838
841
  const dependencies = Object.keys(pkgJson.dependencies);
839
842
  if (dependencies.length > 0) {
@@ -895,7 +898,12 @@ var CompilerContext = class {
895
898
  await this.writeDependenciesCache();
896
899
  debug2?.("buildNpm end");
897
900
  }
898
- async usingComponentsHandler(entry, relDir) {
901
+ /**
902
+ * @deps [this.scanComponentEntry]
903
+ * @param entry
904
+ * @param relDir
905
+ */
906
+ async usingComponentsHandler(entry, relDir, subPackageMeta) {
899
907
  const { usingComponents } = entry.json;
900
908
  if (usingComponents) {
901
909
  for (const [, componentUrl] of Object.entries(usingComponents)) {
@@ -906,10 +914,10 @@ var CompilerContext = class {
906
914
  if (tokens[0] && (0, import_shared3.isObject)(this.packageJson.dependencies) && Reflect.has(this.packageJson.dependencies, tokens[0])) {
907
915
  continue;
908
916
  } else if (tokens[0] === "") {
909
- await this.scanComponentEntry(componentUrl.substring(1), import_pathe5.default.resolve(this.cwd, this.srcRoot));
917
+ await this.scanComponentEntry(componentUrl.substring(1), import_pathe5.default.resolve(this.cwd, this.srcRoot), subPackageMeta);
910
918
  } else {
911
919
  const importee = resolveImportee(componentUrl, entry, this.aliasEntries);
912
- await this.scanComponentEntry(importee, relDir);
920
+ await this.scanComponentEntry(importee, relDir, subPackageMeta);
913
921
  }
914
922
  }
915
923
  }
@@ -919,6 +927,17 @@ var CompilerContext = class {
919
927
  this.entries.length = 0;
920
928
  this.subPackageMeta = {};
921
929
  }
930
+ // fork() {
931
+ // return new CompilerContext({
932
+ // cwd: this.cwd,
933
+ // inlineConfig: this.inlineConfig,
934
+ // isDev: this.isDev,
935
+ // mode: this.mode,
936
+ // packageJson: this.packageJson,
937
+ // platform: this.platform,
938
+ // projectConfig: this.projectConfig,
939
+ // })
940
+ // }
922
941
  async scanAppEntry() {
923
942
  debug2?.("scanAppEntry start");
924
943
  this.resetEntries();
@@ -970,14 +989,13 @@ var CompilerContext = class {
970
989
  entriesSet: /* @__PURE__ */ new Set(),
971
990
  subPackage: sub
972
991
  };
973
- const scanComponentEntry = this.scanComponentEntry.bind(meta);
974
992
  if (Array.isArray(sub.pages)) {
975
993
  for (const page of sub.pages) {
976
- await scanComponentEntry(import_pathe5.default.join(sub.root, page), appDirname);
994
+ await this.scanComponentEntry(import_pathe5.default.join(sub.root, page), appDirname, meta);
977
995
  }
978
996
  }
979
997
  if (sub.entry) {
980
- await scanComponentEntry(import_pathe5.default.join(sub.root, sub.entry), appDirname);
998
+ await this.scanComponentEntry(import_pathe5.default.join(sub.root, sub.entry), appDirname, meta);
981
999
  }
982
1000
  this.subPackageMeta[sub.root] = meta;
983
1001
  } else {
@@ -1006,16 +1024,20 @@ var CompilerContext = class {
1006
1024
  // pages
1007
1025
  // https://developers.weixin.qq.com/miniprogram/dev/framework/structure.html
1008
1026
  // 页面可以没有 JSON
1009
- async scanComponentEntry(componentEntry, dirname) {
1027
+ async scanComponentEntry(componentEntry, dirname, subPackageMeta) {
1028
+ const meta = subPackageMeta ?? {
1029
+ entriesSet: this.entriesSet,
1030
+ entries: this.entries
1031
+ };
1010
1032
  debug2?.("scanComponentEntry start", componentEntry);
1011
1033
  const baseName = (0, import_shared3.removeExtension)(import_pathe5.default.resolve(dirname, componentEntry));
1012
1034
  const jsEntry = await findJsEntry(baseName);
1013
1035
  const partialEntry = {
1014
1036
  path: jsEntry
1015
1037
  };
1016
- if (jsEntry && !this.entriesSet.has(jsEntry)) {
1017
- this.entriesSet.add(jsEntry);
1018
- this.entries.push(partialEntry);
1038
+ if (jsEntry && !meta.entriesSet.has(jsEntry)) {
1039
+ meta.entriesSet.add(jsEntry);
1040
+ meta.entries.push(partialEntry);
1019
1041
  }
1020
1042
  const configFile = await findJsonEntry(baseName);
1021
1043
  if (configFile) {
@@ -1029,7 +1051,7 @@ var CompilerContext = class {
1029
1051
  partialEntry.jsonPath = jsonFragment.jsonPath;
1030
1052
  }
1031
1053
  if ((0, import_shared3.isObject)(config)) {
1032
- await this.usingComponentsHandler(jsonFragment, import_pathe5.default.dirname(configFile));
1054
+ await this.usingComponentsHandler(jsonFragment, import_pathe5.default.dirname(configFile), subPackageMeta);
1033
1055
  }
1034
1056
  }
1035
1057
  debug2?.("scanComponentEntry end", componentEntry);
@@ -1054,6 +1076,7 @@ var CompilerContext = class {
1054
1076
  }
1055
1077
  }
1056
1078
  });
1079
+ await this.buildNpm(meta.subPackage);
1057
1080
  const output = await (0, import_vite2.build)(
1058
1081
  inlineConfig
1059
1082
  );
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PackageJson } from 'pkg-types';
2
2
  import { RollupWatcher, RollupOutput } 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 } from './config-BeFRKLxC.cjs';
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-DMYZNPWv.cjs';
4
4
  import { InlineConfig } from 'vite';
5
5
  import { Options } from 'tsup';
6
6
  import '@weapp-core/schematics';
@@ -32,6 +32,9 @@ declare class CompilerContext {
32
32
  aliasEntries: ResolvedAlias[];
33
33
  platform: MpPlatform;
34
34
  outputExtensions: OutputExtensions;
35
+ /**
36
+ * 不修改 ctx
37
+ */
35
38
  readCommentJson: (filepath: string) => Promise<any>;
36
39
  /**
37
40
  * esbuild 定义的环境变量
@@ -62,11 +65,16 @@ declare class CompilerContext {
62
65
  writeDependenciesCache(): Promise<void>;
63
66
  readDependenciesCache(): Promise<any>;
64
67
  checkDependenciesCacheOutdate(): Promise<boolean>;
65
- buildNpm(options?: Options): Promise<void>;
68
+ buildNpm(subPackage?: SubPackage, options?: Options): Promise<void>;
69
+ /**
70
+ * @deps [this.scanComponentEntry]
71
+ * @param entry
72
+ * @param relDir
73
+ */
66
74
  private usingComponentsHandler;
67
75
  resetEntries(): void;
68
76
  scanAppEntry(): Promise<AppEntry | undefined>;
69
- scanComponentEntry(componentEntry: string, dirname: string): Promise<void>;
77
+ scanComponentEntry(componentEntry: string, dirname: string, subPackageMeta?: SubPackageMetaValue): Promise<void>;
70
78
  setRollupWatcher(watcher: RollupWatcher, root?: string): void;
71
79
  buildSubPackage(): Promise<void>;
72
80
  }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PackageJson } from 'pkg-types';
2
2
  import { RollupWatcher, RollupOutput } 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 } from './config-BeFRKLxC.js';
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-DMYZNPWv.js';
4
4
  import { InlineConfig } from 'vite';
5
5
  import { Options } from 'tsup';
6
6
  import '@weapp-core/schematics';
@@ -32,6 +32,9 @@ declare class CompilerContext {
32
32
  aliasEntries: ResolvedAlias[];
33
33
  platform: MpPlatform;
34
34
  outputExtensions: OutputExtensions;
35
+ /**
36
+ * 不修改 ctx
37
+ */
35
38
  readCommentJson: (filepath: string) => Promise<any>;
36
39
  /**
37
40
  * esbuild 定义的环境变量
@@ -62,11 +65,16 @@ declare class CompilerContext {
62
65
  writeDependenciesCache(): Promise<void>;
63
66
  readDependenciesCache(): Promise<any>;
64
67
  checkDependenciesCacheOutdate(): Promise<boolean>;
65
- buildNpm(options?: Options): Promise<void>;
68
+ buildNpm(subPackage?: SubPackage, options?: Options): Promise<void>;
69
+ /**
70
+ * @deps [this.scanComponentEntry]
71
+ * @param entry
72
+ * @param relDir
73
+ */
66
74
  private usingComponentsHandler;
67
75
  resetEntries(): void;
68
76
  scanAppEntry(): Promise<AppEntry | undefined>;
69
- scanComponentEntry(componentEntry: string, dirname: string): Promise<void>;
77
+ scanComponentEntry(componentEntry: string, dirname: string, subPackageMeta?: SubPackageMetaValue): Promise<void>;
70
78
  setRollupWatcher(watcher: RollupWatcher, root?: string): void;
71
79
  buildSubPackage(): Promise<void>;
72
80
  }
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CompilerContext,
3
3
  createCompilerContext
4
- } from "./chunk-5PUUYFZM.mjs";
4
+ } from "./chunk-C7FRWINE.mjs";
5
5
  import "./chunk-444MQSSG.mjs";
6
6
  export {
7
7
  CompilerContext,
package/dist/json.d.cts CHANGED
@@ -3,7 +3,7 @@ export { App, Component, Page, Sitemap, Theme } from '@weapp-core/schematics';
3
3
  import { CompilerContext } from './index.cjs';
4
4
  import 'pkg-types';
5
5
  import 'rollup';
6
- import './config-BeFRKLxC.cjs';
6
+ import './config-DMYZNPWv.cjs';
7
7
  import 'vite';
8
8
  import 'tsup';
9
9
  import 'vite-tsconfig-paths';
package/dist/json.d.ts CHANGED
@@ -3,7 +3,7 @@ export { App, Component, Page, Sitemap, Theme } from '@weapp-core/schematics';
3
3
  import { CompilerContext } from './index.js';
4
4
  import 'pkg-types';
5
5
  import 'rollup';
6
- import './config-BeFRKLxC.js';
6
+ import './config-DMYZNPWv.js';
7
7
  import 'vite';
8
8
  import 'tsup';
9
9
  import 'vite-tsconfig-paths';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite",
3
3
  "type": "module",
4
- "version": "1.6.7",
4
+ "version": "1.6.8",
5
5
  "description": "weapp-vite 一个现代化的小程序打包工具",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -74,10 +74,10 @@
74
74
  "picomatch": "^4.0.2",
75
75
  "tsup": "^8.3.5",
76
76
  "vite-tsconfig-paths": "^5.0.1",
77
- "@weapp-core/init": "^1.1.6",
78
- "@weapp-core/shared": "^1.0.3",
79
- "@weapp-core/schematics": "^1.0.3",
77
+ "@weapp-core/schematics": "^1.0.4",
80
78
  "@weapp-core/logger": "^1.0.1",
79
+ "@weapp-core/shared": "^1.0.3",
80
+ "@weapp-core/init": "^1.1.6",
81
81
  "weapp-ide-cli": "^2.0.6"
82
82
  },
83
83
  "publishConfig": {
@@ -85,7 +85,7 @@
85
85
  "registry": "https://registry.npmjs.org"
86
86
  },
87
87
  "devDependencies": {
88
- "@babel/parser": "^7.26.1",
88
+ "@babel/parser": "^7.26.2",
89
89
  "@babel/traverse": "^7.25.9",
90
90
  "htmlparser2": "^9.1.0"
91
91
  },