@bundle-stats/utils 4.0.0-alpha.9 → 4.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/report/create.js +2 -4
- package/lib/report/create.js.map +1 -1
- package/lib/webpack/extract/assets.js +27 -32
- package/lib/webpack/extract/assets.js.map +1 -1
- package/lib/webpack/extract/index.js +0 -2
- package/lib/webpack/extract/index.js.map +1 -1
- package/lib/webpack/extract/modules-packages-duplicate.js +1 -1
- package/lib/webpack/extract/modules-packages-duplicate.js.map +1 -1
- package/lib/webpack/extract/modules-packages.js +4 -5
- package/lib/webpack/extract/modules-packages.js.map +1 -1
- package/lib/webpack/extract/modules.js +9 -4
- package/lib/webpack/extract/modules.js.map +1 -1
- package/lib/webpack/index.js +1 -0
- package/lib/webpack/index.js.map +1 -1
- package/lib/webpack/metrics.js +11 -11
- package/lib/webpack/metrics.js.map +1 -1
- package/lib/webpack/types.js +3 -0
- package/lib/webpack/types.js.map +1 -0
- package/lib/webpack/utils.js +1 -1
- package/lib/webpack/utils.js.map +1 -1
- package/lib-esm/webpack/extract/assets.js +27 -31
- package/lib-esm/webpack/extract/assets.js.map +1 -1
- package/lib-esm/webpack/extract/index.js +0 -2
- package/lib-esm/webpack/extract/index.js.map +1 -1
- package/lib-esm/webpack/extract/modules-packages.js +3 -3
- package/lib-esm/webpack/extract/modules-packages.js.map +1 -1
- package/lib-esm/webpack/extract/modules.js +9 -4
- package/lib-esm/webpack/extract/modules.js.map +1 -1
- package/lib-esm/webpack/index.js +1 -0
- package/lib-esm/webpack/index.js.map +1 -1
- package/lib-esm/webpack/metrics.js +11 -11
- package/lib-esm/webpack/metrics.js.map +1 -1
- package/lib-esm/webpack/types.js +2 -0
- package/lib-esm/webpack/types.js.map +1 -0
- package/package.json +7 -7
- package/src/constants.ts +0 -24
- package/src/webpack/extract/assets.ts +39 -62
- package/src/webpack/extract/index.js +2 -7
- package/src/webpack/extract/modules-packages.ts +7 -7
- package/src/webpack/extract/modules.ts +14 -18
- package/src/webpack/index.js +1 -0
- package/src/webpack/metrics.js +11 -11
- package/src/webpack/types.ts +54 -0
- package/types/constants.d.ts +0 -20
- package/types/webpack/extract/assets.d.ts +3 -11
- package/types/webpack/extract/modules-packages.d.ts +2 -2
- package/types/webpack/extract/modules.d.ts +3 -2
- package/types/webpack/index.d.ts +1 -0
- package/types/webpack/types.d.ts +45 -0
- package/lib/webpack/extract/modules-count.js +0 -14
- package/lib/webpack/extract/modules-count.js.map +0 -1
- package/lib-esm/webpack/extract/modules-count.js +0 -7
- package/lib-esm/webpack/extract/modules-count.js.map +0 -1
- package/src/webpack/extract/modules-count.js +0 -8
- package/types/webpack/extract/modules-count.d.ts +0 -7
package/src/webpack/metrics.js
CHANGED
|
@@ -7,74 +7,74 @@ import {
|
|
|
7
7
|
export const metrics = {
|
|
8
8
|
totalSizeByTypeALL: {
|
|
9
9
|
label: 'Bundle Size',
|
|
10
|
-
description: '
|
|
10
|
+
description: 'The total size of the assets produced by webpack',
|
|
11
11
|
url: 'https://relative-ci.com/documentation/metrics-and-data#assets',
|
|
12
12
|
type: METRIC_TYPE_FILE_SIZE,
|
|
13
13
|
},
|
|
14
14
|
totalInitialSizeJS: {
|
|
15
15
|
label: 'Initial JS',
|
|
16
|
-
description: '
|
|
16
|
+
description: 'The total size of JavaScript initial chunks',
|
|
17
17
|
url: 'https://relative-ci.com/documentation/metrics-and-data#assets',
|
|
18
18
|
type: METRIC_TYPE_FILE_SIZE,
|
|
19
19
|
},
|
|
20
20
|
totalInitialSizeCSS: {
|
|
21
21
|
label: 'Initial CSS',
|
|
22
|
-
description: '
|
|
22
|
+
description: 'The total size of CSS initial chunks',
|
|
23
23
|
url: 'https://relative-ci.com/documentation/metrics-and-data#assets',
|
|
24
24
|
type: METRIC_TYPE_FILE_SIZE,
|
|
25
25
|
},
|
|
26
26
|
cacheInvalidation: {
|
|
27
27
|
label: 'Cache Invalidation',
|
|
28
|
-
description: '
|
|
28
|
+
description: 'The ratio between the total changed assets and total assets size(Bundle Size)',
|
|
29
29
|
url: 'https://relative-ci.com/documentation/metrics-and-data#assets',
|
|
30
30
|
type: METRIC_TYPE_PERCENTAGE,
|
|
31
31
|
biggerIsBetter: false,
|
|
32
32
|
},
|
|
33
33
|
chunkCount: {
|
|
34
34
|
label: 'Chunks',
|
|
35
|
-
description: '
|
|
35
|
+
description: 'The total number of chunks',
|
|
36
36
|
url: 'https://relative-ci.com/documentation/metrics-and-data#assets',
|
|
37
37
|
type: METRIC_TYPE_NUMERIC,
|
|
38
38
|
biggerIsBetter: false,
|
|
39
39
|
},
|
|
40
40
|
assetCount: {
|
|
41
41
|
label: 'Assets',
|
|
42
|
-
description: 'Total number of assets
|
|
42
|
+
description: 'Total number of assets',
|
|
43
43
|
url: 'https://relative-ci.com/documentation/metrics-and-data#assets',
|
|
44
44
|
type: METRIC_TYPE_NUMERIC,
|
|
45
45
|
biggerIsBetter: false,
|
|
46
46
|
},
|
|
47
47
|
moduleCount: {
|
|
48
48
|
label: 'Modules',
|
|
49
|
-
description: '
|
|
49
|
+
description: 'The total number of modules bundled by webpack',
|
|
50
50
|
url: 'https://relative-ci.com/documentation/metrics-and-data#modules-1',
|
|
51
51
|
type: METRIC_TYPE_NUMERIC,
|
|
52
52
|
biggerIsBetter: false,
|
|
53
53
|
},
|
|
54
54
|
duplicateModulesCount: {
|
|
55
55
|
label: 'Duplicate Modules',
|
|
56
|
-
description: '
|
|
56
|
+
description: 'The total number of modules that belong to more than one chunk',
|
|
57
57
|
url: 'https://relative-ci.com/documentation/metrics-and-data#modules-1',
|
|
58
58
|
type: METRIC_TYPE_NUMERIC,
|
|
59
59
|
biggerIsBetter: false,
|
|
60
60
|
},
|
|
61
61
|
duplicateCode: {
|
|
62
62
|
label: 'Duplicate Code',
|
|
63
|
-
description: 'The percentage of total duplicate module size from the total module size
|
|
63
|
+
description: 'The percentage of total duplicate module size from the total module size',
|
|
64
64
|
url: 'https://relative-ci.com/documentation/metrics-and-data#modules-1',
|
|
65
65
|
type: METRIC_TYPE_PERCENTAGE,
|
|
66
66
|
biggerIsBetter: false,
|
|
67
67
|
},
|
|
68
68
|
packageCount: {
|
|
69
69
|
label: 'Packages',
|
|
70
|
-
description: '
|
|
70
|
+
description: 'The total number of packages bundled by webpack',
|
|
71
71
|
url: 'https://relative-ci.com/documentation/metrics-and-data#packages',
|
|
72
72
|
type: METRIC_TYPE_NUMERIC,
|
|
73
73
|
biggerIsBetter: false,
|
|
74
74
|
},
|
|
75
75
|
duplicatePackagesCount: {
|
|
76
76
|
label: 'Duplicate Packages',
|
|
77
|
-
description: '
|
|
77
|
+
description: 'The total number of duplicate packages',
|
|
78
78
|
url: 'https://relative-ci.com/documentation/metrics-and-data#packages',
|
|
79
79
|
type: METRIC_TYPE_NUMERIC,
|
|
80
80
|
biggerIsBetter: false,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Metric, MetricRun } from '../constants';
|
|
2
|
+
|
|
3
|
+
interface MetaChunk {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface Asset extends Metric {
|
|
9
|
+
name: string;
|
|
10
|
+
isEntry: boolean;
|
|
11
|
+
isInitial: boolean;
|
|
12
|
+
isChunk: boolean;
|
|
13
|
+
chunkId?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type Assets = Record<string, Asset>;
|
|
17
|
+
|
|
18
|
+
export interface MetricsAssets {
|
|
19
|
+
metrics: {
|
|
20
|
+
assets: Assets;
|
|
21
|
+
};
|
|
22
|
+
meta?: {
|
|
23
|
+
chunks: Array<MetaChunk>;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface Module extends Metric {
|
|
28
|
+
name: string;
|
|
29
|
+
chunkIds: Array<String>;
|
|
30
|
+
duplicated: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type Modules = Record<string, Module>;
|
|
34
|
+
|
|
35
|
+
export interface MetricsModules {
|
|
36
|
+
metrics: {
|
|
37
|
+
duplicateCode: MetricRun;
|
|
38
|
+
duplicateModulesCount: MetricRun;
|
|
39
|
+
modules: Modules;
|
|
40
|
+
moduleCount: MetricRun;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface Package extends Metric {
|
|
45
|
+
path: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type Packages = Record<string, Package>;
|
|
49
|
+
|
|
50
|
+
export interface MetricsPackages {
|
|
51
|
+
metrics: {
|
|
52
|
+
packages: Packages;
|
|
53
|
+
};
|
|
54
|
+
}
|
package/types/constants.d.ts
CHANGED
|
@@ -37,26 +37,6 @@ export interface MetricRunInfo {
|
|
|
37
37
|
export interface Metric {
|
|
38
38
|
value: number;
|
|
39
39
|
}
|
|
40
|
-
export interface ModuleMetric extends Metric {
|
|
41
|
-
name: string;
|
|
42
|
-
chunkIds: Array<String>;
|
|
43
|
-
duplicated: boolean;
|
|
44
|
-
}
|
|
45
|
-
export interface PackageMetric extends Metric {
|
|
46
|
-
path: string;
|
|
47
|
-
}
|
|
48
|
-
export interface WebpackMetricsModules {
|
|
49
|
-
metrics: {
|
|
50
|
-
duplicateCode: MetricRun;
|
|
51
|
-
duplicateModulesCount: MetricRun;
|
|
52
|
-
modules: Record<string, ModuleMetric>;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
export interface WebpackMetricsPackages {
|
|
56
|
-
metrics: {
|
|
57
|
-
packages: Record<string, PackageMetric>;
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
40
|
export interface LighthouseSource {
|
|
61
41
|
lighthouseVersion: string;
|
|
62
42
|
fetchTime: string;
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
id: string;
|
|
5
|
-
name: string;
|
|
6
|
-
}[];
|
|
7
|
-
} | undefined;
|
|
8
|
-
metrics: {
|
|
9
|
-
assets: {};
|
|
10
|
-
};
|
|
11
|
-
};
|
|
1
|
+
import { WebpackStatsFiltered } from '@bundle-stats/plugin-webpack-filter';
|
|
2
|
+
import { MetricsAssets } from '../types';
|
|
3
|
+
export declare const extractAssets: (webpackStats: WebpackStatsFiltered) => MetricsAssets;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MetricsModules, MetricsPackages } from '../types';
|
|
2
2
|
export declare const getPackageMetaFromModulePath: (modulePath: string) => {
|
|
3
3
|
id: string;
|
|
4
4
|
name: unknown;
|
|
5
5
|
path: string;
|
|
6
6
|
} | null;
|
|
7
|
-
export declare const extractModulesPackages: (
|
|
7
|
+
export declare const extractModulesPackages: (_?: unknown, currentExtractedData?: MetricsModules) => MetricsPackages;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { WebpackStatsFiltered } from '@bundle-stats/plugin-webpack-filter';
|
|
2
|
+
import { MetricsModules } from '../types';
|
|
3
|
+
export declare const extractModules: (webpackStats?: WebpackStatsFiltered) => MetricsModules;
|
package/types/webpack/index.d.ts
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Metric, MetricRun } from '../constants';
|
|
2
|
+
interface MetaChunk {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
6
|
+
export interface Asset extends Metric {
|
|
7
|
+
name: string;
|
|
8
|
+
isEntry: boolean;
|
|
9
|
+
isInitial: boolean;
|
|
10
|
+
isChunk: boolean;
|
|
11
|
+
chunkId?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare type Assets = Record<string, Asset>;
|
|
14
|
+
export interface MetricsAssets {
|
|
15
|
+
metrics: {
|
|
16
|
+
assets: Assets;
|
|
17
|
+
};
|
|
18
|
+
meta?: {
|
|
19
|
+
chunks: Array<MetaChunk>;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface Module extends Metric {
|
|
23
|
+
name: string;
|
|
24
|
+
chunkIds: Array<String>;
|
|
25
|
+
duplicated: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare type Modules = Record<string, Module>;
|
|
28
|
+
export interface MetricsModules {
|
|
29
|
+
metrics: {
|
|
30
|
+
duplicateCode: MetricRun;
|
|
31
|
+
duplicateModulesCount: MetricRun;
|
|
32
|
+
modules: Modules;
|
|
33
|
+
moduleCount: MetricRun;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface Package extends Metric {
|
|
37
|
+
path: string;
|
|
38
|
+
}
|
|
39
|
+
export declare type Packages = Record<string, Package>;
|
|
40
|
+
export interface MetricsPackages {
|
|
41
|
+
metrics: {
|
|
42
|
+
packages: Packages;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.extractModulesCount = void 0;
|
|
7
|
-
const get_1 = __importDefault(require("lodash/get"));
|
|
8
|
-
const extractModulesCount = (webpackStats, currentExtractedData = {}) => {
|
|
9
|
-
const modules = (0, get_1.default)(currentExtractedData, 'metrics.modules', {});
|
|
10
|
-
const value = Object.values(modules).length || 0;
|
|
11
|
-
return { metrics: { moduleCount: { value } } };
|
|
12
|
-
};
|
|
13
|
-
exports.extractModulesCount = extractModulesCount;
|
|
14
|
-
//# sourceMappingURL=modules-count.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"modules-count.js","sourceRoot":"","sources":["../../../src/webpack/extract/modules-count.js"],"names":[],"mappings":";;;;;;AAAA,qDAA6B;AAEtB,MAAM,mBAAmB,GAAG,CAAC,YAAY,EAAE,oBAAoB,GAAG,EAAE,EAAE,EAAE;IAC7E,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC,oBAAoB,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAC;IACjE,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC;IAEjD,OAAO,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AACjD,CAAC,CAAC;AALW,QAAA,mBAAmB,uBAK9B"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import get from 'lodash/get';
|
|
2
|
-
export const extractModulesCount = (webpackStats, currentExtractedData = {}) => {
|
|
3
|
-
const modules = get(currentExtractedData, 'metrics.modules', {});
|
|
4
|
-
const value = Object.values(modules).length || 0;
|
|
5
|
-
return { metrics: { moduleCount: { value } } };
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=modules-count.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"modules-count.js","sourceRoot":"","sources":["../../../src/webpack/extract/modules-count.js"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,YAAY,EAAE,oBAAoB,GAAG,EAAE,EAAE,EAAE;IAC7E,MAAM,OAAO,GAAG,GAAG,CAAC,oBAAoB,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAC;IACjE,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC;IAEjD,OAAO,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AACjD,CAAC,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import get from 'lodash/get';
|
|
2
|
-
|
|
3
|
-
export const extractModulesCount = (webpackStats, currentExtractedData = {}) => {
|
|
4
|
-
const modules = get(currentExtractedData, 'metrics.modules', {});
|
|
5
|
-
const value = Object.values(modules).length || 0;
|
|
6
|
-
|
|
7
|
-
return { metrics: { moduleCount: { value } } };
|
|
8
|
-
};
|