weapp-vite 5.7.1 → 5.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto-import-components/resolvers.cjs +5 -5
- package/dist/auto-import-components/resolvers.mjs +1 -1
- package/dist/auto-routes.cjs +8 -8
- package/dist/auto-routes.mjs +4 -4
- package/dist/{chunk-AXUA33LJ.mjs → chunk-3WGK7INY.mjs} +2 -2
- package/dist/{chunk-GGLONZVQ.cjs → chunk-AUQJOLJS.cjs} +6 -6
- package/dist/{chunk-ZMX6CFVX.mjs → chunk-ED4S52HS.mjs} +1 -1
- package/dist/{chunk-O4FBXXL3.mjs → chunk-FSDX3XLK.mjs} +311 -26
- package/dist/{chunk-T4OVF4GP.cjs → chunk-HKSOVHNE.cjs} +657 -372
- package/dist/{chunk-MQBCRXCD.cjs → chunk-JKNSNXOE.cjs} +2 -2
- package/dist/chunk-O3YXI56P.cjs +6 -0
- package/dist/{chunk-A5DD7GKX.cjs → chunk-QKFYCWOC.cjs} +2 -2
- package/dist/{chunk-N463WDOG.mjs → chunk-RJVVY5EI.mjs} +1 -1
- package/dist/{chunk-G6EZVEVT.cjs → chunk-RMHCFT5Q.cjs} +2 -2
- package/dist/{chunk-2SUWUB42.mjs → chunk-SSYIWHY2.mjs} +1 -1
- package/dist/{chunk-SSQGJIB5.mjs → chunk-TZWATIK3.mjs} +2 -2
- package/dist/cli.cjs +143 -99
- package/dist/cli.mjs +63 -19
- package/dist/config.cjs +4 -4
- package/dist/config.mjs +3 -3
- package/dist/index.cjs +8 -8
- package/dist/index.mjs +6 -6
- package/dist/json.cjs +3 -3
- package/dist/json.mjs +2 -2
- package/dist/types.cjs +9 -9
- package/dist/types.mjs +2 -2
- package/dist/volar.cjs +2 -2
- package/dist/volar.mjs +1 -1
- package/modules/analyze-dashboard/assets/echarts.js +11 -25
- package/modules/analyze-dashboard/assets/index.js +1 -1
- package/modules/analyze-dashboard/assets/rolldown-runtime.js +1 -1
- package/package.json +5 -5
- 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
|
|
3
|
+
var _chunkQKFYCWOCcjs = require('../chunk-QKFYCWOC.cjs');
|
|
4
4
|
|
|
5
5
|
// src/auto-import-components/resolvers/index.ts
|
|
6
|
-
|
|
6
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
7
7
|
|
|
8
8
|
// src/auto-import-components/resolvers/tdesign.ts
|
|
9
|
-
|
|
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
|
-
|
|
127
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
128
128
|
|
|
129
129
|
// src/auto-import-components/resolvers/vant.ts
|
|
130
|
-
|
|
130
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
131
131
|
|
|
132
132
|
|
|
133
133
|
// src/auto-import-components/resolvers/json/vant.json
|
package/dist/auto-routes.cjs
CHANGED
|
@@ -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
|
|
4
|
-
require('./chunk-
|
|
5
|
-
require('./chunk-
|
|
3
|
+
var _chunkHKSOVHNEcjs = require('./chunk-HKSOVHNE.cjs');
|
|
4
|
+
require('./chunk-JKNSNXOE.cjs');
|
|
5
|
+
require('./chunk-RMHCFT5Q.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkQKFYCWOCcjs = require('./chunk-QKFYCWOC.cjs');
|
|
9
9
|
|
|
10
10
|
// src/auto-routes.ts
|
|
11
|
-
|
|
11
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
12
12
|
|
|
13
13
|
// src/context/index.ts
|
|
14
|
-
|
|
14
|
+
_chunkQKFYCWOCcjs.init_cjs_shims.call(void 0, );
|
|
15
15
|
|
|
16
16
|
// src/context/CompilerContext.ts
|
|
17
|
-
|
|
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 =
|
|
27
|
+
var ctx = _chunkHKSOVHNEcjs.getCompilerContext.call(void 0, );
|
|
28
28
|
var service = ctx.autoRoutesService;
|
|
29
29
|
var routes = {};
|
|
30
30
|
Object.defineProperties(routes, {
|
package/dist/auto-routes.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getCompilerContext
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-FSDX3XLK.mjs";
|
|
4
|
+
import "./chunk-RJVVY5EI.mjs";
|
|
5
|
+
import "./chunk-SSYIWHY2.mjs";
|
|
6
6
|
import {
|
|
7
7
|
init_esm_shims
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-TZWATIK3.mjs";
|
|
9
9
|
|
|
10
10
|
// src/auto-routes.ts
|
|
11
11
|
init_esm_shims();
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
getCompilerContext,
|
|
3
3
|
resetCompilerContext,
|
|
4
4
|
setActiveCompilerContextKey
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-FSDX3XLK.mjs";
|
|
6
6
|
import {
|
|
7
7
|
init_esm_shims
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-TZWATIK3.mjs";
|
|
9
9
|
|
|
10
10
|
// src/createContext.ts
|
|
11
11
|
init_esm_shims();
|
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkHKSOVHNEcjs = require('./chunk-HKSOVHNE.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkQKFYCWOCcjs = require('./chunk-QKFYCWOC.cjs');
|
|
9
9
|
|
|
10
10
|
// src/createContext.ts
|
|
11
|
-
|
|
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
|
-
|
|
15
|
+
_chunkHKSOVHNEcjs.resetCompilerContext.call(void 0, key);
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
const ctx =
|
|
17
|
+
_chunkHKSOVHNEcjs.setActiveCompilerContextKey.call(void 0, key);
|
|
18
|
+
const ctx = _chunkHKSOVHNEcjs.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-
|
|
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 = "
|
|
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:
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
12153
|
-
|
|
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
|
-
|
|
12169
|
-
|
|
12170
|
-
|
|
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 (
|
|
12333
|
+
if (resolvedSourceMap) {
|
|
12178
12334
|
this.emitFile({
|
|
12179
12335
|
type: "asset",
|
|
12180
12336
|
fileName: `${newFileName}.map`,
|
|
12181
|
-
source:
|
|
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
|
-
|
|
12194
|
-
|
|
12195
|
-
|
|
12196
|
-
|
|
12197
|
-
|
|
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, {
|