@rsdoctor/utils 1.2.2 → 1.2.4-beta.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.
- package/compiled/connect/index.d.ts +90 -0
- package/compiled/connect/index.js +2427 -0
- package/compiled/connect/license +25 -0
- package/compiled/connect/package.json +1 -0
- package/compiled/filesize/index.d.ts +58 -0
- package/compiled/filesize/index.js +255 -0
- package/compiled/filesize/license +28 -0
- package/compiled/filesize/package.json +1 -0
- package/dist/{type/build → build}/envinfo.d.ts +0 -1
- package/dist/{type/build → build}/file/cache.d.ts +0 -1
- package/dist/build/file/index.d.ts +3 -0
- package/dist/{type/build → build}/file/sharding.d.ts +0 -1
- package/dist/{type/build → build}/index.d.ts +0 -1
- package/dist/{type/build → build}/json.d.ts +0 -1
- package/dist/{type/build → build}/process.d.ts +0 -1
- package/dist/{type/build → build}/server.d.ts +0 -1
- package/dist/build.cjs +1310 -0
- package/dist/build.js +343 -0
- package/dist/{type/common → common}/alerts.d.ts +0 -1
- package/dist/{type/common → common}/algorithm.d.ts +0 -1
- package/dist/{type/common → common}/bundle.d.ts +0 -1
- package/dist/{type/common → common}/crypto.d.ts +0 -1
- package/dist/{type/common → common}/data/index.d.ts +0 -1
- package/dist/{type/common → common}/file.d.ts +0 -1
- package/dist/{type/common → common}/global-config.d.ts +0 -1
- package/dist/{type/common → common}/graph/assets.d.ts +0 -1
- package/dist/{type/common → common}/graph/chunk.d.ts +0 -1
- package/dist/{type/common → common}/graph/dependency.d.ts +0 -1
- package/dist/{type/common → common}/graph/entrypoints.d.ts +0 -1
- package/dist/{type/common → common}/graph/index.d.ts +0 -1
- package/dist/{type/common → common}/graph/modules.d.ts +0 -1
- package/dist/{type/common → common}/index.d.ts +0 -1
- package/dist/{type/common → common}/loader.d.ts +0 -1
- package/dist/{type/common → common}/lodash.d.ts +0 -1
- package/dist/{type/common → common}/manifest.d.ts +0 -1
- package/dist/{type/common → common}/package.d.ts +0 -1
- package/dist/{type/common → common}/plugin.d.ts +0 -1
- package/dist/{type/common → common}/resolver.d.ts +0 -1
- package/dist/{type/common → common}/rspack.d.ts +0 -1
- package/dist/{type/common → common}/summary.d.ts +0 -1
- package/dist/{type/common → common}/time.d.ts +0 -1
- package/dist/{type/common → common}/url.d.ts +0 -1
- package/dist/common.cjs +1328 -0
- package/dist/common.js +1255 -0
- package/dist/{type/error → error}/error.d.ts +0 -1
- package/dist/{type/error → error}/index.d.ts +0 -1
- package/dist/{type/error → error}/transform.d.ts +0 -1
- package/dist/{type/error → error}/utils.d.ts +0 -1
- package/dist/error.cjs +310 -0
- package/dist/error.js +232 -0
- package/dist/logger.cjs +82 -0
- package/dist/{type/logger.d.ts → logger.d.ts} +0 -1
- package/dist/{esm/logger.mjs → logger.js} +8 -13
- package/dist/{type/rule-utils → rule-utils}/document/document.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/document/index.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/document/server.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/document/types.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/index.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/parser/asserts.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/parser/index.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/parser/parser.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/parser/types.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/parser/utils.d.ts +0 -1
- package/dist/ruleUtils.cjs +320 -0
- package/dist/ruleUtils.js +256 -0
- package/package.json +35 -39
- package/dist/cjs/build/envinfo.js +0 -121
- package/dist/cjs/build/file/cache.js +0 -76
- package/dist/cjs/build/file/index.js +0 -81
- package/dist/cjs/build/file/sharding.js +0 -96
- package/dist/cjs/build/index.js +0 -52
- package/dist/cjs/build/json.js +0 -103
- package/dist/cjs/build/process.js +0 -54
- package/dist/cjs/build/server.js +0 -158
- package/dist/cjs/common/alerts.js +0 -51
- package/dist/cjs/common/algorithm.js +0 -75
- package/dist/cjs/common/bundle.js +0 -62
- package/dist/cjs/common/crypto.js +0 -54
- package/dist/cjs/common/data/index.js +0 -396
- package/dist/cjs/common/file.js +0 -44
- package/dist/cjs/common/global-config.js +0 -81
- package/dist/cjs/common/graph/assets.js +0 -314
- package/dist/cjs/common/graph/chunk.js +0 -81
- package/dist/cjs/common/graph/dependency.js +0 -50
- package/dist/cjs/common/graph/entrypoints.js +0 -38
- package/dist/cjs/common/graph/index.js +0 -96
- package/dist/cjs/common/graph/modules.js +0 -133
- package/dist/cjs/common/index.js +0 -104
- package/dist/cjs/common/loader.js +0 -320
- package/dist/cjs/common/lodash.js +0 -93
- package/dist/cjs/common/manifest.js +0 -70
- package/dist/cjs/common/package.js +0 -96
- package/dist/cjs/common/plugin.js +0 -91
- package/dist/cjs/common/resolver.js +0 -92
- package/dist/cjs/common/rspack.js +0 -65
- package/dist/cjs/common/summary.js +0 -42
- package/dist/cjs/common/time.js +0 -86
- package/dist/cjs/common/url.js +0 -54
- package/dist/cjs/error/error.js +0 -199
- package/dist/cjs/error/index.js +0 -73
- package/dist/cjs/error/transform.js +0 -182
- package/dist/cjs/error/utils.js +0 -62
- package/dist/cjs/index.js +0 -40
- package/dist/cjs/logger.js +0 -106
- package/dist/cjs/rule-utils/document/document.js +0 -92
- package/dist/cjs/rule-utils/document/index.js +0 -78
- package/dist/cjs/rule-utils/document/server.js +0 -49
- package/dist/cjs/rule-utils/document/types.js +0 -18
- package/dist/cjs/rule-utils/index.js +0 -69
- package/dist/cjs/rule-utils/parser/asserts.js +0 -138
- package/dist/cjs/rule-utils/parser/index.js +0 -87
- package/dist/cjs/rule-utils/parser/parser.js +0 -57
- package/dist/cjs/rule-utils/parser/types.js +0 -41
- package/dist/cjs/rule-utils/parser/utils.js +0 -170
- package/dist/esm/build/envinfo.mjs +0 -57
- package/dist/esm/build/file/cache.mjs +0 -23
- package/dist/esm/build/file/index.mjs +0 -4
- package/dist/esm/build/file/sharding.mjs +0 -50
- package/dist/esm/build/index.mjs +0 -6
- package/dist/esm/build/json.mjs +0 -66
- package/dist/esm/build/process.mjs +0 -17
- package/dist/esm/build/server.mjs +0 -96
- package/dist/esm/common/alerts.mjs +0 -17
- package/dist/esm/common/algorithm.mjs +0 -32
- package/dist/esm/common/bundle.mjs +0 -22
- package/dist/esm/common/crypto.mjs +0 -17
- package/dist/esm/common/data/index.mjs +0 -362
- package/dist/esm/common/file.mjs +0 -7
- package/dist/esm/common/global-config.mjs +0 -32
- package/dist/esm/common/graph/assets.mjs +0 -238
- package/dist/esm/common/graph/chunk.mjs +0 -32
- package/dist/esm/common/graph/dependency.mjs +0 -10
- package/dist/esm/common/graph/entrypoints.mjs +0 -4
- package/dist/esm/common/graph/index.mjs +0 -5
- package/dist/esm/common/graph/modules.mjs +0 -78
- package/dist/esm/common/index.mjs +0 -19
- package/dist/esm/common/loader.mjs +0 -247
- package/dist/esm/common/lodash.mjs +0 -32
- package/dist/esm/common/manifest.mjs +0 -30
- package/dist/esm/common/package.mjs +0 -56
- package/dist/esm/common/plugin.mjs +0 -48
- package/dist/esm/common/resolver.mjs +0 -46
- package/dist/esm/common/rspack.mjs +0 -25
- package/dist/esm/common/summary.mjs +0 -8
- package/dist/esm/common/time.mjs +0 -43
- package/dist/esm/common/url.mjs +0 -14
- package/dist/esm/error/error.mjs +0 -154
- package/dist/esm/error/index.mjs +0 -3
- package/dist/esm/error/transform.mjs +0 -138
- package/dist/esm/error/utils.mjs +0 -22
- package/dist/esm/index.mjs +0 -3
- package/dist/esm/rule-utils/document/document.mjs +0 -58
- package/dist/esm/rule-utils/document/index.mjs +0 -3
- package/dist/esm/rule-utils/document/server.mjs +0 -12
- package/dist/esm/rule-utils/document/types.mjs +0 -0
- package/dist/esm/rule-utils/index.mjs +0 -2
- package/dist/esm/rule-utils/parser/asserts.mjs +0 -104
- package/dist/esm/rule-utils/parser/index.mjs +0 -4
- package/dist/esm/rule-utils/parser/parser.mjs +0 -23
- package/dist/esm/rule-utils/parser/types.mjs +0 -7
- package/dist/esm/rule-utils/parser/utils.mjs +0 -109
- package/dist/type/build/envinfo.d.ts.map +0 -1
- package/dist/type/build/file/cache.d.ts.map +0 -1
- package/dist/type/build/file/index.d.ts +0 -4
- package/dist/type/build/file/index.d.ts.map +0 -1
- package/dist/type/build/file/sharding.d.ts.map +0 -1
- package/dist/type/build/index.d.ts.map +0 -1
- package/dist/type/build/json.d.ts.map +0 -1
- package/dist/type/build/process.d.ts.map +0 -1
- package/dist/type/build/server.d.ts.map +0 -1
- package/dist/type/common/alerts.d.ts.map +0 -1
- package/dist/type/common/algorithm.d.ts.map +0 -1
- package/dist/type/common/bundle.d.ts.map +0 -1
- package/dist/type/common/crypto.d.ts.map +0 -1
- package/dist/type/common/data/index.d.ts.map +0 -1
- package/dist/type/common/file.d.ts.map +0 -1
- package/dist/type/common/global-config.d.ts.map +0 -1
- package/dist/type/common/graph/assets.d.ts.map +0 -1
- package/dist/type/common/graph/chunk.d.ts.map +0 -1
- package/dist/type/common/graph/dependency.d.ts.map +0 -1
- package/dist/type/common/graph/entrypoints.d.ts.map +0 -1
- package/dist/type/common/graph/index.d.ts.map +0 -1
- package/dist/type/common/graph/modules.d.ts.map +0 -1
- package/dist/type/common/index.d.ts.map +0 -1
- package/dist/type/common/loader.d.ts.map +0 -1
- package/dist/type/common/lodash.d.ts.map +0 -1
- package/dist/type/common/manifest.d.ts.map +0 -1
- package/dist/type/common/package.d.ts.map +0 -1
- package/dist/type/common/plugin.d.ts.map +0 -1
- package/dist/type/common/resolver.d.ts.map +0 -1
- package/dist/type/common/rspack.d.ts.map +0 -1
- package/dist/type/common/summary.d.ts.map +0 -1
- package/dist/type/common/time.d.ts.map +0 -1
- package/dist/type/common/url.d.ts.map +0 -1
- package/dist/type/error/error.d.ts.map +0 -1
- package/dist/type/error/index.d.ts.map +0 -1
- package/dist/type/error/transform.d.ts.map +0 -1
- package/dist/type/error/utils.d.ts.map +0 -1
- package/dist/type/index.d.ts +0 -3
- package/dist/type/index.d.ts.map +0 -1
- package/dist/type/logger.d.ts.map +0 -1
- package/dist/type/rule-utils/document/document.d.ts.map +0 -1
- package/dist/type/rule-utils/document/index.d.ts.map +0 -1
- package/dist/type/rule-utils/document/server.d.ts.map +0 -1
- package/dist/type/rule-utils/document/types.d.ts.map +0 -1
- package/dist/type/rule-utils/index.d.ts.map +0 -1
- package/dist/type/rule-utils/parser/asserts.d.ts.map +0 -1
- package/dist/type/rule-utils/parser/index.d.ts.map +0 -1
- package/dist/type/rule-utils/parser/parser.d.ts.map +0 -1
- package/dist/type/rule-utils/parser/types.d.ts.map +0 -1
- package/dist/type/rule-utils/parser/utils.d.ts.map +0 -1
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
function getDependencyByPackageData(dep, dependencies) {
|
|
2
|
-
return dependencies.find((item)=>item.id === dep.dependencyId);
|
|
3
|
-
}
|
|
4
|
-
function getDependenciesByModule(module, dependencies) {
|
|
5
|
-
return module.dependencies.map((id)=>dependencies.find((dep)=>dep.id === id)).filter(Boolean);
|
|
6
|
-
}
|
|
7
|
-
function getDependencyByResolvedRequest(resolvedRequest, dependencies) {
|
|
8
|
-
return dependencies.find((e)=>e.resolvedRequest === resolvedRequest);
|
|
9
|
-
}
|
|
10
|
-
export { getDependenciesByModule, getDependencyByPackageData, getDependencyByResolvedRequest };
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { getChunkIdsByAsset, getChunksByChunkIds } from "./chunk.mjs";
|
|
2
|
-
import { getDependenciesByModule, getDependencyByPackageData } from "./dependency.mjs";
|
|
3
|
-
import { logger } from "../../logger.mjs";
|
|
4
|
-
import { isJsExt, isStyleExt } from "../file.mjs";
|
|
5
|
-
function getModulesByAsset(asset, chunks, modules, filterModules, checkModules) {
|
|
6
|
-
const ids = getChunkIdsByAsset(asset);
|
|
7
|
-
const cks = getChunksByChunkIds(ids, chunks);
|
|
8
|
-
const res = getModulesByChunks(asset.path, cks, modules, filterModules, checkModules);
|
|
9
|
-
return res;
|
|
10
|
-
}
|
|
11
|
-
function getModuleIdsByChunk(chunk) {
|
|
12
|
-
const { modules = [] } = chunk;
|
|
13
|
-
return modules;
|
|
14
|
-
}
|
|
15
|
-
function getModuleIdsByModulesIds(moduleIds, modules) {
|
|
16
|
-
return moduleIds.map((id)=>modules.find((m)=>m.id === id)).filter(Boolean);
|
|
17
|
-
}
|
|
18
|
-
function getModulesByChunk(chunk, modules, filterModules) {
|
|
19
|
-
const ids = getModuleIdsByChunk(chunk);
|
|
20
|
-
return ids.map((id)=>{
|
|
21
|
-
const module = modules.find((e)=>e.id === id);
|
|
22
|
-
if (filterModules && filterModules.length > 0) {
|
|
23
|
-
if (!module) return null;
|
|
24
|
-
const filtered = {};
|
|
25
|
-
for (const key of filterModules)if (void 0 !== module[key]) filtered[key] = module[key];
|
|
26
|
-
return filtered;
|
|
27
|
-
}
|
|
28
|
-
return module;
|
|
29
|
-
}).filter(Boolean);
|
|
30
|
-
}
|
|
31
|
-
function getTypeChecker(assetPath) {
|
|
32
|
-
if (isStyleExt(assetPath)) return isStyleExt;
|
|
33
|
-
if (isJsExt(assetPath)) return isJsExt;
|
|
34
|
-
return ()=>true;
|
|
35
|
-
}
|
|
36
|
-
function getModulesByChunks(assetPath, chunks, modules, filterModules, checkModules) {
|
|
37
|
-
const res = [];
|
|
38
|
-
const typeChecker = getTypeChecker(assetPath);
|
|
39
|
-
try {
|
|
40
|
-
chunks.forEach((chunk)=>{
|
|
41
|
-
getModulesByChunk(chunk, modules, filterModules).forEach((md)=>{
|
|
42
|
-
const name = md.path || '';
|
|
43
|
-
if (!typeChecker(name)) return;
|
|
44
|
-
if ((checkModules ? checkModules(md) : true) && !res.filter((_m)=>_m.id === md.id).length) res.push(md);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
} catch (error) {
|
|
48
|
-
logger.debug(error);
|
|
49
|
-
}
|
|
50
|
-
return res;
|
|
51
|
-
}
|
|
52
|
-
function getModuleByDependency(dep, modules) {
|
|
53
|
-
return modules.find((item)=>item.id === dep.module);
|
|
54
|
-
}
|
|
55
|
-
function filterModulesAndDependenciesByPackageDeps(deps, dependencies, modules) {
|
|
56
|
-
const _dependencies = [];
|
|
57
|
-
const _modules = [];
|
|
58
|
-
for(let i = 0; i < deps.length; i++){
|
|
59
|
-
const dep = getDependencyByPackageData(deps[i], dependencies);
|
|
60
|
-
if (dep) {
|
|
61
|
-
_dependencies.push(dep);
|
|
62
|
-
const module = getModuleByDependency(dep, modules);
|
|
63
|
-
if (module) _modules.push(module);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
dependencies: _dependencies,
|
|
68
|
-
modules: _modules
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function getModuleDetails(moduleId, modules, dependencies) {
|
|
72
|
-
const module = modules.find((e)=>e.id === moduleId);
|
|
73
|
-
return {
|
|
74
|
-
module,
|
|
75
|
-
dependencies: getDependenciesByModule(module, dependencies)
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
export { filterModulesAndDependenciesByPackageDeps, getModuleByDependency, getModuleDetails, getModuleIdsByChunk, getModuleIdsByModulesIds, getModulesByAsset, getModulesByChunk, getModulesByChunks };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as __WEBPACK_EXTERNAL_MODULE__summary_mjs_54f58833__ from "./summary.mjs";
|
|
2
|
-
import * as __WEBPACK_EXTERNAL_MODULE__crypto_mjs_252a9c2c__ from "./crypto.mjs";
|
|
3
|
-
import * as __WEBPACK_EXTERNAL_MODULE__manifest_mjs_2d750078__ from "./manifest.mjs";
|
|
4
|
-
import * as __WEBPACK_EXTERNAL_MODULE__loader_mjs_ab87ced3__ from "./loader.mjs";
|
|
5
|
-
import * as __WEBPACK_EXTERNAL_MODULE__time_mjs_7d968bf1__ from "./time.mjs";
|
|
6
|
-
import * as __WEBPACK_EXTERNAL_MODULE__algorithm_mjs_ed543360__ from "./algorithm.mjs";
|
|
7
|
-
import * as __WEBPACK_EXTERNAL_MODULE__resolver_mjs_24d6f61e__ from "./resolver.mjs";
|
|
8
|
-
import * as __WEBPACK_EXTERNAL_MODULE__graph_index_mjs_4e5a8d12__ from "./graph/index.mjs";
|
|
9
|
-
import * as __WEBPACK_EXTERNAL_MODULE__bundle_mjs_804f0b3a__ from "./bundle.mjs";
|
|
10
|
-
import * as __WEBPACK_EXTERNAL_MODULE__url_mjs_0b48a1db__ from "./url.mjs";
|
|
11
|
-
import * as __WEBPACK_EXTERNAL_MODULE__plugin_mjs_ee4957f9__ from "./plugin.mjs";
|
|
12
|
-
import * as __WEBPACK_EXTERNAL_MODULE__data_index_mjs_870691a9__ from "./data/index.mjs";
|
|
13
|
-
import * as __WEBPACK_EXTERNAL_MODULE__alerts_mjs_af8e297e__ from "./alerts.mjs";
|
|
14
|
-
import * as __WEBPACK_EXTERNAL_MODULE__rspack_mjs_fb7d03b6__ from "./rspack.mjs";
|
|
15
|
-
import * as __WEBPACK_EXTERNAL_MODULE__package_mjs_f12bd493__ from "./package.mjs";
|
|
16
|
-
import * as __WEBPACK_EXTERNAL_MODULE__lodash_mjs_5081b560__ from "./lodash.mjs";
|
|
17
|
-
import * as __WEBPACK_EXTERNAL_MODULE__global_config_mjs_ce875cc9__ from "./global-config.mjs";
|
|
18
|
-
import * as __WEBPACK_EXTERNAL_MODULE__file_mjs_bb53e012__ from "./file.mjs";
|
|
19
|
-
export { __WEBPACK_EXTERNAL_MODULE__alerts_mjs_af8e297e__ as Alerts, __WEBPACK_EXTERNAL_MODULE__algorithm_mjs_ed543360__ as Algorithm, __WEBPACK_EXTERNAL_MODULE__bundle_mjs_804f0b3a__ as Bundle, __WEBPACK_EXTERNAL_MODULE__crypto_mjs_252a9c2c__ as Crypto, __WEBPACK_EXTERNAL_MODULE__data_index_mjs_870691a9__ as Data, __WEBPACK_EXTERNAL_MODULE__file_mjs_bb53e012__ as File, __WEBPACK_EXTERNAL_MODULE__global_config_mjs_ce875cc9__ as GlobalConfig, __WEBPACK_EXTERNAL_MODULE__graph_index_mjs_4e5a8d12__ as Graph, __WEBPACK_EXTERNAL_MODULE__loader_mjs_ab87ced3__ as Loader, __WEBPACK_EXTERNAL_MODULE__lodash_mjs_5081b560__ as Lodash, __WEBPACK_EXTERNAL_MODULE__manifest_mjs_2d750078__ as Manifest, __WEBPACK_EXTERNAL_MODULE__package_mjs_f12bd493__ as Package, __WEBPACK_EXTERNAL_MODULE__plugin_mjs_ee4957f9__ as Plugin, __WEBPACK_EXTERNAL_MODULE__resolver_mjs_24d6f61e__ as Resolver, __WEBPACK_EXTERNAL_MODULE__rspack_mjs_fb7d03b6__ as Rspack, __WEBPACK_EXTERNAL_MODULE__summary_mjs_54f58833__ as Summary, __WEBPACK_EXTERNAL_MODULE__time_mjs_7d968bf1__ as Time, __WEBPACK_EXTERNAL_MODULE__url_mjs_0b48a1db__ as Url };
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import { mergeIntervals } from "./algorithm.mjs";
|
|
2
|
-
function findLoaderTotalTiming(loaders) {
|
|
3
|
-
let start = 1 / 0;
|
|
4
|
-
let end = -1 / 0;
|
|
5
|
-
for(let i = 0; i < loaders.length; i++){
|
|
6
|
-
const loader = loaders[i];
|
|
7
|
-
if (loader.startAt <= start) start = loader.startAt;
|
|
8
|
-
if (loader.endAt >= end) end = loader.endAt;
|
|
9
|
-
}
|
|
10
|
-
return {
|
|
11
|
-
start,
|
|
12
|
-
end
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
function getLoadersCosts(filter, loaders) {
|
|
16
|
-
const match = {};
|
|
17
|
-
const others = {};
|
|
18
|
-
loaders.forEach((e)=>{
|
|
19
|
-
if (filter(e)) {
|
|
20
|
-
if (!match[e.pid]) match[e.pid] = [];
|
|
21
|
-
match[e.pid].push([
|
|
22
|
-
e.startAt,
|
|
23
|
-
e.endAt
|
|
24
|
-
]);
|
|
25
|
-
} else {
|
|
26
|
-
if (!others[e.pid]) others[e.pid] = [];
|
|
27
|
-
others[e.pid].push([
|
|
28
|
-
e.startAt,
|
|
29
|
-
e.endAt
|
|
30
|
-
]);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
let costs = 0;
|
|
34
|
-
const pids = Object.keys(match);
|
|
35
|
-
for(let i = 0; i < pids.length; i++){
|
|
36
|
-
const pid = pids[i];
|
|
37
|
-
const _match = mergeIntervals(match[pid]);
|
|
38
|
-
const _others = mergeIntervals(others[pid] || []).filter(([s, e])=>_match.some((el)=>s >= el[0] && e <= el[1]));
|
|
39
|
-
const matchSum = _match.length ? _match.reduce((t, c)=>t += c[1] - c[0], 0) : 0;
|
|
40
|
-
const othersSum = _others.length ? _others.reduce((t, c)=>t += c[1] - c[0], 0) : 0;
|
|
41
|
-
costs += matchSum - othersSum;
|
|
42
|
-
}
|
|
43
|
-
return costs;
|
|
44
|
-
}
|
|
45
|
-
function getLoaderCosts(loader, loaders) {
|
|
46
|
-
const blocked = loaders.filter((e)=>{
|
|
47
|
-
if (e.loader.includes('builtin')) return false;
|
|
48
|
-
if (e !== loader && e.pid === loader.pid) {
|
|
49
|
-
if (e.startAt >= loader.startAt) {
|
|
50
|
-
if (e.endAt <= loader.endAt) return true;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return false;
|
|
54
|
-
});
|
|
55
|
-
let costs = loader.endAt - loader.startAt;
|
|
56
|
-
if (blocked.length) {
|
|
57
|
-
const intervals = blocked.map((e)=>[
|
|
58
|
-
Math.max(e.startAt, loader.startAt),
|
|
59
|
-
Math.min(e.endAt, loader.endAt)
|
|
60
|
-
]);
|
|
61
|
-
mergeIntervals(intervals).forEach((e)=>{
|
|
62
|
-
const sub = e[1] - e[0];
|
|
63
|
-
costs -= sub;
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
return costs;
|
|
67
|
-
}
|
|
68
|
-
function getLoaderNames(loaders) {
|
|
69
|
-
const names = new Set();
|
|
70
|
-
loaders.forEach((e)=>e.loaders.forEach((l)=>names.add(getLoadrName(l.loader))));
|
|
71
|
-
return [
|
|
72
|
-
...names
|
|
73
|
-
];
|
|
74
|
-
}
|
|
75
|
-
function getLoadersTransformData(loaders) {
|
|
76
|
-
const res = [];
|
|
77
|
-
for(let i = 0; i < loaders.length; i++){
|
|
78
|
-
const item = loaders[i];
|
|
79
|
-
for(let j = 0; j < item.loaders.length; j++){
|
|
80
|
-
const loader = item.loaders[j];
|
|
81
|
-
res.push(loader);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return res;
|
|
85
|
-
}
|
|
86
|
-
function getLoaderChartData(loaders) {
|
|
87
|
-
const res = [];
|
|
88
|
-
const list = getLoadersTransformData(loaders);
|
|
89
|
-
loaders.forEach((item)=>{
|
|
90
|
-
item.loaders.forEach((el)=>{
|
|
91
|
-
res.push({
|
|
92
|
-
layer: item.resource.layer,
|
|
93
|
-
loader: getLoadrName(el.loader),
|
|
94
|
-
isPitch: el.isPitch,
|
|
95
|
-
startAt: el.startAt,
|
|
96
|
-
endAt: el.endAt,
|
|
97
|
-
pid: el.pid,
|
|
98
|
-
sync: el.sync,
|
|
99
|
-
resource: item.resource.path,
|
|
100
|
-
costs: getLoaderCosts(el, list)
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
return res;
|
|
105
|
-
}
|
|
106
|
-
function getLoaderFileTree(loaders) {
|
|
107
|
-
const list = getLoadersTransformData(loaders);
|
|
108
|
-
return loaders.map((data)=>{
|
|
109
|
-
const { loaders: arr, resource } = data;
|
|
110
|
-
return {
|
|
111
|
-
path: resource.path,
|
|
112
|
-
layer: resource.layer,
|
|
113
|
-
loaders: arr.map((l)=>({
|
|
114
|
-
key: l.path,
|
|
115
|
-
loader: getLoadrName(l.loader),
|
|
116
|
-
path: l.path,
|
|
117
|
-
errors: l.errors,
|
|
118
|
-
costs: getLoaderCosts(l, list)
|
|
119
|
-
}))
|
|
120
|
-
};
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
function getLoaderFileDetails(path, loaders) {
|
|
124
|
-
const data = loaders.find((e)=>e.resource.path === path);
|
|
125
|
-
if (!data) throw new Error(`"${path}" not match any loader data`);
|
|
126
|
-
const list = getLoadersTransformData(loaders);
|
|
127
|
-
return {
|
|
128
|
-
...data,
|
|
129
|
-
loaders: data.loaders.map((el)=>({
|
|
130
|
-
...el,
|
|
131
|
-
loader: getLoadrName(el.loader),
|
|
132
|
-
costs: getLoaderCosts(el, list)
|
|
133
|
-
}))
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
function getLoaderFolderStatistics(folder, loaders) {
|
|
137
|
-
const datas = loaders.filter((data)=>{
|
|
138
|
-
const { path } = data.resource;
|
|
139
|
-
return path.startsWith(folder);
|
|
140
|
-
});
|
|
141
|
-
const filteredLoaders = [];
|
|
142
|
-
const uniqueLoaders = new Map();
|
|
143
|
-
datas.forEach((data)=>{
|
|
144
|
-
data.loaders.forEach((fl)=>{
|
|
145
|
-
const uniqueLoader = uniqueLoaders.get(fl.loader);
|
|
146
|
-
if (uniqueLoader) uniqueLoaders.set(fl.loader, {
|
|
147
|
-
files: uniqueLoader.files + 1,
|
|
148
|
-
path: fl.path
|
|
149
|
-
});
|
|
150
|
-
else uniqueLoaders.set(fl.loader, {
|
|
151
|
-
files: 1,
|
|
152
|
-
path: fl.path
|
|
153
|
-
});
|
|
154
|
-
return filteredLoaders.push({
|
|
155
|
-
loader: fl.loader,
|
|
156
|
-
startAt: fl.startAt,
|
|
157
|
-
endAt: fl.endAt,
|
|
158
|
-
pid: fl.pid
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
const loaderCosts = Array.from(uniqueLoaders).map((uniqueLoader)=>{
|
|
163
|
-
const filter = (l)=>l.loader === uniqueLoader[0];
|
|
164
|
-
const costs = getLoadersCosts(filter, filteredLoaders);
|
|
165
|
-
return {
|
|
166
|
-
loader: uniqueLoader[0],
|
|
167
|
-
files: uniqueLoader[1].files,
|
|
168
|
-
path: uniqueLoader[1].path,
|
|
169
|
-
costs
|
|
170
|
-
};
|
|
171
|
-
});
|
|
172
|
-
return loaderCosts;
|
|
173
|
-
}
|
|
174
|
-
function collectResourceDirectories(loaders, root) {
|
|
175
|
-
const directories = new Set();
|
|
176
|
-
loaders.forEach((item)=>{
|
|
177
|
-
if (item.resource.path.startsWith(root)) {
|
|
178
|
-
const pathParts = item.resource.path.split(root).slice(1).join('/').split('/');
|
|
179
|
-
if (pathParts.length >= 2) {
|
|
180
|
-
const twoLevelDir = pathParts.slice(0, 2).join('/');
|
|
181
|
-
directories.add(`${root}/${twoLevelDir}`);
|
|
182
|
-
}
|
|
183
|
-
} else {
|
|
184
|
-
const pathParts = item.resource.path.split('/');
|
|
185
|
-
const twoLevelDir = pathParts.slice(0, pathParts.length - 1).join('/');
|
|
186
|
-
directories.add(twoLevelDir);
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
return Array.from(directories);
|
|
190
|
-
}
|
|
191
|
-
function getDirectoriesLoaders(loaders, root) {
|
|
192
|
-
const rootPath = root || process.cwd();
|
|
193
|
-
const directories = collectResourceDirectories(loaders, rootPath);
|
|
194
|
-
return directories.map((directory)=>{
|
|
195
|
-
const stats = getLoaderFolderStatistics(directory, loaders);
|
|
196
|
-
return {
|
|
197
|
-
directory,
|
|
198
|
-
stats
|
|
199
|
-
};
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
function getLoaderFileFirstInput(file, loaders) {
|
|
203
|
-
for(let i = 0; i < loaders.length; i++){
|
|
204
|
-
const item = loaders[i];
|
|
205
|
-
if (item.resource.path === file) {
|
|
206
|
-
const nonPitchLoaders = item.loaders.filter((e)=>!e.isPitch);
|
|
207
|
-
if (!nonPitchLoaders.length) return '';
|
|
208
|
-
return nonPitchLoaders[0].input || '';
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return '';
|
|
212
|
-
}
|
|
213
|
-
function getLoaderFileInputAndOutput(file, loader, loaderIndex, loaders) {
|
|
214
|
-
for(let i = 0; i < loaders.length; i++){
|
|
215
|
-
const item = loaders[i];
|
|
216
|
-
if (item.resource.path === file) for(let j = 0; j < item.loaders.length; j++){
|
|
217
|
-
const l = item.loaders[j];
|
|
218
|
-
if (l.loader === loader && l.loaderIndex === loaderIndex) return {
|
|
219
|
-
input: l.input || '',
|
|
220
|
-
output: l.result || ''
|
|
221
|
-
};
|
|
222
|
-
return {
|
|
223
|
-
input: '',
|
|
224
|
-
output: ''
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
return {
|
|
229
|
-
input: '',
|
|
230
|
-
output: ''
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
const LoaderInternalPropertyName = '__l__';
|
|
234
|
-
const isVue = (compiler)=>{
|
|
235
|
-
const rules = 'module' in compiler.options && compiler.options.module.rules || [];
|
|
236
|
-
const hasVueRule = rules.some((rule)=>{
|
|
237
|
-
var _rule_test;
|
|
238
|
-
if (rule && 'object' == typeof rule && rule.test instanceof RegExp && (null == (_rule_test = rule.test) ? void 0 : _rule_test.test('.vue'))) return true;
|
|
239
|
-
return false;
|
|
240
|
-
});
|
|
241
|
-
return hasVueRule;
|
|
242
|
-
};
|
|
243
|
-
const getLoadrName = (loader)=>{
|
|
244
|
-
const regResults = loader.includes('node_modules') ? loader.split('node_modules') : null;
|
|
245
|
-
return regResults ? regResults[regResults.length - 1] : loader;
|
|
246
|
-
};
|
|
247
|
-
export { LoaderInternalPropertyName, findLoaderTotalTiming, getDirectoriesLoaders, getLoaderChartData, getLoaderCosts, getLoaderFileDetails, getLoaderFileFirstInput, getLoaderFileInputAndOutput, getLoaderFileTree, getLoaderFolderStatistics, getLoaderNames, getLoadersCosts, getLoadersTransformData, isVue };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
function isUndefined(value) {
|
|
2
|
-
return void 0 === value;
|
|
3
|
-
}
|
|
4
|
-
function isNumber(value) {
|
|
5
|
-
return 'number' == typeof value && !Number.isNaN(value);
|
|
6
|
-
}
|
|
7
|
-
function isObject(value) {
|
|
8
|
-
return 'object' == typeof value && null !== value;
|
|
9
|
-
}
|
|
10
|
-
function isEmpty(value) {
|
|
11
|
-
return null == value || Array.isArray(value) && 0 === value.length || 'object' == typeof value && 0 === Object.keys(value).length;
|
|
12
|
-
}
|
|
13
|
-
function last(array) {
|
|
14
|
-
return array[array.length - 1];
|
|
15
|
-
}
|
|
16
|
-
function compact(array) {
|
|
17
|
-
return array.filter((item)=>null != item || !item);
|
|
18
|
-
}
|
|
19
|
-
function isNil(value) {
|
|
20
|
-
return null == value;
|
|
21
|
-
}
|
|
22
|
-
const isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && Object.getPrototypeOf(obj) === Object.prototype;
|
|
23
|
-
const isString = (v)=>'string' == typeof v || !!v && 'object' == typeof v && !Array.isArray(v) && '[object String]' === ({}).toString.call(v);
|
|
24
|
-
function pick(obj, keys) {
|
|
25
|
-
const result = {};
|
|
26
|
-
for(let i = 0; i < keys.length; i++){
|
|
27
|
-
const key = keys[i];
|
|
28
|
-
if (Object.hasOwn(obj, key)) result[key] = obj[key];
|
|
29
|
-
}
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
|
-
export { compact, isEmpty, isNil, isNumber, isObject, isPlainObject, isString, isUndefined, last, pick };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { decompressText } from "./algorithm.mjs";
|
|
2
|
-
import { isRemoteUrl } from "./url.mjs";
|
|
3
|
-
function isShardingData(data) {
|
|
4
|
-
if (Array.isArray(data) && data.length > 0) {
|
|
5
|
-
if (data.every((e)=>isRemoteUrl(e))) return true;
|
|
6
|
-
}
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
async function fetchShardingData(shardingFiles, fetchImplement) {
|
|
10
|
-
const res = await Promise.all(shardingFiles.map((url)=>fetchImplement(url)));
|
|
11
|
-
const strings = 0 === res.length ? [] : res.reduce((t, e)=>t + e);
|
|
12
|
-
return 'object' == typeof strings ? strings : JSON.parse(decompressText(strings));
|
|
13
|
-
}
|
|
14
|
-
async function fetchShardingFiles(data, fetchImplement, filterKeys) {
|
|
15
|
-
const datas = await Promise.all(Object.keys(data).map(async (_key)=>{
|
|
16
|
-
const key = _key;
|
|
17
|
-
const val = data[key];
|
|
18
|
-
if ((null == filterKeys ? void 0 : filterKeys.length) && filterKeys.indexOf(key) < 0) return {
|
|
19
|
-
[key]: []
|
|
20
|
-
};
|
|
21
|
-
if (isShardingData(val)) return {
|
|
22
|
-
[key]: await fetchShardingData(val, fetchImplement)
|
|
23
|
-
};
|
|
24
|
-
return {
|
|
25
|
-
[key]: val
|
|
26
|
-
};
|
|
27
|
-
}));
|
|
28
|
-
return datas.reduce((t, c)=>Object.assign(t, c));
|
|
29
|
-
}
|
|
30
|
-
export { fetchShardingData, fetchShardingFiles, isShardingData };
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { compact, isEmpty, last } from "./lodash.mjs";
|
|
2
|
-
const PACKAGE_PREFIX = /(?:node_modules|~)(?:\/\.pnpm)?/;
|
|
3
|
-
const PACKAGE_SLUG = /[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*/;
|
|
4
|
-
const VERSION = /@[\w|\-|_|.]+/;
|
|
5
|
-
const VERSION_NUMBER = '@([\\d.]+)';
|
|
6
|
-
const MODULE_PATH_PACKAGES = new RegExp([
|
|
7
|
-
`(?:${PACKAGE_PREFIX.source}/)`,
|
|
8
|
-
'(?:',
|
|
9
|
-
`(?:@${PACKAGE_SLUG.source}[/|+])?`,
|
|
10
|
-
`(?:${PACKAGE_SLUG.source}\\+)*`,
|
|
11
|
-
`(?:${PACKAGE_SLUG.source})`,
|
|
12
|
-
`(?:${VERSION.source})?`,
|
|
13
|
-
')',
|
|
14
|
-
'(?:_',
|
|
15
|
-
`(?:@${PACKAGE_SLUG.source}[/|+])?`,
|
|
16
|
-
`(?:${PACKAGE_SLUG.source})`,
|
|
17
|
-
`(?:@${PACKAGE_SLUG.source})?`,
|
|
18
|
-
')*',
|
|
19
|
-
'/'
|
|
20
|
-
].join(''), 'g');
|
|
21
|
-
const PACKAGE_PATH_NAME = /(?:(?:node_modules|~)(?:\/\.pnpm)?\/)(?:((?:@[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*[/|+])?(?:(?:[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*\+)*)(?:[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*))(?:@[\w|\-|_|.]+)?)(?:_((?:@[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*[/|+])?(?:[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*))(?:@[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*))*\//gm;
|
|
22
|
-
const uniqLast = (data)=>{
|
|
23
|
-
const res = [];
|
|
24
|
-
data.forEach((item, index)=>{
|
|
25
|
-
if (!data.slice(index + 1).includes(item)) res.push(item);
|
|
26
|
-
});
|
|
27
|
-
return res;
|
|
28
|
-
};
|
|
29
|
-
const getPackageMetaFromModulePath = (modulePath)=>{
|
|
30
|
-
var _path_match_flat_slice, _path_match;
|
|
31
|
-
const paths = modulePath.match(MODULE_PATH_PACKAGES);
|
|
32
|
-
if (!paths) return {
|
|
33
|
-
name: '',
|
|
34
|
-
version: ''
|
|
35
|
-
};
|
|
36
|
-
const names = uniqLast(paths.flatMap((packagePath)=>{
|
|
37
|
-
const found = packagePath.matchAll(PACKAGE_PATH_NAME);
|
|
38
|
-
if (!found) return [];
|
|
39
|
-
const paksArray = compact([
|
|
40
|
-
...found
|
|
41
|
-
].flat());
|
|
42
|
-
return paksArray.slice(1).filter(Boolean).map((name)=>name.replace(/\+/g, '/'));
|
|
43
|
-
}));
|
|
44
|
-
if (isEmpty(names)) return {
|
|
45
|
-
name: '',
|
|
46
|
-
version: ''
|
|
47
|
-
};
|
|
48
|
-
const name = last(names);
|
|
49
|
-
const pattern = new RegExp(`(.*)(${last(paths)}).*`);
|
|
50
|
-
const path = modulePath.replace(pattern, '$1$2').replace(/\/$/, '');
|
|
51
|
-
return {
|
|
52
|
-
name,
|
|
53
|
-
version: path && name ? (null == (_path_match = path.match(new RegExp(`${name}${VERSION_NUMBER}`))) ? void 0 : null == (_path_match_flat_slice = _path_match.flat().slice(1)) ? void 0 : _path_match_flat_slice[0]) || '' : ''
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
export { MODULE_PATH_PACKAGES, PACKAGE_PATH_NAME, getPackageMetaFromModulePath };
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
function getPluginHooks(plugin) {
|
|
2
|
-
return Object.keys(plugin);
|
|
3
|
-
}
|
|
4
|
-
function getPluginTapNames(plugin) {
|
|
5
|
-
const hooks = getPluginHooks(plugin);
|
|
6
|
-
const tapNames = new Set();
|
|
7
|
-
hooks.forEach((hook)=>{
|
|
8
|
-
plugin[hook].forEach((data)=>{
|
|
9
|
-
tapNames.add(data.tapName);
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
return [
|
|
13
|
-
...tapNames
|
|
14
|
-
];
|
|
15
|
-
}
|
|
16
|
-
function getPluginSummary(plugin) {
|
|
17
|
-
return {
|
|
18
|
-
hooks: getPluginHooks(plugin),
|
|
19
|
-
tapNames: getPluginTapNames(plugin)
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
function getPluginData(plugin, selectedHooks = [], selectedTapNames = []) {
|
|
23
|
-
const hooks = getPluginHooks(plugin).filter((hook)=>{
|
|
24
|
-
if (selectedHooks.length && -1 === selectedHooks.indexOf(hook)) return false;
|
|
25
|
-
return true;
|
|
26
|
-
});
|
|
27
|
-
if (!hooks.length) return [];
|
|
28
|
-
const tapNames = getPluginTapNames(plugin);
|
|
29
|
-
return tapNames.reduce((total, tapName)=>{
|
|
30
|
-
if (selectedTapNames.length && -1 === selectedTapNames.indexOf(tapName)) return total;
|
|
31
|
-
hooks.forEach((hook)=>{
|
|
32
|
-
const hookData = plugin[hook].filter((e)=>e.tapName === tapName);
|
|
33
|
-
if (0 === hookData.length) return;
|
|
34
|
-
total.push({
|
|
35
|
-
tapName,
|
|
36
|
-
hook,
|
|
37
|
-
data: hookData.map((e)=>({
|
|
38
|
-
startAt: e.startAt,
|
|
39
|
-
endAt: e.endAt,
|
|
40
|
-
costs: e.costs,
|
|
41
|
-
type: e.type
|
|
42
|
-
}))
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
return total;
|
|
46
|
-
}, []);
|
|
47
|
-
}
|
|
48
|
-
export { getPluginData, getPluginHooks, getPluginSummary, getPluginTapNames };
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { mergeIntervals } from "./algorithm.mjs";
|
|
2
|
-
function isResolveSuccessData(data) {
|
|
3
|
-
return Boolean(data.result);
|
|
4
|
-
}
|
|
5
|
-
function isResolveFailData(data) {
|
|
6
|
-
return Boolean(data.error);
|
|
7
|
-
}
|
|
8
|
-
function getResolverCosts(resolver, resolvers) {
|
|
9
|
-
const blocked = resolvers.filter((e)=>e !== resolver && e.pid === resolver.pid && e.startAt >= resolver.startAt && e.endAt <= resolver.endAt);
|
|
10
|
-
let costs = resolver.endAt - resolver.startAt;
|
|
11
|
-
if (blocked.length) {
|
|
12
|
-
const intervals = blocked.map((e)=>[
|
|
13
|
-
Math.max(e.startAt, resolver.startAt),
|
|
14
|
-
Math.min(e.endAt, resolver.endAt)
|
|
15
|
-
]);
|
|
16
|
-
mergeIntervals(intervals).forEach((e)=>{
|
|
17
|
-
const sub = e[1] - e[0];
|
|
18
|
-
costs -= sub;
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
return costs;
|
|
22
|
-
}
|
|
23
|
-
function getResolverFileTree(resolver) {
|
|
24
|
-
return resolver.map((e)=>({
|
|
25
|
-
issuerPath: e.issuerPath
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
function getResolverFileDetails(filepath, resolvers, modules, moduleCodeMap) {
|
|
29
|
-
const module = modules.find((item)=>item.path === filepath);
|
|
30
|
-
const matchResolvers = resolvers.filter((e)=>e.issuerPath === filepath);
|
|
31
|
-
const before = module && moduleCodeMap && moduleCodeMap[module.id] ? moduleCodeMap[module.id].source : '';
|
|
32
|
-
const after = matchResolvers.reduce((t, c)=>{
|
|
33
|
-
if (c.request && isResolveSuccessData(c)) return t.replace(new RegExp(`["']${c.request}["']`), `"${c.result}"`);
|
|
34
|
-
return t;
|
|
35
|
-
}, before);
|
|
36
|
-
return {
|
|
37
|
-
filepath,
|
|
38
|
-
before,
|
|
39
|
-
after,
|
|
40
|
-
resolvers: matchResolvers.map((e)=>({
|
|
41
|
-
...e,
|
|
42
|
-
costs: getResolverCosts(e, resolvers)
|
|
43
|
-
}))
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
export { getResolverCosts, getResolverFileDetails, getResolverFileTree, isResolveFailData, isResolveSuccessData };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const RspackLoaderInternalPropertyName = '__l__';
|
|
2
|
-
var rspack_RspackSummaryCostsDataName = /*#__PURE__*/ function(RspackSummaryCostsDataName) {
|
|
3
|
-
RspackSummaryCostsDataName["Bootstrap"] = "bootstrap->rspack:beforeCompile";
|
|
4
|
-
RspackSummaryCostsDataName["Compile"] = "rspack:beforeCompile->afterCompile";
|
|
5
|
-
RspackSummaryCostsDataName["Done"] = "rspack:afterCompile->done";
|
|
6
|
-
RspackSummaryCostsDataName["Minify"] = "rspack:minify(rspack:optimizeChunkAssets)";
|
|
7
|
-
return RspackSummaryCostsDataName;
|
|
8
|
-
}({});
|
|
9
|
-
function checkSourceMapSupport(configs) {
|
|
10
|
-
var _configs__config, _configs_, _configs__config1, _configs__config2;
|
|
11
|
-
if (!Array.isArray(configs) || !configs[0]) return {
|
|
12
|
-
isRspack: false,
|
|
13
|
-
hasSourceMap: false
|
|
14
|
-
};
|
|
15
|
-
const isRspack = 'rspack' === configs[0].name && (null == (_configs_ = configs[0]) ? void 0 : null == (_configs__config = _configs_.config) ? void 0 : _configs__config.name) !== 'lynx';
|
|
16
|
-
const devtool = null == (_configs__config1 = configs[0].config) ? void 0 : _configs__config1.devtool;
|
|
17
|
-
const plugins = null == (_configs__config2 = configs[0].config) ? void 0 : _configs__config2.plugins;
|
|
18
|
-
const hasLynxSourcemapPlugin = null == plugins ? void 0 : plugins.filter((plugin)=>plugin && plugin.includes('SourceMapDevToolPlugin'));
|
|
19
|
-
const hasSourceMap = 'string' == typeof devtool && devtool.includes('source-map') && !devtool.includes('eval') || !!(null == hasLynxSourcemapPlugin ? void 0 : hasLynxSourcemapPlugin.length);
|
|
20
|
-
return {
|
|
21
|
-
isRspack,
|
|
22
|
-
hasSourceMap
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
export { RspackLoaderInternalPropertyName, rspack_RspackSummaryCostsDataName as RspackSummaryCostsDataName, checkSourceMapSupport };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
var summary_SummaryCostsDataName = /*#__PURE__*/ function(SummaryCostsDataName) {
|
|
2
|
-
SummaryCostsDataName["Bootstrap"] = "bootstrap->beforeCompile";
|
|
3
|
-
SummaryCostsDataName["Compile"] = "beforeCompile->afterCompile";
|
|
4
|
-
SummaryCostsDataName["Done"] = "afterCompile->done";
|
|
5
|
-
SummaryCostsDataName["Minify"] = "minify(processAssets)";
|
|
6
|
-
return SummaryCostsDataName;
|
|
7
|
-
}({});
|
|
8
|
-
export { summary_SummaryCostsDataName as SummaryCostsDataName };
|
package/dist/esm/common/time.mjs
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { hrtime } from "process";
|
|
2
|
-
function toFixedDigits(num, digits = 2) {
|
|
3
|
-
if (0 === digits) return Math.floor(num);
|
|
4
|
-
return +num.toFixed(digits);
|
|
5
|
-
}
|
|
6
|
-
function getUnit(num, type) {
|
|
7
|
-
let unit;
|
|
8
|
-
unit = 'm' === type ? num > 1 ? 'mins' : 'min' : num > 1 ? 'hours' : 'hour';
|
|
9
|
-
return unit;
|
|
10
|
-
}
|
|
11
|
-
function formatCosts(costs) {
|
|
12
|
-
costs = Number(costs);
|
|
13
|
-
if (costs >= 1000) {
|
|
14
|
-
const sec = costs / 1000;
|
|
15
|
-
if (sec >= 60) {
|
|
16
|
-
let mins = sec / 60;
|
|
17
|
-
if (mins >= 60) {
|
|
18
|
-
const hours = toFixedDigits(mins / 60, 0);
|
|
19
|
-
const restMins = toFixedDigits(mins % 60, 1);
|
|
20
|
-
const hUnit = getUnit(hours, 'h');
|
|
21
|
-
if (restMins > 0) return `${hours}${hUnit} ${restMins}${getUnit(restMins, 'm')}`;
|
|
22
|
-
return `${hours}${hUnit}`;
|
|
23
|
-
}
|
|
24
|
-
mins = toFixedDigits(mins, 0);
|
|
25
|
-
const mUnit = getUnit(mins, 'm');
|
|
26
|
-
const restSec = toFixedDigits(sec % 60, 0);
|
|
27
|
-
if (restSec > 0) return `${mins}${mUnit} ${restSec}s`;
|
|
28
|
-
return `${mins}${mUnit}`;
|
|
29
|
-
}
|
|
30
|
-
return `${toFixedDigits(sec, 1)}s`;
|
|
31
|
-
}
|
|
32
|
-
if (costs >= 10) return `${+toFixedDigits(costs, 0)}ms`;
|
|
33
|
-
if (costs >= 1) return `${+toFixedDigits(costs, 1)}ms`;
|
|
34
|
-
let r = +toFixedDigits(costs, 2);
|
|
35
|
-
if (0 === r) r = +toFixedDigits(costs, 3);
|
|
36
|
-
return `${r}ms`;
|
|
37
|
-
}
|
|
38
|
-
function getCurrentTimestamp(start, startHRTime) {
|
|
39
|
-
const endHRTime = hrtime(startHRTime);
|
|
40
|
-
const end = start + 1000 * endHRTime[0] + (process.env.RSTEST ? Math.round(endHRTime[1] / 1000000) : endHRTime[1] / 1000000);
|
|
41
|
-
return end;
|
|
42
|
-
}
|
|
43
|
-
export { formatCosts, getCurrentTimestamp, getUnit, toFixedDigits };
|