weapp-vite 5.6.0 → 5.6.1

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkKE6RSOKXcjs = require('./chunk-KE6RSOKX.cjs');
5
+ var _chunk6JB3ELRAcjs = require('./chunk-6JB3ELRA.cjs');
6
6
 
7
7
 
8
8
  var _chunkWWFEREWVcjs = require('./chunk-WWFEREWV.cjs');
@@ -12,10 +12,10 @@ _chunkWWFEREWVcjs.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
- _chunkKE6RSOKXcjs.resetCompilerContext.call(void 0, key);
15
+ _chunk6JB3ELRAcjs.resetCompilerContext.call(void 0, key);
16
16
  }
17
- _chunkKE6RSOKXcjs.setActiveCompilerContextKey.call(void 0, key);
18
- const ctx = _chunkKE6RSOKXcjs.getCompilerContext.call(void 0, key);
17
+ _chunk6JB3ELRAcjs.setActiveCompilerContextKey.call(void 0, key);
18
+ const ctx = _chunk6JB3ELRAcjs.getCompilerContext.call(void 0, key);
19
19
  const { configService, scanService, autoRoutesService } = ctx;
20
20
  await configService.load(options);
21
21
  if (autoRoutesService) {
@@ -22963,6 +22963,8 @@ var watchedCssExts = new Set(supportedCssLangs.map((ext2) => `.${ext2}`));
22963
22963
  var configSuffixes = configExtensions.map((ext2) => `.${ext2}`);
22964
22964
  var sidecarSuffixes = [...configSuffixes, ...watchedCssExts];
22965
22965
  var watchLimitErrorCodes = /* @__PURE__ */ new Set(["EMFILE", "ENOSPC"]);
22966
+ var importProtocols = /^(?:https?:|data:|blob:|\/)/i;
22967
+ var cssImportRE = /@(import|wv-keep-import)\s+(?:url\()?['"]?([^'")\s]+)['"]?\)?/gi;
22966
22968
  function isWatchLimitError(error) {
22967
22969
  if (!error || typeof error !== "object") {
22968
22970
  return false;
@@ -22973,9 +22975,198 @@ function isWatchLimitError(error) {
22973
22975
  }
22974
22976
  return watchLimitErrorCodes.has(maybeError.code);
22975
22977
  }
22976
- async function invalidateEntryForSidecar(filePath) {
22978
+ function normalizePath2(p) {
22979
+ return path25.normalize(p);
22980
+ }
22981
+ function ensureCssGraph(ctx) {
22982
+ return ctx.runtimeState.css;
22983
+ }
22984
+ function cleanupImporterGraph(ctx, importer) {
22985
+ const graph = ensureCssGraph(ctx);
22986
+ const normalizedImporter = normalizePath2(importer);
22987
+ const existingDeps = graph.importerToDependencies.get(normalizedImporter);
22988
+ if (!existingDeps) {
22989
+ return;
22990
+ }
22991
+ graph.importerToDependencies.delete(normalizedImporter);
22992
+ for (const dep of existingDeps) {
22993
+ const importers = graph.dependencyToImporters.get(dep);
22994
+ if (!importers) {
22995
+ continue;
22996
+ }
22997
+ importers.delete(normalizedImporter);
22998
+ if (importers.size === 0) {
22999
+ graph.dependencyToImporters.delete(dep);
23000
+ }
23001
+ }
23002
+ }
23003
+ function registerCssImports(ctx, importer, dependencies) {
23004
+ const graph = ensureCssGraph(ctx);
23005
+ const normalizedImporter = normalizePath2(importer);
23006
+ const normalizedDeps = /* @__PURE__ */ new Set();
23007
+ for (const dependency of dependencies) {
23008
+ if (!dependency) {
23009
+ continue;
23010
+ }
23011
+ normalizedDeps.add(normalizePath2(dependency));
23012
+ }
23013
+ const previousDeps = graph.importerToDependencies.get(normalizedImporter) ?? /* @__PURE__ */ new Set();
23014
+ if (previousDeps.size) {
23015
+ for (const previous of previousDeps) {
23016
+ if (normalizedDeps.has(previous)) {
23017
+ continue;
23018
+ }
23019
+ const importers = graph.dependencyToImporters.get(previous);
23020
+ if (!importers) {
23021
+ continue;
23022
+ }
23023
+ importers.delete(normalizedImporter);
23024
+ if (importers.size === 0) {
23025
+ graph.dependencyToImporters.delete(previous);
23026
+ }
23027
+ }
23028
+ }
23029
+ graph.importerToDependencies.set(normalizedImporter, normalizedDeps);
23030
+ for (const dependency of normalizedDeps) {
23031
+ let importers = graph.dependencyToImporters.get(dependency);
23032
+ if (!importers) {
23033
+ importers = /* @__PURE__ */ new Set();
23034
+ graph.dependencyToImporters.set(dependency, importers);
23035
+ }
23036
+ importers.add(normalizedImporter);
23037
+ }
23038
+ }
23039
+ async function extractCssImportDependencies(ctx, importer) {
23040
+ try {
23041
+ const stats = await fs15.promises.stat(importer);
23042
+ if (!stats.isFile()) {
23043
+ cleanupImporterGraph(ctx, importer);
23044
+ return;
23045
+ }
23046
+ } catch {
23047
+ cleanupImporterGraph(ctx, importer);
23048
+ return;
23049
+ }
23050
+ let cssContent;
23051
+ try {
23052
+ cssContent = await fs15.promises.readFile(importer, "utf8");
23053
+ } catch {
23054
+ cleanupImporterGraph(ctx, importer);
23055
+ return;
23056
+ }
23057
+ cssImportRE.lastIndex = 0;
23058
+ const dependencies = /* @__PURE__ */ new Set();
23059
+ const dir = path25.dirname(importer);
23060
+ while (true) {
23061
+ const match2 = cssImportRE.exec(cssContent);
23062
+ if (!match2) {
23063
+ break;
23064
+ }
23065
+ const rawSpecifier = match2[2]?.trim();
23066
+ if (!rawSpecifier) {
23067
+ continue;
23068
+ }
23069
+ if (importProtocols.test(rawSpecifier)) {
23070
+ if (rawSpecifier.startsWith("/")) {
23071
+ const absolute = path25.resolve(ctx.configService.absoluteSrcRoot, rawSpecifier.slice(1));
23072
+ dependencies.add(absolute);
23073
+ const ext3 = path25.extname(absolute);
23074
+ if (ext3) {
23075
+ dependencies.add(absolute.slice(0, -ext3.length));
23076
+ }
23077
+ }
23078
+ continue;
23079
+ }
23080
+ let specifier = rawSpecifier;
23081
+ if (specifier.startsWith("@/")) {
23082
+ specifier = path25.join(ctx.configService.absoluteSrcRoot, specifier.slice(2));
23083
+ } else if (specifier === "@") {
23084
+ specifier = ctx.configService.absoluteSrcRoot;
23085
+ }
23086
+ if (specifier.startsWith("~")) {
23087
+ specifier = specifier.slice(1);
23088
+ }
23089
+ const cleaned = specifier.replace(/[?#].*$/, "");
23090
+ const resolved = path25.resolve(dir, cleaned);
23091
+ dependencies.add(resolved);
23092
+ const ext2 = path25.extname(resolved);
23093
+ if (!ext2) {
23094
+ dependencies.add(resolved);
23095
+ } else {
23096
+ dependencies.add(resolved.slice(0, -ext2.length));
23097
+ }
23098
+ }
23099
+ registerCssImports(ctx, importer, dependencies);
23100
+ }
23101
+ function collectCssImporters(ctx, dependency) {
23102
+ const graph = ensureCssGraph(ctx);
23103
+ const normalizedDependency = normalizePath2(dependency);
23104
+ const matches2 = /* @__PURE__ */ new Set();
23105
+ const direct = graph.dependencyToImporters.get(normalizedDependency);
23106
+ if (direct) {
23107
+ for (const importer of direct) {
23108
+ matches2.add(importer);
23109
+ }
23110
+ }
23111
+ const ext2 = path25.extname(normalizedDependency);
23112
+ if (ext2) {
23113
+ const base = normalizedDependency.slice(0, -ext2.length);
23114
+ const baseMatches = graph.dependencyToImporters.get(base);
23115
+ if (baseMatches) {
23116
+ for (const importer of baseMatches) {
23117
+ matches2.add(importer);
23118
+ }
23119
+ }
23120
+ }
23121
+ return matches2;
23122
+ }
23123
+ async function resolveScriptForCss(cache2, basePath) {
23124
+ const cached = cache2.get(basePath);
23125
+ if (cached !== void 0) {
23126
+ return cached;
23127
+ }
23128
+ const result = await findJsEntry(basePath);
23129
+ const scriptPath = result.path;
23130
+ cache2.set(basePath, scriptPath);
23131
+ return scriptPath;
23132
+ }
23133
+ async function collectAffectedScriptsAndImporters(ctx, startCssFile) {
23134
+ const queue = [normalizePath2(startCssFile)];
23135
+ const visitedCss = /* @__PURE__ */ new Set();
23136
+ const affectedImporters = /* @__PURE__ */ new Set();
23137
+ const affectedScripts = /* @__PURE__ */ new Set();
23138
+ const scriptCache = /* @__PURE__ */ new Map();
23139
+ while (queue.length) {
23140
+ const current2 = queue.shift();
23141
+ if (visitedCss.has(current2)) {
23142
+ continue;
23143
+ }
23144
+ visitedCss.add(current2);
23145
+ const ext2 = path25.extname(current2);
23146
+ if (ext2) {
23147
+ const base = current2.slice(0, -ext2.length);
23148
+ const script = await resolveScriptForCss(scriptCache, base);
23149
+ if (script) {
23150
+ affectedScripts.add(script);
23151
+ }
23152
+ }
23153
+ const importers = collectCssImporters(ctx, current2);
23154
+ for (const importer of importers) {
23155
+ if (!visitedCss.has(importer)) {
23156
+ queue.push(importer);
23157
+ }
23158
+ affectedImporters.add(importer);
23159
+ }
23160
+ }
23161
+ return {
23162
+ importers: affectedImporters,
23163
+ scripts: affectedScripts
23164
+ };
23165
+ }
23166
+ async function invalidateEntryForSidecar(ctx, filePath, event = "update") {
22977
23167
  const configSuffix = configSuffixes.find((suffix) => filePath.endsWith(suffix));
22978
23168
  const ext2 = path25.extname(filePath);
23169
+ const normalizedPath = normalizePath2(filePath);
22979
23170
  let scriptBasePath;
22980
23171
  if (configSuffix) {
22981
23172
  scriptBasePath = filePath.slice(0, -configSuffix.length);
@@ -22985,11 +23176,51 @@ async function invalidateEntryForSidecar(filePath) {
22985
23176
  if (!scriptBasePath) {
22986
23177
  return;
22987
23178
  }
22988
- const { path: scriptPath } = await findJsEntry(scriptBasePath);
22989
- if (!scriptPath) {
23179
+ const touchedTargets = /* @__PURE__ */ new Set();
23180
+ const touchedScripts = /* @__PURE__ */ new Set();
23181
+ const primaryScript = await findJsEntry(scriptBasePath);
23182
+ if (primaryScript.path) {
23183
+ touchedScripts.add(primaryScript.path);
23184
+ }
23185
+ if (!primaryScript.path && ext2 && watchedCssExts.has(ext2)) {
23186
+ const { importers, scripts } = await collectAffectedScriptsAndImporters(ctx, normalizedPath);
23187
+ for (const importer of importers) {
23188
+ touchedTargets.add(importer);
23189
+ }
23190
+ for (const script of scripts) {
23191
+ touchedScripts.add(script);
23192
+ }
23193
+ }
23194
+ const isCssSidecar = Boolean(ext2 && watchedCssExts.has(ext2));
23195
+ const configService = ctx.configService;
23196
+ const relativeSource = configService.relativeCwd(normalizedPath);
23197
+ for (const target of touchedTargets) {
23198
+ try {
23199
+ await touch(target);
23200
+ } catch {
23201
+ }
23202
+ }
23203
+ for (const script of touchedScripts) {
23204
+ try {
23205
+ await touch(script);
23206
+ } catch {
23207
+ }
23208
+ }
23209
+ if (!touchedTargets.size && !touchedScripts.size) {
23210
+ if (event === "create" && isCssSidecar) {
23211
+ logger_default.info(`[sidecar:${event}] ${relativeSource} \u65B0\u589E\uFF0C\u4F46\u672A\u627E\u5230\u5F15\u7528\u65B9\uFF0C\u7B49\u5F85\u540E\u7EED\u5173\u8054`);
23212
+ }
22990
23213
  return;
22991
23214
  }
22992
- await touch(scriptPath);
23215
+ const touchedList = [];
23216
+ for (const target of touchedTargets) {
23217
+ touchedList.push(configService.relativeCwd(target));
23218
+ }
23219
+ for (const script of touchedScripts) {
23220
+ touchedList.push(configService.relativeCwd(script));
23221
+ }
23222
+ const uniqueTouched = Array.from(new Set(touchedList));
23223
+ logger_default.success(`[sidecar:${event}] ${relativeSource} -> \u5237\u65B0 ${uniqueTouched.join(", ")}`);
22993
23224
  }
22994
23225
  function ensureSidecarWatcher(ctx, rootDir) {
22995
23226
  if (!ctx.configService.isDev || !rootDir || process6.env.VITEST === "true" || process6.env.NODE_ENV === "test") {
@@ -23003,32 +23234,51 @@ function ensureSidecarWatcher(ctx, rootDir) {
23003
23234
  if (sidecarWatcherMap.has(absRoot)) {
23004
23235
  return;
23005
23236
  }
23006
- const handleSidecarChange = (filePath) => {
23237
+ let isReady = false;
23238
+ const handleSidecarChange = (event, filePath, ready) => {
23007
23239
  if (!isSidecarFile(filePath)) {
23008
23240
  return;
23009
23241
  }
23010
- void invalidateEntryForSidecar(filePath);
23242
+ const ext2 = path25.extname(filePath);
23243
+ const isCssFile = Boolean(ext2 && watchedCssExts.has(ext2));
23244
+ if (isCssFile && (event === "create" || event === "update")) {
23245
+ void extractCssImportDependencies(ctx, filePath);
23246
+ }
23247
+ const shouldInvalidate = event === "create" && ready || event === "delete";
23248
+ if (shouldInvalidate) {
23249
+ void (async () => {
23250
+ await invalidateEntryForSidecar(ctx, filePath, event);
23251
+ if (isCssFile && event === "delete") {
23252
+ cleanupImporterGraph(ctx, filePath);
23253
+ }
23254
+ })();
23255
+ return;
23256
+ }
23257
+ if (isCssFile && event === "delete") {
23258
+ cleanupImporterGraph(ctx, filePath);
23259
+ }
23011
23260
  };
23012
23261
  const patterns = [
23013
23262
  ...configExtensions.map((ext2) => path25.join(absRoot, `**/*.${ext2}`)),
23014
23263
  ...supportedCssLangs.map((ext2) => path25.join(absRoot, `**/*.${ext2}`))
23015
23264
  ];
23016
23265
  const watcher = esm_default.watch(patterns, {
23017
- ignoreInitial: true,
23266
+ ignoreInitial: false,
23018
23267
  persistent: true,
23019
23268
  awaitWriteFinish: {
23020
23269
  stabilityThreshold: 100,
23021
23270
  pollInterval: 20
23022
23271
  }
23023
23272
  });
23024
- const forwardChange = (input) => {
23273
+ const forwardChange = (event, input) => {
23025
23274
  if (!input) {
23026
23275
  return;
23027
23276
  }
23028
- handleSidecarChange(path25.normalize(input));
23277
+ handleSidecarChange(event, path25.normalize(input), isReady);
23029
23278
  };
23030
- watcher.on("add", forwardChange);
23031
- watcher.on("unlink", forwardChange);
23279
+ watcher.on("add", (path36) => forwardChange("create", path36));
23280
+ watcher.on("change", (path36) => forwardChange("update", path36));
23281
+ watcher.on("unlink", (path36) => forwardChange("delete", path36));
23032
23282
  watcher.on("raw", (eventName, rawPath, details) => {
23033
23283
  if (eventName !== "rename") {
23034
23284
  return;
@@ -23039,7 +23289,10 @@ function ensureSidecarWatcher(ctx, rootDir) {
23039
23289
  }
23040
23290
  const baseDir = typeof details === "object" && details && "watchedPath" in details ? details.watchedPath ?? absRoot : absRoot;
23041
23291
  const resolved = path25.isAbsolute(candidate) ? candidate : path25.resolve(baseDir, candidate);
23042
- forwardChange(resolved);
23292
+ forwardChange("create", resolved);
23293
+ });
23294
+ watcher.on("ready", () => {
23295
+ isReady = true;
23043
23296
  });
23044
23297
  watcher.on("error", (error) => {
23045
23298
  if (!isWatchLimitError(error)) {
@@ -23426,7 +23679,7 @@ function createCoreLifecyclePlugin(state) {
23426
23679
  let handledByIndependentWatcher = false;
23427
23680
  let independentMeta;
23428
23681
  if (change.event === "create" || change.event === "delete") {
23429
- await invalidateEntryForSidecar(id);
23682
+ await invalidateEntryForSidecar(ctx, id, change.event);
23430
23683
  }
23431
23684
  if (!subPackageMeta) {
23432
23685
  if (relativeSrc === "app.json" || relativeCwd === "project.config.json" || relativeCwd === "project.private.config.json") {
@@ -26037,6 +26290,10 @@ function createRuntimeState() {
26037
26290
  json: {
26038
26291
  cache: new FileCache()
26039
26292
  },
26293
+ css: {
26294
+ importerToDependencies: /* @__PURE__ */ new Map(),
26295
+ dependencyToImporters: /* @__PURE__ */ new Map()
26296
+ },
26040
26297
  watcher: {
26041
26298
  rollupWatcherMap: /* @__PURE__ */ new Map(),
26042
26299
  sidecarWatcherMap: /* @__PURE__ */ new Map()
package/dist/cli.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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 _chunk2Q7K5AR4cjs = require('./chunk-2Q7K5AR4.cjs');
3
+ var _chunkBJJOLDPKcjs = require('./chunk-BJJOLDPK.cjs');
4
4
 
5
5
 
6
6
 
@@ -9,7 +9,7 @@ var _chunk2Q7K5AR4cjs = require('./chunk-2Q7K5AR4.cjs');
9
9
 
10
10
 
11
11
 
12
- var _chunkKE6RSOKXcjs = require('./chunk-KE6RSOKX.cjs');
12
+ var _chunk6JB3ELRAcjs = require('./chunk-6JB3ELRA.cjs');
13
13
 
14
14
 
15
15
  var _chunkWWFEREWVcjs = require('./chunk-WWFEREWV.cjs');
@@ -817,7 +817,7 @@ async function generate(options) {
817
817
  for (const { code, fileName: fileName2 } of files) {
818
818
  if (code !== void 0) {
819
819
  await _fsextra2.default.outputFile(_pathe2.default.resolve(basepath, fileName2), code, "utf8");
820
- _chunkKE6RSOKXcjs.logger_default.success(`${composePath(outDir, fileName2)} \u521B\u5EFA\u6210\u529F\uFF01`);
820
+ _chunk6JB3ELRAcjs.logger_default.success(`${composePath(outDir, fileName2)} \u521B\u5EFA\u6210\u529F\uFF01`);
821
821
  }
822
822
  }
823
823
  }
@@ -855,7 +855,7 @@ async function readTemplateFile(templatePath, context) {
855
855
  // src/cli.ts
856
856
  var cli = cac("weapp-vite");
857
857
  try {
858
- _chunkKE6RSOKXcjs.checkRuntime.call(void 0, {
858
+ _chunk6JB3ELRAcjs.checkRuntime.call(void 0, {
859
859
  bun: "0.0.0",
860
860
  deno: "0.0.0",
861
861
  node: "20.19.0"
@@ -873,7 +873,7 @@ async function loadConfig(configFile) {
873
873
  mode: "development"
874
874
  };
875
875
  const loaded = await _vite.loadConfigFromFile.call(void 0, configEnv, resolvedConfigFile, cwd);
876
- const weappConfigFilePath = await _chunkKE6RSOKXcjs.resolveWeappConfigFile.call(void 0, {
876
+ const weappConfigFilePath = await _chunk6JB3ELRAcjs.resolveWeappConfigFile.call(void 0, {
877
877
  root: cwd,
878
878
  specified: resolvedConfigFile
879
879
  });
@@ -921,15 +921,15 @@ function logBuildAppFinish(configService, webServer, options = {}) {
921
921
  const urls = webServer.resolvedUrls;
922
922
  const candidates = urls ? [..._nullishCoalesce(urls.local, () => ( [])), ..._nullishCoalesce(urls.network, () => ( []))] : [];
923
923
  if (candidates.length > 0) {
924
- _chunkKE6RSOKXcjs.logger_default.success("Web \u8FD0\u884C\u65F6\u5DF2\u542F\u52A8\uFF0C\u6D4F\u89C8\u5668\u8BBF\u95EE\uFF1A");
924
+ _chunk6JB3ELRAcjs.logger_default.success("Web \u8FD0\u884C\u65F6\u5DF2\u542F\u52A8\uFF0C\u6D4F\u89C8\u5668\u8BBF\u95EE\uFF1A");
925
925
  for (const url of candidates) {
926
- _chunkKE6RSOKXcjs.logger_default.info(` \u279C ${url}`);
926
+ _chunk6JB3ELRAcjs.logger_default.info(` \u279C ${url}`);
927
927
  }
928
928
  } else {
929
- _chunkKE6RSOKXcjs.logger_default.success("Web \u8FD0\u884C\u65F6\u5DF2\u542F\u52A8");
929
+ _chunk6JB3ELRAcjs.logger_default.success("Web \u8FD0\u884C\u65F6\u5DF2\u542F\u52A8");
930
930
  }
931
931
  } else {
932
- _chunkKE6RSOKXcjs.logger_default.success("Web \u8FD0\u884C\u65F6\u5DF2\u542F\u52A8");
932
+ _chunk6JB3ELRAcjs.logger_default.success("Web \u8FD0\u884C\u65F6\u5DF2\u542F\u52A8");
933
933
  }
934
934
  logBuildAppFinishOnlyShowOnce = true;
935
935
  return;
@@ -943,19 +943,19 @@ function logBuildAppFinish(configService, webServer, options = {}) {
943
943
  args: ["run", "open"]
944
944
  }));
945
945
  const devCommand = `${command} ${args.join(" ")}`;
946
- _chunkKE6RSOKXcjs.logger_default.success("\u5E94\u7528\u6784\u5EFA\u5B8C\u6210\uFF01\u9884\u89C8\u65B9\u5F0F ( `2` \u79CD\u9009\u5176\u4E00\u5373\u53EF)\uFF1A");
947
- _chunkKE6RSOKXcjs.logger_default.info(`\u6267\u884C \`${devCommand}\` \u53EF\u4EE5\u76F4\u63A5\u5728 \`\u5FAE\u4FE1\u5F00\u53D1\u8005\u5DE5\u5177\` \u91CC\u6253\u5F00\u5F53\u524D\u5E94\u7528`);
948
- _chunkKE6RSOKXcjs.logger_default.info("\u6216\u624B\u52A8\u6253\u5F00\u5FAE\u4FE1\u5F00\u53D1\u8005\u5DE5\u5177\uFF0C\u5BFC\u5165\u6839\u76EE\u5F55(`project.config.json` \u6587\u4EF6\u6240\u5728\u7684\u76EE\u5F55)\uFF0C\u5373\u53EF\u9884\u89C8\u6548\u679C");
946
+ _chunk6JB3ELRAcjs.logger_default.success("\u5E94\u7528\u6784\u5EFA\u5B8C\u6210\uFF01\u9884\u89C8\u65B9\u5F0F ( `2` \u79CD\u9009\u5176\u4E00\u5373\u53EF)\uFF1A");
947
+ _chunk6JB3ELRAcjs.logger_default.info(`\u6267\u884C \`${devCommand}\` \u53EF\u4EE5\u76F4\u63A5\u5728 \`\u5FAE\u4FE1\u5F00\u53D1\u8005\u5DE5\u5177\` \u91CC\u6253\u5F00\u5F53\u524D\u5E94\u7528`);
948
+ _chunk6JB3ELRAcjs.logger_default.info("\u6216\u624B\u52A8\u6253\u5F00\u5FAE\u4FE1\u5F00\u53D1\u8005\u5DE5\u5177\uFF0C\u5BFC\u5165\u6839\u76EE\u5F55(`project.config.json` \u6587\u4EF6\u6240\u5728\u7684\u76EE\u5F55)\uFF0C\u5373\u53EF\u9884\u89C8\u6548\u679C");
949
949
  if (!skipWeb && webServer) {
950
950
  const urls = webServer.resolvedUrls;
951
951
  const candidates = urls ? [..._nullishCoalesce(urls.local, () => ( [])), ..._nullishCoalesce(urls.network, () => ( []))] : [];
952
952
  if (candidates.length > 0) {
953
- _chunkKE6RSOKXcjs.logger_default.success("Web \u8FD0\u884C\u65F6\u5DF2\u542F\u52A8\uFF0C\u6D4F\u89C8\u5668\u8BBF\u95EE\uFF1A");
953
+ _chunk6JB3ELRAcjs.logger_default.success("Web \u8FD0\u884C\u65F6\u5DF2\u542F\u52A8\uFF0C\u6D4F\u89C8\u5668\u8BBF\u95EE\uFF1A");
954
954
  for (const url of candidates) {
955
- _chunkKE6RSOKXcjs.logger_default.info(` \u279C ${url}`);
955
+ _chunk6JB3ELRAcjs.logger_default.info(` \u279C ${url}`);
956
956
  }
957
957
  } else {
958
- _chunkKE6RSOKXcjs.logger_default.success("Web \u8FD0\u884C\u65F6\u5DF2\u542F\u52A8");
958
+ _chunk6JB3ELRAcjs.logger_default.success("Web \u8FD0\u884C\u65F6\u5DF2\u542F\u52A8");
959
959
  }
960
960
  }
961
961
  logBuildAppFinishOnlyShowOnce = true;
@@ -985,11 +985,11 @@ async function openIde() {
985
985
  try {
986
986
  await _weappidecli.parse.call(void 0, ["open", "-p"]);
987
987
  } catch (error) {
988
- _chunkKE6RSOKXcjs.logger_default.error(error);
988
+ _chunk6JB3ELRAcjs.logger_default.error(error);
989
989
  }
990
990
  }
991
991
  function logRuntimeTarget(targets) {
992
- _chunkKE6RSOKXcjs.logger_default.info(`\u76EE\u6807\u5E73\u53F0\uFF1A${targets.label}`);
992
+ _chunk6JB3ELRAcjs.logger_default.info(`\u76EE\u6807\u5E73\u53F0\uFF1A${targets.label}`);
993
993
  }
994
994
  function resolveRuntimeTargets(options) {
995
995
  const rawPlatform = typeof options.platform === "string" ? options.platform : typeof options.p === "string" ? options.p : void 0;
@@ -997,17 +997,17 @@ function resolveRuntimeTargets(options) {
997
997
  return {
998
998
  runMini: true,
999
999
  runWeb: false,
1000
- mpPlatform: _chunkKE6RSOKXcjs.DEFAULT_MP_PLATFORM,
1001
- label: _chunkKE6RSOKXcjs.DEFAULT_MP_PLATFORM
1000
+ mpPlatform: _chunk6JB3ELRAcjs.DEFAULT_MP_PLATFORM,
1001
+ label: _chunk6JB3ELRAcjs.DEFAULT_MP_PLATFORM
1002
1002
  };
1003
1003
  }
1004
- const normalized = _chunkKE6RSOKXcjs.normalizeMiniPlatform.call(void 0, rawPlatform);
1004
+ const normalized = _chunk6JB3ELRAcjs.normalizeMiniPlatform.call(void 0, rawPlatform);
1005
1005
  if (!normalized) {
1006
1006
  return {
1007
1007
  runMini: true,
1008
1008
  runWeb: false,
1009
- mpPlatform: _chunkKE6RSOKXcjs.DEFAULT_MP_PLATFORM,
1010
- label: _chunkKE6RSOKXcjs.DEFAULT_MP_PLATFORM
1009
+ mpPlatform: _chunk6JB3ELRAcjs.DEFAULT_MP_PLATFORM,
1010
+ label: _chunk6JB3ELRAcjs.DEFAULT_MP_PLATFORM
1011
1011
  };
1012
1012
  }
1013
1013
  if (normalized === "h5" || normalized === "web") {
@@ -1018,7 +1018,7 @@ function resolveRuntimeTargets(options) {
1018
1018
  label: normalized === "h5" ? "h5" : "web"
1019
1019
  };
1020
1020
  }
1021
- const mpPlatform = _chunkKE6RSOKXcjs.resolveMiniPlatform.call(void 0, normalized);
1021
+ const mpPlatform = _chunk6JB3ELRAcjs.resolveMiniPlatform.call(void 0, normalized);
1022
1022
  if (mpPlatform) {
1023
1023
  return {
1024
1024
  runMini: true,
@@ -1027,12 +1027,12 @@ function resolveRuntimeTargets(options) {
1027
1027
  label: mpPlatform
1028
1028
  };
1029
1029
  }
1030
- _chunkKE6RSOKXcjs.logger_default.warn(`\u672A\u8BC6\u522B\u7684\u5E73\u53F0 "${rawPlatform}"\uFF0C\u5DF2\u56DE\u9000\u5230 ${_chunkKE6RSOKXcjs.DEFAULT_MP_PLATFORM}`);
1030
+ _chunk6JB3ELRAcjs.logger_default.warn(`\u672A\u8BC6\u522B\u7684\u5E73\u53F0 "${rawPlatform}"\uFF0C\u5DF2\u56DE\u9000\u5230 ${_chunk6JB3ELRAcjs.DEFAULT_MP_PLATFORM}`);
1031
1031
  return {
1032
1032
  runMini: true,
1033
1033
  runWeb: false,
1034
- mpPlatform: _chunkKE6RSOKXcjs.DEFAULT_MP_PLATFORM,
1035
- label: _chunkKE6RSOKXcjs.DEFAULT_MP_PLATFORM
1034
+ mpPlatform: _chunk6JB3ELRAcjs.DEFAULT_MP_PLATFORM,
1035
+ label: _chunk6JB3ELRAcjs.DEFAULT_MP_PLATFORM
1036
1036
  };
1037
1037
  }
1038
1038
  function createInlineConfig(mpPlatform) {
@@ -1054,7 +1054,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
1054
1054
  const targets = resolveRuntimeTargets(options);
1055
1055
  logRuntimeTarget(targets);
1056
1056
  const inlineConfig = createInlineConfig(targets.mpPlatform);
1057
- const { buildService, configService, webService } = await _chunk2Q7K5AR4cjs.createCompilerContext.call(void 0, {
1057
+ const { buildService, configService, webService } = await _chunkBJJOLDPKcjs.createCompilerContext.call(void 0, {
1058
1058
  cwd: root,
1059
1059
  mode: _nullishCoalesce(options.mode, () => ( "development")),
1060
1060
  isDev: true,
@@ -1069,7 +1069,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
1069
1069
  try {
1070
1070
  webServer = await _optionalChain([webService, 'optionalAccess', _15 => _15.startDevServer, 'call', _16 => _16()]);
1071
1071
  } catch (error) {
1072
- _chunkKE6RSOKXcjs.logger_default.error(error);
1072
+ _chunk6JB3ELRAcjs.logger_default.error(error);
1073
1073
  throw error;
1074
1074
  }
1075
1075
  }
@@ -1097,7 +1097,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
1097
1097
  const targets = resolveRuntimeTargets(options);
1098
1098
  logRuntimeTarget(targets);
1099
1099
  const inlineConfig = createInlineConfig(targets.mpPlatform);
1100
- const { buildService, configService, webService } = await _chunk2Q7K5AR4cjs.createCompilerContext.call(void 0, {
1100
+ const { buildService, configService, webService } = await _chunkBJJOLDPKcjs.createCompilerContext.call(void 0, {
1101
1101
  cwd: root,
1102
1102
  mode: _nullishCoalesce(options.mode, () => ( "production")),
1103
1103
  configFile,
@@ -1110,9 +1110,9 @@ cli.command("build [root]", "build for production").option("--target <target>",
1110
1110
  if (targets.runWeb && _optionalChain([webConfig, 'optionalAccess', _17 => _17.enabled])) {
1111
1111
  try {
1112
1112
  await _optionalChain([webService, 'optionalAccess', _18 => _18.build, 'call', _19 => _19()]);
1113
- _chunkKE6RSOKXcjs.logger_default.success(`Web \u6784\u5EFA\u5B8C\u6210\uFF0C\u8F93\u51FA\u76EE\u5F55\uFF1A${configService.relativeCwd(webConfig.outDir)}`);
1113
+ _chunk6JB3ELRAcjs.logger_default.success(`Web \u6784\u5EFA\u5B8C\u6210\uFF0C\u8F93\u51FA\u76EE\u5F55\uFF1A${configService.relativeCwd(webConfig.outDir)}`);
1114
1114
  } catch (error) {
1115
- _chunkKE6RSOKXcjs.logger_default.error(error);
1115
+ _chunk6JB3ELRAcjs.logger_default.error(error);
1116
1116
  throw error;
1117
1117
  }
1118
1118
  }
@@ -1129,7 +1129,7 @@ cli.command("init").action(async () => {
1129
1129
  command: "weapp-vite"
1130
1130
  });
1131
1131
  } catch (error) {
1132
- _chunkKE6RSOKXcjs.logger_default.error(error);
1132
+ _chunk6JB3ELRAcjs.logger_default.error(error);
1133
1133
  }
1134
1134
  });
1135
1135
  cli.command("open").action(async () => {
@@ -1139,7 +1139,7 @@ cli.command("npm").alias("build:npm").alias("build-npm").action(async () => {
1139
1139
  try {
1140
1140
  await _weappidecli.parse.call(void 0, ["build-npm", "-p"]);
1141
1141
  } catch (error) {
1142
- _chunkKE6RSOKXcjs.logger_default.error(error);
1142
+ _chunk6JB3ELRAcjs.logger_default.error(error);
1143
1143
  }
1144
1144
  });
1145
1145
  cli.command("g [filepath]", "generate component").alias("generate").option("-a, --app", "type app").option("-p, --page", "type app").option("-n, --name <name>", "filename").action(async (filepath, options) => {
@@ -1154,7 +1154,7 @@ cli.command("g [filepath]", "generate component").alias("generate").option("-a,
1154
1154
  fileName = "app";
1155
1155
  }
1156
1156
  if (filepath === void 0) {
1157
- _chunkKE6RSOKXcjs.logger_default.error("weapp-vite generate <outDir> \u547D\u4EE4\u5FC5\u987B\u4F20\u5165\u8DEF\u5F84\u53C2\u6570 outDir");
1157
+ _chunk6JB3ELRAcjs.logger_default.error("weapp-vite generate <outDir> \u547D\u4EE4\u5FC5\u987B\u4F20\u5165\u8DEF\u5F84\u53C2\u6570 outDir");
1158
1158
  return;
1159
1159
  }
1160
1160
  if (options.page) {
@@ -1174,5 +1174,5 @@ cli.command("create [outDir]", "create project").option("-t, --template <type>",
1174
1174
  await _init.createProject.call(void 0, outDir, options.template);
1175
1175
  });
1176
1176
  cli.help();
1177
- cli.version(_chunkKE6RSOKXcjs.VERSION);
1177
+ cli.version(_chunk6JB3ELRAcjs.VERSION);
1178
1178
  cli.parse();
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createCompilerContext
3
- } from "./chunk-K2MHCVVB.mjs";
3
+ } from "./chunk-3FNAS3G7.mjs";
4
4
  import {
5
5
  DEFAULT_MP_PLATFORM,
6
6
  VERSION,
@@ -9,7 +9,7 @@ import {
9
9
  normalizeMiniPlatform,
10
10
  resolveMiniPlatform,
11
11
  resolveWeappConfigFile
12
- } from "./chunk-2JQYFUSO.mjs";
12
+ } from "./chunk-LWQW2GQC.mjs";
13
13
  import {
14
14
  init_esm_shims
15
15
  } from "./chunk-C5ZVOPAJ.mjs";
@@ -712,6 +712,10 @@ interface RuntimeState {
712
712
  json: {
713
713
  cache: FileCache<any>;
714
714
  };
715
+ css: {
716
+ importerToDependencies: Map<string, Set<string>>;
717
+ dependencyToImporters: Map<string, Set<string>>;
718
+ };
715
719
  watcher: {
716
720
  rollupWatcherMap: Map<string, WatcherInstance>;
717
721
  sidecarWatcherMap: Map<string, SidecarWatcher>;
@@ -712,6 +712,10 @@ interface RuntimeState {
712
712
  json: {
713
713
  cache: FileCache<any>;
714
714
  };
715
+ css: {
716
+ importerToDependencies: Map<string, Set<string>>;
717
+ dependencyToImporters: Map<string, Set<string>>;
718
+ };
715
719
  watcher: {
716
720
  rollupWatcherMap: Map<string, WatcherInstance>;
717
721
  sidecarWatcherMap: Map<string, SidecarWatcher>;
package/dist/config.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { UserConfig, UserConfigExport, UserConfigFnObject } from 'vite';
2
- export { W as WeappViteConfig, a as defineAppJson, c as defineComponentJson, d as defineConfig, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-D7WbfUyN.cjs';
2
+ export { W as WeappViteConfig, a as defineAppJson, c as defineComponentJson, d as defineConfig, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-BuTlQpli.cjs';
3
3
  export { App, Component, Page, Sitemap, Theme } from '@weapp-core/schematics';
4
4
  import '@weapp-vite/web';
5
5
  import 'rolldown';
package/dist/config.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { UserConfig, UserConfigExport, UserConfigFnObject } from 'vite';
2
- export { W as WeappViteConfig, a as defineAppJson, c as defineComponentJson, d as defineConfig, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-BaoM7pt1.js';
2
+ export { W as WeappViteConfig, a as defineAppJson, c as defineComponentJson, d as defineConfig, b as definePageJson, e as defineSitemapJson, f as defineThemeJson } from './config-BB6bSUwe.js';
3
3
  export { App, Component, Page, Sitemap, Theme } from '@weapp-core/schematics';
4
4
  import '@weapp-vite/web';
5
5
  import 'rolldown';
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk2Q7K5AR4cjs = require('./chunk-2Q7K5AR4.cjs');
4
- require('./chunk-KE6RSOKX.cjs');
3
+ var _chunkBJJOLDPKcjs = require('./chunk-BJJOLDPK.cjs');
4
+ require('./chunk-6JB3ELRA.cjs');
5
5
 
6
6
 
7
7
  var _chunkACNTFTT2cjs = require('./chunk-ACNTFTT2.cjs');
@@ -27,4 +27,4 @@ _chunkWWFEREWVcjs.init_cjs_shims.call(void 0, );
27
27
 
28
28
 
29
29
 
30
- exports.createCompilerContext = _chunk2Q7K5AR4cjs.createCompilerContext; exports.defineAppJson = _chunkZIRGPJR5cjs.defineAppJson; exports.defineComponentJson = _chunkZIRGPJR5cjs.defineComponentJson; exports.defineConfig = _chunkACNTFTT2cjs.defineConfig; exports.definePageJson = _chunkZIRGPJR5cjs.definePageJson; exports.defineSitemapJson = _chunkZIRGPJR5cjs.defineSitemapJson; exports.defineThemeJson = _chunkZIRGPJR5cjs.defineThemeJson;
30
+ exports.createCompilerContext = _chunkBJJOLDPKcjs.createCompilerContext; exports.defineAppJson = _chunkZIRGPJR5cjs.defineAppJson; exports.defineComponentJson = _chunkZIRGPJR5cjs.defineComponentJson; exports.defineConfig = _chunkACNTFTT2cjs.defineConfig; exports.definePageJson = _chunkZIRGPJR5cjs.definePageJson; exports.defineSitemapJson = _chunkZIRGPJR5cjs.defineSitemapJson; exports.defineThemeJson = _chunkZIRGPJR5cjs.defineThemeJson;