weapp-vite 5.7.1 → 5.8.0

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.
Files changed (44) hide show
  1. package/dist/auto-import-components/resolvers.cjs +5 -5
  2. package/dist/auto-import-components/resolvers.mjs +1 -1
  3. package/dist/auto-routes.cjs +8 -8
  4. package/dist/auto-routes.mjs +4 -4
  5. package/dist/{chunk-GGLONZVQ.cjs → chunk-3AGZHFSV.cjs} +6 -6
  6. package/dist/{chunk-O4FBXXL3.mjs → chunk-DHQDH7RC.mjs} +353 -30
  7. package/dist/{chunk-ZMX6CFVX.mjs → chunk-ED4S52HS.mjs} +1 -1
  8. package/dist/{chunk-MQBCRXCD.cjs → chunk-JKNSNXOE.cjs} +2 -2
  9. package/dist/{chunk-T4OVF4GP.cjs → chunk-LZJAPKF7.cjs} +699 -376
  10. package/dist/chunk-O3YXI56P.cjs +6 -0
  11. package/dist/{chunk-A5DD7GKX.cjs → chunk-QKFYCWOC.cjs} +2 -2
  12. package/dist/{chunk-AXUA33LJ.mjs → chunk-R7M4HN7H.mjs} +2 -2
  13. package/dist/{chunk-N463WDOG.mjs → chunk-RJVVY5EI.mjs} +1 -1
  14. package/dist/{chunk-G6EZVEVT.cjs → chunk-RMHCFT5Q.cjs} +2 -2
  15. package/dist/{chunk-2SUWUB42.mjs → chunk-SSYIWHY2.mjs} +1 -1
  16. package/dist/{chunk-SSQGJIB5.mjs → chunk-TZWATIK3.mjs} +2 -2
  17. package/dist/cli.cjs +143 -99
  18. package/dist/cli.mjs +63 -19
  19. package/dist/{config-C-oMiscN.d.cts → config-07wfK_aU.d.cts} +17 -17
  20. package/dist/{config-CbKHc1kT.d.ts → config-DVxKePlL.d.ts} +17 -17
  21. package/dist/config.cjs +4 -4
  22. package/dist/config.d.cts +1 -1
  23. package/dist/config.d.ts +1 -1
  24. package/dist/config.mjs +3 -3
  25. package/dist/index.cjs +8 -8
  26. package/dist/index.d.cts +2 -2
  27. package/dist/index.d.ts +2 -2
  28. package/dist/index.mjs +6 -6
  29. package/dist/json.cjs +3 -3
  30. package/dist/json.d.cts +1 -1
  31. package/dist/json.d.ts +1 -1
  32. package/dist/json.mjs +2 -2
  33. package/dist/types.cjs +9 -9
  34. package/dist/types.d.cts +2 -2
  35. package/dist/types.d.ts +2 -2
  36. package/dist/types.mjs +2 -2
  37. package/dist/volar.cjs +2 -2
  38. package/dist/volar.mjs +1 -1
  39. package/modules/analyze-dashboard/assets/echarts.js +11 -25
  40. package/modules/analyze-dashboard/assets/index.js +1 -1
  41. package/modules/analyze-dashboard/assets/rolldown-runtime.js +1 -1
  42. package/modules/analyze-dashboard/assets/vue.js +7 -1
  43. package/package.json +9 -9
  44. package/dist/chunk-FOWFAOSV.cjs +0 -6
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkA5DD7GKXcjs = require('../chunk-A5DD7GKX.cjs');
3
+ var _chunkQKFYCWOCcjs = require('../chunk-QKFYCWOC.cjs');
4
4
 
5
5
  // src/auto-import-components/resolvers/index.ts
6
- _chunkA5DD7GKXcjs.init_cjs_shims.call(void 0, );
6
+ _chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
7
7
 
8
8
  // src/auto-import-components/resolvers/tdesign.ts
9
- _chunkA5DD7GKXcjs.init_cjs_shims.call(void 0, );
9
+ _chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
10
10
  var _shared = require('@weapp-core/shared');
11
11
 
12
12
  // src/auto-import-components/resolvers/json/tdesign.json
@@ -124,10 +124,10 @@ var TDesignResolver = (opts) => {
124
124
  };
125
125
 
126
126
  // src/auto-import-components/resolvers/types.ts
127
- _chunkA5DD7GKXcjs.init_cjs_shims.call(void 0, );
127
+ _chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
128
128
 
129
129
  // src/auto-import-components/resolvers/vant.ts
130
- _chunkA5DD7GKXcjs.init_cjs_shims.call(void 0, );
130
+ _chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
131
131
 
132
132
 
133
133
  // src/auto-import-components/resolvers/json/vant.json
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  init_esm_shims
3
- } from "../chunk-SSQGJIB5.mjs";
3
+ } from "../chunk-TZWATIK3.mjs";
4
4
 
5
5
  // src/auto-import-components/resolvers/index.ts
6
6
  init_esm_shims();
@@ -1,20 +1,20 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkT4OVF4GPcjs = require('./chunk-T4OVF4GP.cjs');
4
- require('./chunk-MQBCRXCD.cjs');
5
- require('./chunk-G6EZVEVT.cjs');
3
+ var _chunkLZJAPKF7cjs = require('./chunk-LZJAPKF7.cjs');
4
+ require('./chunk-JKNSNXOE.cjs');
5
+ require('./chunk-RMHCFT5Q.cjs');
6
6
 
7
7
 
8
- var _chunkA5DD7GKXcjs = require('./chunk-A5DD7GKX.cjs');
8
+ var _chunkQKFYCWOCcjs = require('./chunk-QKFYCWOC.cjs');
9
9
 
10
10
  // src/auto-routes.ts
11
- _chunkA5DD7GKXcjs.init_cjs_shims.call(void 0, );
11
+ _chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
12
12
 
13
13
  // src/context/index.ts
14
- _chunkA5DD7GKXcjs.init_cjs_shims.call(void 0, );
14
+ _chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
15
15
 
16
16
  // src/context/CompilerContext.ts
17
- _chunkA5DD7GKXcjs.init_cjs_shims.call(void 0, );
17
+ _chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
18
18
 
19
19
  // src/auto-routes.ts
20
20
  function createGetter(resolver) {
@@ -24,7 +24,7 @@ function createGetter(resolver) {
24
24
  get: resolver
25
25
  };
26
26
  }
27
- var ctx = _chunkT4OVF4GPcjs.getCompilerContext.call(void 0, );
27
+ var ctx = _chunkLZJAPKF7cjs.getCompilerContext.call(void 0, );
28
28
  var service = ctx.autoRoutesService;
29
29
  var routes = {};
30
30
  Object.defineProperties(routes, {
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  getCompilerContext
3
- } from "./chunk-O4FBXXL3.mjs";
4
- import "./chunk-N463WDOG.mjs";
5
- import "./chunk-2SUWUB42.mjs";
3
+ } from "./chunk-DHQDH7RC.mjs";
4
+ import "./chunk-RJVVY5EI.mjs";
5
+ import "./chunk-SSYIWHY2.mjs";
6
6
  import {
7
7
  init_esm_shims
8
- } from "./chunk-SSQGJIB5.mjs";
8
+ } from "./chunk-TZWATIK3.mjs";
9
9
 
10
10
  // src/auto-routes.ts
11
11
  init_esm_shims();
@@ -2,20 +2,20 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkT4OVF4GPcjs = require('./chunk-T4OVF4GP.cjs');
5
+ var _chunkLZJAPKF7cjs = require('./chunk-LZJAPKF7.cjs');
6
6
 
7
7
 
8
- var _chunkA5DD7GKXcjs = require('./chunk-A5DD7GKX.cjs');
8
+ var _chunkQKFYCWOCcjs = require('./chunk-QKFYCWOC.cjs');
9
9
 
10
10
  // src/createContext.ts
11
- _chunkA5DD7GKXcjs.init_cjs_shims.call(void 0, );
11
+ _chunkQKFYCWOCcjs.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
- _chunkT4OVF4GPcjs.resetCompilerContext.call(void 0, key);
15
+ _chunkLZJAPKF7cjs.resetCompilerContext.call(void 0, key);
16
16
  }
17
- _chunkT4OVF4GPcjs.setActiveCompilerContextKey.call(void 0, key);
18
- const ctx = _chunkT4OVF4GPcjs.getCompilerContext.call(void 0, key);
17
+ _chunkLZJAPKF7cjs.setActiveCompilerContextKey.call(void 0, key);
18
+ const ctx = _chunkLZJAPKF7cjs.getCompilerContext.call(void 0, key);
19
19
  const { configService, scanService, autoRoutesService } = ctx;
20
20
  await configService.load(options);
21
21
  if (autoRoutesService) {
@@ -3,7 +3,7 @@ import {
3
3
  __require,
4
4
  __toESM,
5
5
  init_esm_shims
6
- } from "./chunk-SSQGJIB5.mjs";
6
+ } from "./chunk-TZWATIK3.mjs";
7
7
 
8
8
  // ../../node_modules/.pnpm/semver@7.7.3/node_modules/semver/internal/debug.js
9
9
  var require_debug = __commonJS({
@@ -11922,8 +11922,39 @@ import { Buffer as Buffer2 } from "buffer";
11922
11922
  import { posix as path10 } from "pathe";
11923
11923
  var SHARED_CHUNK_VIRTUAL_PREFIX = "weapp_shared_virtual";
11924
11924
  var SUB_PACKAGE_SHARED_DIR = "weapp-shared";
11925
- var DEFAULT_SHARED_CHUNK_STRATEGY = "duplicate";
11925
+ var DEFAULT_SHARED_CHUNK_STRATEGY = "hoist";
11926
+ function markTakeModuleImporter(moduleId, importerId) {
11927
+ if (!moduleId || !importerId) {
11928
+ return;
11929
+ }
11930
+ const importers = takeImportersMap.get(moduleId);
11931
+ if (importers) {
11932
+ importers.add(importerId);
11933
+ } else {
11934
+ takeImportersMap.set(moduleId, /* @__PURE__ */ new Set([importerId]));
11935
+ }
11936
+ }
11937
+ function resetTakeImportRegistry() {
11938
+ takeImportersMap.clear();
11939
+ forceDuplicateSharedChunks.clear();
11940
+ sharedChunkDiagnostics.clear();
11941
+ }
11942
+ function getTakeImporters(moduleId) {
11943
+ return takeImportersMap.get(moduleId);
11944
+ }
11945
+ function markForceDuplicateSharedChunk(sharedName) {
11946
+ if (!sharedName) {
11947
+ return;
11948
+ }
11949
+ forceDuplicateSharedChunks.add(sharedName);
11950
+ forceDuplicateSharedChunks.add(`${sharedName}.js`);
11951
+ }
11952
+ function isForceDuplicateSharedChunk(fileName) {
11953
+ return forceDuplicateSharedChunks.has(fileName);
11954
+ }
11926
11955
  var sharedChunkDiagnostics = /* @__PURE__ */ new Map();
11956
+ var takeImportersMap = /* @__PURE__ */ new Map();
11957
+ var forceDuplicateSharedChunks = /* @__PURE__ */ new Set();
11927
11958
  function resolveSharedChunkName(options) {
11928
11959
  const {
11929
11960
  id,
@@ -11933,7 +11964,42 @@ function resolveSharedChunkName(options) {
11933
11964
  strategy,
11934
11965
  forceDuplicateTester
11935
11966
  } = options;
11967
+ const subPackageRootList = Array.from(subPackageRoots);
11936
11968
  const moduleInfo = ctx.getModuleInfo(id);
11969
+ const takeImporters = getTakeImporters(id);
11970
+ if (takeImporters?.size) {
11971
+ const takeSharedName = resolveTakeSharedChunkName({
11972
+ id,
11973
+ ctx,
11974
+ relativeAbsoluteSrcRoot,
11975
+ subPackageRoots: subPackageRootList,
11976
+ importers: Array.from(takeImporters)
11977
+ });
11978
+ if (takeSharedName) {
11979
+ return takeSharedName;
11980
+ }
11981
+ }
11982
+ if (strategy === "hoist") {
11983
+ const relativeId = relativeAbsoluteSrcRoot(id);
11984
+ const moduleRoot = resolveSubPackagePrefix(relativeId, subPackageRootList);
11985
+ if (moduleRoot) {
11986
+ assertModuleScopedToRoot({
11987
+ moduleInfo,
11988
+ moduleRoot,
11989
+ relativeAbsoluteSrcRoot,
11990
+ subPackageRoots: subPackageRootList,
11991
+ moduleId: id
11992
+ });
11993
+ if (!moduleInfo?.importers || moduleInfo.importers.length <= 1) {
11994
+ return void 0;
11995
+ }
11996
+ return path10.join(moduleRoot, "common");
11997
+ }
11998
+ if (!moduleInfo?.importers || moduleInfo.importers.length <= 1) {
11999
+ return void 0;
12000
+ }
12001
+ return "common";
12002
+ }
11937
12003
  if (!moduleInfo?.importers || moduleInfo.importers.length <= 1) {
11938
12004
  return void 0;
11939
12005
  }
@@ -11941,7 +12007,7 @@ function resolveSharedChunkName(options) {
11941
12007
  ctx,
11942
12008
  importers: moduleInfo.importers,
11943
12009
  relativeAbsoluteSrcRoot,
11944
- subPackageRoots: Array.from(subPackageRoots),
12010
+ subPackageRoots: subPackageRootList,
11945
12011
  forceDuplicateTester
11946
12012
  });
11947
12013
  const keys = Object.keys(summary);
@@ -11954,9 +12020,7 @@ function resolveSharedChunkName(options) {
11954
12020
  }
11955
12021
  const hasMainImporter = keys.includes("");
11956
12022
  if (strategy === "duplicate" && !hasMainImporter) {
11957
- const combination = keys.filter(Boolean).sort().join("+");
11958
- const combinationSegment = combination ? `${combination}/` : "";
11959
- const sharedName = `${SHARED_CHUNK_VIRTUAL_PREFIX}/${combinationSegment}common`;
12023
+ const sharedName = createSharedChunkNameFromKeys(keys);
11960
12024
  if (ignoredMainImporters.length) {
11961
12025
  sharedChunkDiagnostics.set(sharedName, {
11962
12026
  ignoredMainImporters: Array.from(new Set(ignoredMainImporters))
@@ -12107,8 +12171,60 @@ function resolveSubPackagePrefix(fileName, subPackageRoots) {
12107
12171
  }
12108
12172
  return "";
12109
12173
  }
12174
+ function resolveTakeSharedChunkName(options) {
12175
+ const {
12176
+ ctx,
12177
+ relativeAbsoluteSrcRoot,
12178
+ subPackageRoots,
12179
+ importers
12180
+ } = options;
12181
+ if (!importers.length) {
12182
+ return void 0;
12183
+ }
12184
+ const { summary } = summarizeImportPrefixes({
12185
+ ctx,
12186
+ importers,
12187
+ relativeAbsoluteSrcRoot,
12188
+ subPackageRoots
12189
+ });
12190
+ const keys = Object.keys(summary).filter(Boolean);
12191
+ if (!keys.length) {
12192
+ return void 0;
12193
+ }
12194
+ const sharedName = createSharedChunkNameFromKeys(keys);
12195
+ markForceDuplicateSharedChunk(sharedName);
12196
+ return sharedName;
12197
+ }
12198
+ function createSharedChunkNameFromKeys(keys) {
12199
+ const sanitize = (value) => value.replace(/[\\/]+/g, "_");
12200
+ const combination = keys.filter(Boolean).map(sanitize).sort().join("+");
12201
+ const combinationSegment = combination ? `${combination}/` : "";
12202
+ return `${SHARED_CHUNK_VIRTUAL_PREFIX}/${combinationSegment}common`;
12203
+ }
12204
+ function assertModuleScopedToRoot(options) {
12205
+ const {
12206
+ moduleInfo,
12207
+ moduleRoot,
12208
+ relativeAbsoluteSrcRoot,
12209
+ subPackageRoots,
12210
+ moduleId
12211
+ } = options;
12212
+ if (!moduleRoot || !moduleInfo?.importers?.length) {
12213
+ return;
12214
+ }
12215
+ for (const importer of moduleInfo.importers) {
12216
+ const importerRoot = resolveSubPackagePrefix(relativeAbsoluteSrcRoot(importer), subPackageRoots);
12217
+ if (importerRoot !== moduleRoot) {
12218
+ const moduleLabel = relativeAbsoluteSrcRoot(moduleId);
12219
+ const importerLabel = relativeAbsoluteSrcRoot(importer);
12220
+ throw new Error(
12221
+ `[subpackages] \u6A21\u5757 "${moduleLabel}" \u4F4D\u4E8E\u5206\u5305 "${moduleRoot}"\uFF0C\u4F46\u88AB "${importerLabel}" \u5F15\u7528\uFF0C\u8BF7\u5C06\u8BE5\u6A21\u5757\u79FB\u52A8\u5230\u4E3B\u5305\u6216\u516C\u5171\u76EE\u5F55\u4EE5\u8FDB\u884C\u8DE8\u5206\u5305\u5171\u4EAB\u3002`
12222
+ );
12223
+ }
12224
+ }
12225
+ }
12110
12226
  function applySharedChunkStrategy(bundle, options) {
12111
- if (options.strategy !== "duplicate") {
12227
+ if (options.strategy !== "duplicate" && forceDuplicateSharedChunks.size === 0) {
12112
12228
  return;
12113
12229
  }
12114
12230
  if (!this) {
@@ -12128,13 +12244,17 @@ function applySharedChunkStrategy(bundle, options) {
12128
12244
  if (importers.length === 0) {
12129
12245
  continue;
12130
12246
  }
12247
+ const sourceMapKeys = collectSourceMapKeys(fileName, chunk);
12248
+ const sourceMapAssetInfo = findSourceMapAsset(bundle, sourceMapKeys);
12249
+ const resolvedSourceMap = resolveSourceMapSource(originalMap, sourceMapAssetInfo?.asset.source);
12131
12250
  const importerMap = /* @__PURE__ */ new Map();
12132
12251
  let hasMainImporter = false;
12252
+ const shouldForceDuplicate = isForceDuplicateSharedChunk(originalSharedFileName);
12133
12253
  for (const importerFile of importers) {
12134
12254
  const root = resolveSubPackagePrefix(importerFile, subPackageRoots);
12135
12255
  if (!root) {
12136
12256
  hasMainImporter = true;
12137
- break;
12257
+ continue;
12138
12258
  }
12139
12259
  const duplicateBaseName = path10.basename(fileName);
12140
12260
  const intendedFileName = path10.join(root, SUB_PACKAGE_SHARED_DIR, duplicateBaseName);
@@ -12149,12 +12269,28 @@ function applySharedChunkStrategy(bundle, options) {
12149
12269
  });
12150
12270
  }
12151
12271
  }
12152
- if (hasMainImporter || importerMap.size === 0) {
12153
- consumeSharedChunkDiagnostics(originalSharedFileName);
12272
+ const importerToChunk = /* @__PURE__ */ new Map();
12273
+ const duplicates = [];
12274
+ const diagnostics = consumeSharedChunkDiagnostics(originalSharedFileName);
12275
+ const shouldRetainOriginalChunk = shouldForceDuplicate && hasMainImporter;
12276
+ if ((hasMainImporter || importerMap.size === 0) && (!shouldForceDuplicate || importerMap.size === 0)) {
12154
12277
  let finalFileName = chunk.fileName;
12155
12278
  if (fileName.startsWith(`${SHARED_CHUNK_VIRTUAL_PREFIX}/`)) {
12156
12279
  const newFileName = fileName.slice(SHARED_CHUNK_VIRTUAL_PREFIX.length + 1);
12157
12280
  chunk.fileName = newFileName;
12281
+ if (typeof chunk.sourcemapFileName === "string" && chunk.sourcemapFileName) {
12282
+ chunk.sourcemapFileName = `${newFileName}.map`;
12283
+ }
12284
+ const targetKey = `${newFileName}.map`;
12285
+ emitSourceMapAsset(this, targetKey, sourceMapAssetInfo, resolvedSourceMap);
12286
+ for (const mapKey of sourceMapKeys) {
12287
+ if (!mapKey || mapKey === targetKey) {
12288
+ continue;
12289
+ }
12290
+ if (bundle[mapKey]) {
12291
+ delete bundle[mapKey];
12292
+ }
12293
+ }
12158
12294
  finalFileName = newFileName;
12159
12295
  }
12160
12296
  options.onFallback?.({
@@ -12165,20 +12301,40 @@ function applySharedChunkStrategy(bundle, options) {
12165
12301
  });
12166
12302
  continue;
12167
12303
  }
12168
- const importerToChunk = /* @__PURE__ */ new Map();
12169
- const duplicates = [];
12170
- const diagnostics = consumeSharedChunkDiagnostics(originalSharedFileName);
12304
+ if (shouldRetainOriginalChunk && fileName.startsWith(`${SHARED_CHUNK_VIRTUAL_PREFIX}/`)) {
12305
+ const newFileName = fileName.slice(SHARED_CHUNK_VIRTUAL_PREFIX.length + 1);
12306
+ chunk.fileName = newFileName;
12307
+ if (typeof chunk.sourcemapFileName === "string" && chunk.sourcemapFileName) {
12308
+ chunk.sourcemapFileName = `${newFileName}.map`;
12309
+ }
12310
+ const targetKey = `${newFileName}.map`;
12311
+ emitSourceMapAsset(this, targetKey, sourceMapAssetInfo, resolvedSourceMap);
12312
+ for (const mapKey of sourceMapKeys) {
12313
+ if (!mapKey || mapKey === targetKey) {
12314
+ continue;
12315
+ }
12316
+ if (bundle[mapKey]) {
12317
+ delete bundle[mapKey];
12318
+ }
12319
+ }
12320
+ options.onFallback?.({
12321
+ sharedFileName: originalSharedFileName,
12322
+ finalFileName: newFileName,
12323
+ reason: "main-package",
12324
+ importers: [...importers]
12325
+ });
12326
+ }
12171
12327
  for (const { newFileName, importers: importerFiles } of importerMap.values()) {
12172
12328
  this.emitFile({
12173
12329
  type: "asset",
12174
12330
  fileName: newFileName,
12175
12331
  source: originalCode
12176
12332
  });
12177
- if (originalMap) {
12333
+ if (resolvedSourceMap) {
12178
12334
  this.emitFile({
12179
12335
  type: "asset",
12180
12336
  fileName: `${newFileName}.map`,
12181
- source: typeof originalMap === "string" ? originalMap : JSON.stringify(originalMap)
12337
+ source: cloneSourceLike(resolvedSourceMap)
12182
12338
  });
12183
12339
  }
12184
12340
  for (const importerFile of importerFiles) {
@@ -12190,15 +12346,12 @@ function applySharedChunkStrategy(bundle, options) {
12190
12346
  });
12191
12347
  }
12192
12348
  updateImporters(bundle, importerToChunk, fileName);
12193
- delete bundle[fileName];
12194
- const candidateMapKeys = /* @__PURE__ */ new Set();
12195
- candidateMapKeys.add(`${fileName}.map`);
12196
- if (typeof chunk.sourcemapFileName === "string" && chunk.sourcemapFileName) {
12197
- candidateMapKeys.add(chunk.sourcemapFileName);
12198
- }
12199
- for (const mapKey of candidateMapKeys) {
12200
- if (mapKey && bundle[mapKey]) {
12201
- delete bundle[mapKey];
12349
+ if (!shouldRetainOriginalChunk) {
12350
+ delete bundle[fileName];
12351
+ for (const mapKey of sourceMapKeys) {
12352
+ if (mapKey && bundle[mapKey]) {
12353
+ delete bundle[mapKey];
12354
+ }
12202
12355
  }
12203
12356
  }
12204
12357
  const chunkBytes = typeof originalCode === "string" ? Buffer2.byteLength(originalCode, "utf8") : void 0;
@@ -12208,7 +12361,8 @@ function applySharedChunkStrategy(bundle, options) {
12208
12361
  duplicates,
12209
12362
  ignoredMainImporters: diagnostics?.ignoredMainImporters,
12210
12363
  chunkBytes,
12211
- redundantBytes
12364
+ redundantBytes,
12365
+ retainedInMain: shouldRetainOriginalChunk
12212
12366
  });
12213
12367
  }
12214
12368
  }
@@ -12226,6 +12380,27 @@ function consumeSharedChunkDiagnostics(fileName) {
12226
12380
  }
12227
12381
  return void 0;
12228
12382
  }
12383
+ function emitSourceMapAsset(ctx, targetFileName, sourceMapAssetInfo, fallbackSource) {
12384
+ if (!targetFileName) {
12385
+ return;
12386
+ }
12387
+ if (sourceMapAssetInfo?.asset && isSourceLike(sourceMapAssetInfo.asset.source)) {
12388
+ ctx.emitFile({
12389
+ type: "asset",
12390
+ fileName: targetFileName,
12391
+ source: cloneSourceLike(sourceMapAssetInfo.asset.source),
12392
+ name: sourceMapAssetInfo.asset.name
12393
+ });
12394
+ return;
12395
+ }
12396
+ if (fallbackSource) {
12397
+ ctx.emitFile({
12398
+ type: "asset",
12399
+ fileName: targetFileName,
12400
+ source: cloneSourceLike(fallbackSource)
12401
+ });
12402
+ }
12403
+ }
12229
12404
  function isSharedVirtualChunk(fileName, output) {
12230
12405
  return output?.type === "chunk" && fileName.startsWith(`${SHARED_CHUNK_VIRTUAL_PREFIX}/`);
12231
12406
  }
@@ -12406,6 +12581,55 @@ function createRelativeImport(fromFile, toFile) {
12406
12581
  }
12407
12582
  return `./${relative3}`;
12408
12583
  }
12584
+ function collectSourceMapKeys(fileName, chunk) {
12585
+ const keys = /* @__PURE__ */ new Set();
12586
+ if (fileName) {
12587
+ keys.add(`${fileName}.map`);
12588
+ }
12589
+ if (typeof chunk.sourcemapFileName === "string" && chunk.sourcemapFileName) {
12590
+ keys.add(chunk.sourcemapFileName);
12591
+ }
12592
+ return keys;
12593
+ }
12594
+ function findSourceMapAsset(bundle, candidateKeys) {
12595
+ for (const key of candidateKeys) {
12596
+ if (!key) {
12597
+ continue;
12598
+ }
12599
+ const entry = bundle[key];
12600
+ if (entry?.type === "asset") {
12601
+ return {
12602
+ asset: entry,
12603
+ key
12604
+ };
12605
+ }
12606
+ }
12607
+ return void 0;
12608
+ }
12609
+ function resolveSourceMapSource(originalMap, assetSource) {
12610
+ if (originalMap) {
12611
+ if (typeof originalMap === "string") {
12612
+ return originalMap;
12613
+ }
12614
+ if (originalMap instanceof Uint8Array || Buffer2.isBuffer(originalMap)) {
12615
+ return Buffer2.from(originalMap);
12616
+ }
12617
+ return JSON.stringify(originalMap);
12618
+ }
12619
+ if (isSourceLike(assetSource)) {
12620
+ return cloneSourceLike(assetSource);
12621
+ }
12622
+ return void 0;
12623
+ }
12624
+ function isSourceLike(source) {
12625
+ return typeof source === "string" || source instanceof Uint8Array || Buffer2.isBuffer(source);
12626
+ }
12627
+ function cloneSourceLike(source) {
12628
+ if (typeof source === "string") {
12629
+ return source;
12630
+ }
12631
+ return Buffer2.from(source);
12632
+ }
12409
12633
 
12410
12634
  // src/runtime/advancedChunks.ts
12411
12635
  function testByReg2DExpList(reg2DExpList) {
@@ -23891,11 +24115,69 @@ function weappVite(ctx, subPackageMeta) {
23891
24115
  watchFilesSnapshot: []
23892
24116
  };
23893
24117
  return [
24118
+ createTakeQueryPlugin(state),
23894
24119
  createWxssResolverPlugin(state),
23895
24120
  createCoreLifecyclePlugin(state),
23896
24121
  createRequireAnalysisPlugin(state)
23897
24122
  ];
23898
24123
  }
24124
+ var TAKE_DIRECTIVE_PREFIX = "take:";
24125
+ function normalizeTakeRequest(source) {
24126
+ if (!source) {
24127
+ return null;
24128
+ }
24129
+ if (source.startsWith(TAKE_DIRECTIVE_PREFIX)) {
24130
+ const id = source.slice(TAKE_DIRECTIVE_PREFIX.length);
24131
+ if (!id) {
24132
+ return null;
24133
+ }
24134
+ return {
24135
+ id,
24136
+ legacy: false
24137
+ };
24138
+ }
24139
+ if (!source.includes("?")) {
24140
+ return null;
24141
+ }
24142
+ const [filename, rawQuery] = source.split("?", 2);
24143
+ if (!rawQuery) {
24144
+ return null;
24145
+ }
24146
+ const params = new URLSearchParams(rawQuery);
24147
+ if (!params.has("take")) {
24148
+ return null;
24149
+ }
24150
+ return {
24151
+ id: filename,
24152
+ legacy: true
24153
+ };
24154
+ }
24155
+ function createTakeQueryPlugin(_state) {
24156
+ return {
24157
+ name: "weapp-vite:pre:take-query",
24158
+ enforce: "pre",
24159
+ buildStart() {
24160
+ resetTakeImportRegistry();
24161
+ },
24162
+ async resolveId(source, importer) {
24163
+ const takeRequest = normalizeTakeRequest(source);
24164
+ if (!takeRequest) {
24165
+ return null;
24166
+ }
24167
+ const resolved = await this.resolve(takeRequest.id, importer, { skipSelf: true });
24168
+ if (resolved?.id) {
24169
+ markTakeModuleImporter(resolved.id, importer);
24170
+ if (takeRequest.legacy) {
24171
+ logger_default.warn(
24172
+ `"${source}" detected: the ?take query is deprecated, please migrate to the "take:" prefix (e.g. "take:${takeRequest.id}")`
24173
+ );
24174
+ }
24175
+ return resolved;
24176
+ }
24177
+ return null;
24178
+ }
24179
+ };
24180
+ }
23899
24181
  function createWxssResolverPlugin(_state) {
23900
24182
  return {
23901
24183
  name: "weapp-vite:pre:wxss",
@@ -24045,7 +24327,7 @@ function createCoreLifecyclePlugin(state) {
24045
24327
  const duplicateWarningBytes = Number(configService.weappViteConfig?.chunks?.duplicateWarningBytes ?? 0);
24046
24328
  const shouldWarnOnDuplicate = Number.isFinite(duplicateWarningBytes) && duplicateWarningBytes > 0;
24047
24329
  let redundantBytesTotal = 0;
24048
- const handleDuplicate = shouldLogChunks || shouldWarnOnDuplicate ? ({ duplicates, ignoredMainImporters, chunkBytes, redundantBytes }) => {
24330
+ const handleDuplicate = shouldLogChunks || shouldWarnOnDuplicate ? ({ duplicates, ignoredMainImporters, chunkBytes, redundantBytes, retainedInMain, sharedFileName }) => {
24049
24331
  if (shouldWarnOnDuplicate) {
24050
24332
  const duplicateCount = duplicates.length;
24051
24333
  const computedRedundant = typeof redundantBytes === "number" ? redundantBytes : typeof chunkBytes === "number" ? chunkBytes * Math.max(duplicateCount - 1, 0) : 0;
@@ -24064,6 +24346,9 @@ function createCoreLifecyclePlugin(state) {
24064
24346
  const subPackageList = Array.from(subPackageSet).join("\u3001") || "\u76F8\u5173\u5206\u5305";
24065
24347
  const ignoredHint = ignoredMainImporters?.length ? `\uFF0C\u5FFD\u7565\u4E3B\u5305\u5F15\u7528\uFF1A${ignoredMainImporters.join("\u3001")}` : "";
24066
24348
  logger_default.info(`[subpackages] \u5206\u5305 ${subPackageList} \u5171\u4EAB\u6A21\u5757\u5DF2\u590D\u5236\u5230\u5404\u81EA weapp-shared/common.js\uFF08${totalReferences} \u5904\u5F15\u7528${ignoredHint}\uFF09`);
24349
+ if (retainedInMain) {
24350
+ logger_default.warn(`[subpackages] \u6A21\u5757 ${sharedFileName} \u540C\u65F6\u88AB\u4E3B\u5305\u5F15\u7528\uFF0C\u56E0\u6B64\u4ECD\u4FDD\u7559\u5728\u4E3B\u5305 common.js\uFF0C\u5E76\u590D\u5236\u5230 ${subPackageList}\uFF0C\u8BF7\u786E\u8BA4\u662F\u5426\u9700\u8981\u5C06\u6E90\u4EE3\u7801\u79FB\u52A8\u5230\u4E3B\u5305\u6216\u516C\u5171\u76EE\u5F55\u3002`);
24351
+ }
24067
24352
  }
24068
24353
  } : void 0;
24069
24354
  applySharedChunkStrategy.call(this, bundle, {
@@ -24928,6 +25213,46 @@ function createMergeFactories(options) {
24928
25213
  injectBuiltinAliases(inlineConfig);
24929
25214
  return inlineConfig;
24930
25215
  }
25216
+ function normalizePluginOptions(option) {
25217
+ const normalized = [];
25218
+ if (!option) {
25219
+ return normalized;
25220
+ }
25221
+ if (Array.isArray(option)) {
25222
+ for (const entry of option) {
25223
+ normalized.push(...normalizePluginOptions(entry));
25224
+ }
25225
+ return normalized;
25226
+ }
25227
+ normalized.push(option);
25228
+ return normalized;
25229
+ }
25230
+ function isNamedPlugin(option, name) {
25231
+ return typeof option === "object" && option !== null && "name" in option && option.name === name;
25232
+ }
25233
+ function arrangePlugins(config, subPackageMeta) {
25234
+ const existing = normalizePluginOptions(config.plugins);
25235
+ const tsconfigPlugins = [];
25236
+ const others = [];
25237
+ for (const entry of existing) {
25238
+ if (!entry) {
25239
+ continue;
25240
+ }
25241
+ if (isNamedPlugin(entry, "vite-tsconfig-paths")) {
25242
+ tsconfigPlugins.push(entry);
25243
+ continue;
25244
+ }
25245
+ if (isNamedPlugin(entry, WEAPP_VITE_CONTEXT_PLUGIN_NAME)) {
25246
+ continue;
25247
+ }
25248
+ others.push(entry);
25249
+ }
25250
+ config.plugins = [
25251
+ vitePluginWeapp(ctx, subPackageMeta),
25252
+ ...others,
25253
+ ...tsconfigPlugins
25254
+ ];
25255
+ }
24931
25256
  function merge(subPackageMeta, ...configs) {
24932
25257
  ensureConfigService();
24933
25258
  const currentOptions = getOptions2();
@@ -24964,7 +25289,6 @@ function createMergeFactories(options) {
24964
25289
  {
24965
25290
  root: currentOptions.cwd,
24966
25291
  mode: "development",
24967
- plugins: [vitePluginWeapp(ctx, subPackageMeta)],
24968
25292
  define: getDefineImportMetaEnv(),
24969
25293
  build: {
24970
25294
  watch: {
@@ -24984,6 +25308,7 @@ function createMergeFactories(options) {
24984
25308
  }
24985
25309
  }
24986
25310
  );
25311
+ arrangePlugins(inline, subPackageMeta);
24987
25312
  injectBuiltinAliases(inline);
24988
25313
  return inline;
24989
25314
  }
@@ -24992,9 +25317,6 @@ function createMergeFactories(options) {
24992
25317
  ...configs,
24993
25318
  {
24994
25319
  root: currentOptions.cwd,
24995
- plugins: [
24996
- vitePluginWeapp(ctx, subPackageMeta)
24997
- ],
24998
25320
  mode: "production",
24999
25321
  define: getDefineImportMetaEnv(),
25000
25322
  build: {
@@ -25006,6 +25328,7 @@ function createMergeFactories(options) {
25006
25328
  }
25007
25329
  }
25008
25330
  );
25331
+ arrangePlugins(inlineConfig, subPackageMeta);
25009
25332
  inlineConfig.logLevel = "info";
25010
25333
  injectBuiltinAliases(inlineConfig);
25011
25334
  const currentRoot = subPackageMeta?.subPackage.root;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  init_esm_shims
3
- } from "./chunk-SSQGJIB5.mjs";
3
+ } from "./chunk-TZWATIK3.mjs";
4
4
 
5
5
  // src/types/external.ts
6
6
  init_esm_shims();