@bundle-stats/utils 4.7.5-beta.0 → 4.7.5-beta.3
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/browsertime/metrics.js +22 -22
- package/lib/browsertime/metrics.js.map +1 -1
- package/lib/config/index.js +1 -2
- package/lib/config/index.js.map +1 -1
- package/lib/config/metric-types.js +28 -0
- package/lib/config/metric-types.js.map +1 -0
- package/lib/constants.js +9 -19
- package/lib/constants.js.map +1 -1
- package/lib/lighthouse/metrics.js +13 -13
- package/lib/lighthouse/metrics.js.map +1 -1
- package/lib/report/add-row-metric-data.js +2 -2
- package/lib/report/add-row-metric-data.js.map +1 -1
- package/lib/report/create.js.map +1 -1
- package/lib/utils/delta.js +29 -26
- package/lib/utils/delta.js.map +1 -1
- package/lib/utils/metrics.js +47 -29
- package/lib/utils/metrics.js.map +1 -1
- package/lib/webpack/compare.js +11 -11
- package/lib/webpack/compare.js.map +1 -1
- package/lib/webpack/metrics.js +23 -23
- package/lib/webpack/metrics.js.map +1 -1
- package/lib-esm/browsertime/metrics.js +22 -22
- package/lib-esm/browsertime/metrics.js.map +1 -1
- package/lib-esm/config/index.js +1 -2
- package/lib-esm/config/index.js.map +1 -1
- package/lib-esm/config/metric-types.js +25 -0
- package/lib-esm/config/metric-types.js.map +1 -0
- package/lib-esm/constants.js +8 -18
- package/lib-esm/constants.js.map +1 -1
- package/lib-esm/lighthouse/metrics.js +13 -13
- package/lib-esm/lighthouse/metrics.js.map +1 -1
- package/lib-esm/report/add-row-metric-data.js +2 -2
- package/lib-esm/report/add-row-metric-data.js.map +1 -1
- package/lib-esm/report/create.js.map +1 -1
- package/lib-esm/utils/delta.js +29 -26
- package/lib-esm/utils/delta.js.map +1 -1
- package/lib-esm/utils/metrics.js +44 -27
- package/lib-esm/utils/metrics.js.map +1 -1
- package/lib-esm/webpack/compare.js +4 -4
- package/lib-esm/webpack/compare.js.map +1 -1
- package/lib-esm/webpack/metrics.js +24 -24
- package/lib-esm/webpack/metrics.js.map +1 -1
- package/package.json +4 -4
- package/src/browsertime/metrics.js +22 -22
- package/src/config/index.js +1 -2
- package/src/config/metric-types.ts +25 -0
- package/src/constants.ts +64 -28
- package/src/lighthouse/metrics.js +13 -15
- package/src/report/add-row-metric-data.ts +3 -2
- package/src/report/create.ts +1 -1
- package/src/utils/delta.ts +91 -0
- package/src/utils/metrics.ts +81 -0
- package/src/webpack/compare.js +19 -12
- package/src/webpack/metrics.ts +26 -41
- package/types/browsertime/metrics.d.ts +43 -23
- package/types/config/index.d.ts +1 -2
- package/types/config/metric-types.d.ts +2 -0
- package/types/constants.d.ts +24 -22
- package/types/lighthouse/metrics.d.ts +25 -17
- package/types/report/add-row-metric-data.d.ts +4 -3
- package/types/utils/delta.d.ts +4 -6
- package/types/utils/metrics.d.ts +4 -3
- package/types/webpack/metrics.d.ts +3 -11
- package/types/webpack/utils.d.ts +1 -1
- package/lib/config/delta.js +0 -13
- package/lib/config/delta.js.map +0 -1
- package/lib/config/metrics.js +0 -32
- package/lib/config/metrics.js.map +0 -1
- package/lib-esm/config/delta.js +0 -10
- package/lib-esm/config/delta.js.map +0 -1
- package/lib-esm/config/metrics.js +0 -29
- package/lib-esm/config/metrics.js.map +0 -1
- package/src/config/delta.js +0 -11
- package/src/config/metrics.js +0 -31
- package/src/utils/delta.js +0 -94
- package/src/utils/metrics.js +0 -92
- package/types/config/delta.d.ts +0 -9
- package/types/config/metrics.d.ts +0 -6
package/lib-esm/utils/metrics.js
CHANGED
|
@@ -1,40 +1,56 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { formatPercentage } from './format';
|
|
2
|
+
import { MetricTypes } from '../constants';
|
|
3
|
+
import { METRIC_TYPE_CONFIGS } from '../config';
|
|
5
4
|
import { metrics as webpackMetricTypes } from '../webpack/metrics';
|
|
6
5
|
import { metrics as lighthouseMetricTypes } from '../lighthouse/metrics';
|
|
7
6
|
import { metrics as browsertimeMeticTypes } from '../browsertime/metrics';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import { formatPercentage } from './format';
|
|
8
|
+
import { formatDelta, getDelta, getDeltaType } from './delta';
|
|
9
|
+
export function createGetMetricType(metrics) {
|
|
10
|
+
return function getMetricType(key, type) {
|
|
11
|
+
const metric = get(metrics, key);
|
|
12
|
+
if (metric === null || metric === void 0 ? void 0 : metric.type) {
|
|
13
|
+
return {
|
|
14
|
+
...METRIC_TYPE_CONFIGS[metric.type],
|
|
15
|
+
...metric,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const resolvedType = type || MetricTypes.Numeric;
|
|
11
19
|
return {
|
|
12
|
-
...
|
|
13
|
-
|
|
20
|
+
...METRIC_TYPE_CONFIGS[resolvedType],
|
|
21
|
+
type: resolvedType,
|
|
22
|
+
label: key,
|
|
14
23
|
};
|
|
15
|
-
}
|
|
16
|
-
const resolvedType = type || METRIC_TYPE_NUMERIC;
|
|
17
|
-
return {
|
|
18
|
-
...METRIC_TYPES[resolvedType],
|
|
19
|
-
type: resolvedType,
|
|
20
|
-
label: key,
|
|
21
24
|
};
|
|
22
|
-
}
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
}
|
|
26
|
+
export function getGlobalMetricType(key, type) {
|
|
27
|
+
const getMetricType = createGetMetricType({
|
|
28
|
+
webpack: webpackMetricTypes,
|
|
29
|
+
lighthouse: lighthouseMetricTypes,
|
|
30
|
+
browsertime: browsertimeMeticTypes,
|
|
31
|
+
});
|
|
32
|
+
return getMetricType(key, type);
|
|
33
|
+
}
|
|
34
|
+
export function getMetricRunInfo(metricType, current, baseline) {
|
|
35
|
+
const { formatter, biggerIsBetter } = metricType;
|
|
30
36
|
const runInfo = {
|
|
31
|
-
value:
|
|
32
|
-
displayValue: formatter(
|
|
37
|
+
value: current,
|
|
38
|
+
displayValue: formatter(current),
|
|
33
39
|
};
|
|
34
|
-
if (typeof
|
|
40
|
+
if (typeof baseline === 'undefined') {
|
|
35
41
|
return runInfo;
|
|
36
42
|
}
|
|
37
|
-
const { delta, deltaPercentage } = getDelta({ value:
|
|
43
|
+
const { delta, deltaPercentage } = getDelta({ value: baseline }, { value: current });
|
|
44
|
+
let regression;
|
|
45
|
+
if (biggerIsBetter === null) {
|
|
46
|
+
regression = null;
|
|
47
|
+
}
|
|
48
|
+
else if ((biggerIsBetter === true && delta > 0) || (biggerIsBetter === false && delta < 0)) {
|
|
49
|
+
regression = false;
|
|
50
|
+
}
|
|
51
|
+
else if ((biggerIsBetter === false && delta > 0) || (biggerIsBetter === true && delta < 0)) {
|
|
52
|
+
regression = true;
|
|
53
|
+
}
|
|
38
54
|
return {
|
|
39
55
|
...runInfo,
|
|
40
56
|
delta,
|
|
@@ -42,6 +58,7 @@ export const getMetricRunInfo = (metric, currentValue, baselineValue) => {
|
|
|
42
58
|
displayDelta: formatDelta(delta, formatter),
|
|
43
59
|
displayDeltaPercentage: formatDelta(deltaPercentage, formatPercentage),
|
|
44
60
|
deltaType: getDeltaType(deltaPercentage, biggerIsBetter),
|
|
61
|
+
regression,
|
|
45
62
|
};
|
|
46
|
-
}
|
|
63
|
+
}
|
|
47
64
|
//# sourceMappingURL=metrics.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/utils/metrics.
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/utils/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,EAAyB,WAAW,EAAkC,MAAM,cAAc,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,qBAAqB,E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,QAAQ,KAAK,WAAW,EAAE;QACnC,OAAO,OAAO,CAAC;KAChB;IAED,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IAGrF,IAAI,UAAU,CAAC;IAEf,IAAI,cAAc,KAAK,IAAI,EAAE;QAC3B,UAAU,GAAG,IAAI,CAAC;KACnB;SAAM,IAAI,CAAC,cAAc,KAAK,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,cAAc,KAAK,KAAK,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE;QAC5F,UAAU,GAAG,KAAK,CAAC;KACpB;SAAM,IAAI,CAAC,cAAc,KAAK,KAAK,IAAI,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,cAAc,KAAK,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE;QAC5F,UAAU,GAAG,IAAI,CAAC;KACnB;IAED,OAAO;QACL,GAAG,OAAO;QACV,KAAK;QACL,eAAe;QACf,YAAY,EAAE,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC;QAC3C,sBAAsB,EAAE,WAAW,CAAC,eAAe,EAAE,gBAAgB,CAAC;QACtE,SAAS,EAAE,YAAY,CAAC,eAAe,EAAE,cAAc,CAAC;QACxD,UAAU;KACX,CAAC;AACJ,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MetricTypes } from '../constants';
|
|
2
2
|
import { compareMetrics } from '../report/compare-metrics';
|
|
3
3
|
import { SECTION_WEBPACK_STATS, SECTION_WEBPACK_SIZES, SECTION_WEBPACK_ASSETS, SECTION_WEBPACK_MODULES, SECTION_WEBPACK_PACKAGES, SECTIONS, } from './constants';
|
|
4
4
|
import { selectors } from './selectors';
|
|
5
5
|
const compareStats = (jobs, rowTransformers) => compareMetrics(jobs, selectors.stats, undefined, rowTransformers);
|
|
6
6
|
const compareSizes = (jobs, rowTransformers) => compareMetrics(jobs, selectors.sizes, undefined, rowTransformers);
|
|
7
|
-
const compareAssets = (jobs, rowTransformers) => compareMetrics(jobs, selectors.assets,
|
|
8
|
-
const compareModules = (jobs, rowTransformers) => compareMetrics(jobs, selectors.modules,
|
|
9
|
-
const comparePackages = (jobs, rowTransformers) => compareMetrics(jobs, selectors.packages,
|
|
7
|
+
const compareAssets = (jobs, rowTransformers) => compareMetrics(jobs, selectors.assets, MetricTypes.FileSize, rowTransformers);
|
|
8
|
+
const compareModules = (jobs, rowTransformers) => compareMetrics(jobs, selectors.modules, MetricTypes.FileSize, rowTransformers);
|
|
9
|
+
const comparePackages = (jobs, rowTransformers) => compareMetrics(jobs, selectors.packages, MetricTypes.FileSize, rowTransformers);
|
|
10
10
|
export const compareBySection = {
|
|
11
11
|
[SECTION_WEBPACK_STATS]: compareStats,
|
|
12
12
|
[SECTION_WEBPACK_SIZES]: compareSizes,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compare.js","sourceRoot":"","sources":["../../src/webpack/compare.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"compare.js","sourceRoot":"","sources":["../../src/webpack/compare.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,QAAQ,GACT,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAUxC,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,eAAe,EAAE,EAAE,CAC7C,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;AAUpE,MAAM,YAAY,G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|
3
|
+
import { MetricTypes } from '../constants';
|
|
4
4
|
export const metrics = {
|
|
5
5
|
[Metric.BUNDLE_SIZE]: {
|
|
6
6
|
label: 'Bundle Size',
|
|
7
7
|
description: 'The total file size of the assets generated or processed by the bundler',
|
|
8
8
|
url: 'https://relative-ci.com/documentation/metrics-and-data#assets',
|
|
9
|
-
type:
|
|
9
|
+
type: MetricTypes.FileSize,
|
|
10
10
|
},
|
|
11
11
|
[Metric.INITIAL_SIZE_JS]: {
|
|
12
12
|
label: 'Initial JS',
|
|
13
13
|
description: 'The total file size of the JavaScript initial chunks',
|
|
14
14
|
url: 'https://relative-ci.com/documentation/metrics-and-data#assets',
|
|
15
|
-
type:
|
|
15
|
+
type: MetricTypes.FileSize,
|
|
16
16
|
},
|
|
17
17
|
[Metric.INITIAL_SIZE_CSS]: {
|
|
18
18
|
label: 'Initial CSS',
|
|
19
19
|
description: 'The total file size of the CSS initial chunks',
|
|
20
20
|
url: 'https://relative-ci.com/documentation/metrics-and-data#assets',
|
|
21
|
-
type:
|
|
21
|
+
type: MetricTypes.FileSize,
|
|
22
22
|
},
|
|
23
23
|
[Metric.CACHE_INVALIDATION]: {
|
|
24
24
|
label: 'Cache Invalidation',
|
|
25
25
|
description: 'The ratio between the total of the changed assets and the total file size(Bundle Size)',
|
|
26
26
|
url: 'https://relative-ci.com/documentation/metrics-and-data#assets',
|
|
27
|
-
type:
|
|
28
|
-
biggerIsBetter:
|
|
27
|
+
type: MetricTypes.Percentage,
|
|
28
|
+
biggerIsBetter: null,
|
|
29
29
|
skipDelta: true,
|
|
30
30
|
},
|
|
31
31
|
[Metric.CHUNK_COUNT]: {
|
|
32
32
|
label: 'Chunks',
|
|
33
33
|
description: 'The total number of chunks generated by the bundler',
|
|
34
34
|
url: 'https://relative-ci.com/documentation/metrics-and-data#assets',
|
|
35
|
-
type:
|
|
36
|
-
biggerIsBetter:
|
|
35
|
+
type: MetricTypes.Numeric,
|
|
36
|
+
biggerIsBetter: null,
|
|
37
37
|
},
|
|
38
38
|
[Metric.ASSET_COUNT]: {
|
|
39
39
|
label: 'Assets',
|
|
40
40
|
description: 'Total number of assets generated or produced by the bundler',
|
|
41
41
|
url: 'https://relative-ci.com/documentation/metrics-and-data#assets',
|
|
42
|
-
type:
|
|
43
|
-
biggerIsBetter:
|
|
42
|
+
type: MetricTypes.Numeric,
|
|
43
|
+
biggerIsBetter: null,
|
|
44
44
|
},
|
|
45
45
|
[Metric.MODULE_COUNT]: {
|
|
46
46
|
label: 'Modules',
|
|
47
47
|
description: 'The total number of bundled modules',
|
|
48
48
|
url: 'https://relative-ci.com/documentation/metrics-and-data#modules-1',
|
|
49
|
-
type:
|
|
50
|
-
biggerIsBetter:
|
|
49
|
+
type: MetricTypes.Numeric,
|
|
50
|
+
biggerIsBetter: null,
|
|
51
51
|
},
|
|
52
52
|
[Metric.DUPLICATE_MODULES_COUNT]: {
|
|
53
53
|
label: 'Duplicate Modules',
|
|
54
54
|
description: 'The total number of modules that belong to more than one chunk',
|
|
55
55
|
url: 'https://relative-ci.com/documentation/metrics-and-data#modules-1',
|
|
56
|
-
type:
|
|
57
|
-
biggerIsBetter:
|
|
56
|
+
type: MetricTypes.Numeric,
|
|
57
|
+
biggerIsBetter: null,
|
|
58
58
|
},
|
|
59
59
|
[Metric.DUPLICATE_CODE]: {
|
|
60
60
|
label: 'Duplicate Code',
|
|
61
61
|
description: 'The percentage of total duplicate module size from the total module size',
|
|
62
62
|
url: 'https://relative-ci.com/documentation/metrics-and-data#modules-1',
|
|
63
|
-
type:
|
|
63
|
+
type: MetricTypes.Percentage,
|
|
64
64
|
biggerIsBetter: false,
|
|
65
65
|
},
|
|
66
66
|
[Metric.PACKAGE_COUNT]: {
|
|
67
67
|
label: 'Packages',
|
|
68
68
|
description: 'The total number of bundled packages',
|
|
69
69
|
url: 'https://relative-ci.com/documentation/metrics-and-data#packages',
|
|
70
|
-
type:
|
|
70
|
+
type: MetricTypes.Numeric,
|
|
71
71
|
biggerIsBetter: false,
|
|
72
72
|
},
|
|
73
73
|
[Metric.DUPLICATE_PACKAGES_COUNT]: {
|
|
74
74
|
label: 'Duplicate Packages',
|
|
75
75
|
description: 'The total number of duplicate packages',
|
|
76
76
|
url: 'https://relative-ci.com/documentation/metrics-and-data#packages',
|
|
77
|
-
type:
|
|
77
|
+
type: MetricTypes.Numeric,
|
|
78
78
|
biggerIsBetter: false,
|
|
79
79
|
},
|
|
80
80
|
sizes: {
|
|
81
81
|
[Metric.TOTAL_SIZE_JS]: {
|
|
82
82
|
label: FILE_TYPE_LABELS.JS,
|
|
83
|
-
type:
|
|
83
|
+
type: MetricTypes.FileSize,
|
|
84
84
|
},
|
|
85
85
|
[Metric.TOTAL_SIZE_CSS]: {
|
|
86
86
|
label: FILE_TYPE_LABELS.CSS,
|
|
87
|
-
type:
|
|
87
|
+
type: MetricTypes.FileSize,
|
|
88
88
|
},
|
|
89
89
|
[Metric.TOTAL_SIZE_IMG]: {
|
|
90
90
|
label: FILE_TYPE_LABELS.IMG,
|
|
91
|
-
type:
|
|
91
|
+
type: MetricTypes.FileSize,
|
|
92
92
|
},
|
|
93
93
|
[Metric.TOTAL_SIZE_MEDIA]: {
|
|
94
94
|
label: FILE_TYPE_LABELS.MEDIA,
|
|
95
|
-
type:
|
|
95
|
+
type: MetricTypes.FileSize,
|
|
96
96
|
},
|
|
97
97
|
[Metric.TOTAL_SIZE_FONT]: {
|
|
98
98
|
label: FILE_TYPE_LABELS.FONT,
|
|
99
|
-
type:
|
|
99
|
+
type: MetricTypes.FileSize,
|
|
100
100
|
},
|
|
101
101
|
[Metric.TOTAL_SIZE_HTML]: {
|
|
102
102
|
label: FILE_TYPE_LABELS.HTML,
|
|
103
|
-
type:
|
|
103
|
+
type: MetricTypes.FileSize,
|
|
104
104
|
},
|
|
105
105
|
[Metric.TOTAL_SIZE_OTHER]: {
|
|
106
106
|
label: FILE_TYPE_LABELS.OTHER,
|
|
107
|
-
type:
|
|
107
|
+
type: MetricTypes.FileSize,
|
|
108
108
|
},
|
|
109
109
|
},
|
|
110
110
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/webpack/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../../src/webpack/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,WAAW,EAAgB,MAAM,cAAc,CAAC;AAMzD,MAAM,CAAC,MAAM,OAAO,GAAmB;IACrC,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE;QACpB,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,yEAAyE;QACtF,GAAG,EAAE,+DAA+D;QACpE,IAAI,EAAE,WAAW,CAAC,QAAQ;KAC3B;IACD,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE;QACxB,KAAK,EAAE,YAAY;QACnB,WAAW,EAAE,sDAAsD;QACnE,GAAG,EAAE,+DAA+D;QACpE,IAAI,EAAE,WAAW,CAAC,QAAQ;KAC3B;IACD,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE;QACzB,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,+CAA+C;QAC5D,GAAG,EAAE,+DAA+D;QACpE,IAAI,EAAE,WAAW,CAAC,QAAQ;KAC3B;IACD,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE;QAC3B,KAAK,EAAE,oBAAoB;QAC3B,WAAW,EACT,wFAAwF;QAC1F,GAAG,EAAE,+DAA+D;QACpE,IAAI,EAAE,WAAW,CAAC,UAAU;QAC5B,cAAc,EAAE,IAAI;QACpB,SAAS,EAAE,IAAI;KAChB;IAC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AAiE;QACtE,IAAI,EAAE,WAAW,CAAC,OAAO;QACzB,cAAc,EAAE,KAAK;KACtB;IACD,KAAK,EAAE;QACL,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE;YACtB,KAAK,EAAE,gBAAgB,CAAC,EAAE;YAC1B,IAAI,EAAE,WAAW,CAAC,QAAQ;SAC3B;QACD,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE;YACvB,KAAK,EAAE,gBAAgB,CAAC,GAAG;YAC3B,IAAI,EAAE,WAAW,CAAC,QAAQ;SAC3B;QACD,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE;YACvB,KAAK,EAAE,gBAAgB,CAAC,GAAG;YAC3B,IAAI,EAAE,WAAW,CAAC,QAAQ;SAC3B;QACD,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE;YACzB,KAAK,EAAE,gBAAgB,CAAC,KAAK;YAC7B,IAAI,EAAE,WAAW,CAAC,QAAQ;SAC3B;QACD,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE;YACxB,KAAK,EAAE,gBAAgB,CAAC,IAAI;YAC5B,IAAI,EAAE,WAAW,CAAC,QAAQ;SAC3B;QACD,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE;YACxB,KAAK,EAAE,gBAAgB,CAAC,IAAI;YAC5B,IAAI,EAAE,WAAW,CAAC,QAAQ;SAC3B;QACD,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE;YACzB,KAAK,EAAE,gBAAgB,CAAC,KAAK;YAC7B,IAAI,EAAE,WAAW,CAAC,QAAQ;SAC3B;KACF;CACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bundle-stats/utils",
|
|
3
|
-
"version": "4.7.5-beta.
|
|
3
|
+
"version": "4.7.5-beta.3",
|
|
4
4
|
"description": "BundleStats utils",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-esm/index.js",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/relative-ci/bundle-stats/blob/master/packages/utils#readme",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@bundle-stats/plugin-webpack-filter": "4.7.5-beta.
|
|
39
|
-
"@bundle-stats/plugin-webpack-validate": "4.7.5-beta.
|
|
38
|
+
"@bundle-stats/plugin-webpack-filter": "4.7.5-beta.3",
|
|
39
|
+
"@bundle-stats/plugin-webpack-validate": "4.7.5-beta.3",
|
|
40
40
|
"query-string": "7.1.3",
|
|
41
41
|
"serialize-query-params": "2.0.2"
|
|
42
42
|
},
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"core-js": "^3.0.0",
|
|
58
58
|
"lodash": "^4.0.0"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "ec48ddd0a677587035f853102296172667705ba6"
|
|
61
61
|
}
|
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MetricTypes } from '../constants';
|
|
2
2
|
|
|
3
3
|
export const metrics = {
|
|
4
4
|
firstPaint: {
|
|
5
5
|
label: 'First Paint',
|
|
6
|
-
type:
|
|
6
|
+
type: MetricTypes.Duration,
|
|
7
7
|
},
|
|
8
8
|
fullyLoaded: {
|
|
9
9
|
label: 'Fully Loaded',
|
|
10
|
-
type:
|
|
10
|
+
type: MetricTypes.Duration,
|
|
11
11
|
},
|
|
12
12
|
backEndTime: {
|
|
13
13
|
label: 'BackEnd Time',
|
|
14
|
-
type:
|
|
14
|
+
type: MetricTypes.Duration,
|
|
15
15
|
},
|
|
16
16
|
domContentLoadedTime: {
|
|
17
17
|
label: 'DOM Content Loaded Time',
|
|
18
|
-
type:
|
|
18
|
+
type: MetricTypes.Duration,
|
|
19
19
|
},
|
|
20
20
|
domInteractiveTime: {
|
|
21
21
|
label: 'DOM Interactive Time',
|
|
22
|
-
type:
|
|
22
|
+
type: MetricTypes.Duration,
|
|
23
23
|
},
|
|
24
24
|
domainLookupTime: {
|
|
25
25
|
label: 'Domain Lookup Time',
|
|
26
|
-
type:
|
|
26
|
+
type: MetricTypes.Duration,
|
|
27
27
|
},
|
|
28
28
|
frontEndTime: {
|
|
29
29
|
label: 'FrontEnd Time',
|
|
30
|
-
type:
|
|
30
|
+
type: MetricTypes.Duration,
|
|
31
31
|
},
|
|
32
32
|
pageDownloadTime: {
|
|
33
33
|
label: 'Page Download Time',
|
|
34
|
-
type:
|
|
34
|
+
type: MetricTypes.Duration,
|
|
35
35
|
},
|
|
36
36
|
pageLoadTime: {
|
|
37
37
|
label: 'Page Load Time',
|
|
38
|
-
type:
|
|
38
|
+
type: MetricTypes.Duration,
|
|
39
39
|
},
|
|
40
40
|
redirectionTime: {
|
|
41
41
|
label: 'Redirection Time',
|
|
42
|
-
type:
|
|
42
|
+
type: MetricTypes.Duration,
|
|
43
43
|
},
|
|
44
44
|
serverConnectionTime: {
|
|
45
45
|
label: 'Server Connection Time',
|
|
46
|
-
type:
|
|
46
|
+
type: MetricTypes.Duration,
|
|
47
47
|
},
|
|
48
48
|
serverResponseTime: {
|
|
49
49
|
label: 'Server Response Time',
|
|
50
|
-
type:
|
|
50
|
+
type: MetricTypes.Duration,
|
|
51
51
|
},
|
|
52
52
|
firstContentfulPaint: {
|
|
53
53
|
label: 'First Contentful Paint',
|
|
54
|
-
type:
|
|
54
|
+
type: MetricTypes.Duration,
|
|
55
55
|
},
|
|
56
56
|
rumSpeedIndex: {
|
|
57
57
|
label: 'RUM Speed Index',
|
|
58
|
-
type:
|
|
58
|
+
type: MetricTypes.Duration,
|
|
59
59
|
},
|
|
60
60
|
firstVisualChange: {
|
|
61
61
|
label: 'First Visual Change',
|
|
62
|
-
type:
|
|
62
|
+
type: MetricTypes.Duration,
|
|
63
63
|
},
|
|
64
64
|
lastVisualChange: {
|
|
65
65
|
label: 'Last Visual Change',
|
|
66
|
-
type:
|
|
66
|
+
type: MetricTypes.Duration,
|
|
67
67
|
},
|
|
68
68
|
perceptualSpeedIndex: {
|
|
69
69
|
label: 'Perceptual SpeedIndex',
|
|
70
|
-
type:
|
|
70
|
+
type: MetricTypes.Duration,
|
|
71
71
|
},
|
|
72
72
|
speedIndex: {
|
|
73
73
|
label: 'Speed Index',
|
|
74
|
-
type:
|
|
74
|
+
type: MetricTypes.Duration,
|
|
75
75
|
},
|
|
76
76
|
visualComplete85: {
|
|
77
77
|
label: 'Visual Complete 85',
|
|
78
|
-
type:
|
|
78
|
+
type: MetricTypes.Duration,
|
|
79
79
|
},
|
|
80
80
|
visualComplete95: {
|
|
81
81
|
label: 'Visual Complete 95',
|
|
82
|
-
type:
|
|
82
|
+
type: MetricTypes.Duration,
|
|
83
83
|
},
|
|
84
84
|
visualComplete99: {
|
|
85
85
|
label: 'Visual Complete 99',
|
|
86
|
-
type:
|
|
86
|
+
type: MetricTypes.Duration,
|
|
87
87
|
},
|
|
88
88
|
};
|
package/src/config/index.js
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { formatNumber, formatDuration, formatFileSize, formatPercentage } from '../utils/format';
|
|
2
|
+
import { MetricTypes, MetricTypeConfig } from '../constants';
|
|
3
|
+
|
|
4
|
+
export const METRIC_TYPE_CONFIGS: Record<MetricTypes, MetricTypeConfig> = {
|
|
5
|
+
[MetricTypes.Numeric]: {
|
|
6
|
+
biggerIsBetter: false,
|
|
7
|
+
formatter: formatNumber,
|
|
8
|
+
},
|
|
9
|
+
[MetricTypes.Score]: {
|
|
10
|
+
biggerIsBetter: true,
|
|
11
|
+
formatter: formatNumber,
|
|
12
|
+
},
|
|
13
|
+
[MetricTypes.Duration]: {
|
|
14
|
+
biggerIsBetter: false,
|
|
15
|
+
formatter: formatDuration,
|
|
16
|
+
},
|
|
17
|
+
[MetricTypes.FileSize]: {
|
|
18
|
+
biggerIsBetter: false,
|
|
19
|
+
formatter: formatFileSize,
|
|
20
|
+
},
|
|
21
|
+
[MetricTypes.Percentage]: {
|
|
22
|
+
biggerIsBetter: true,
|
|
23
|
+
formatter: formatPercentage,
|
|
24
|
+
},
|
|
25
|
+
};
|
package/src/constants.ts
CHANGED
|
@@ -12,39 +12,73 @@ export enum InsightType {
|
|
|
12
12
|
WARNING = 'warning',
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Generic metric type names
|
|
17
|
+
*/
|
|
18
|
+
export enum MetricTypes {
|
|
19
|
+
Numeric = 'METRIC_TYPE_NUMERIC',
|
|
20
|
+
Score = 'METRIC_TYPE_SCORE',
|
|
21
|
+
FileSize = 'METRIC_TYPE_FILE_SIZE',
|
|
22
|
+
Duration = 'METRIC_TYPE_DURATION',
|
|
23
|
+
Percentage = 'METRIC_TYPE_PERCENTAGE',
|
|
21
24
|
}
|
|
22
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Metric type base configuration
|
|
28
|
+
*/
|
|
23
29
|
export interface MetricTypeConfig {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Increased values are regressions, decreased values are improvements
|
|
32
|
+
*/
|
|
33
|
+
biggerIsBetter?: boolean | null;
|
|
34
|
+
/**
|
|
35
|
+
* Value formatter
|
|
36
|
+
*/
|
|
37
|
+
formatter: (value: number | null) => string;
|
|
27
38
|
}
|
|
28
39
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Source metric configuration
|
|
42
|
+
*/
|
|
43
|
+
export interface MetricConfig {
|
|
44
|
+
label: string;
|
|
45
|
+
type: MetricTypes;
|
|
46
|
+
description?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Documentation URL
|
|
49
|
+
*/
|
|
50
|
+
url?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Positive delta values are regressions and negative delta values are improvements
|
|
53
|
+
* overrides MetricTypeConfig['biggerIsBetter']
|
|
54
|
+
*/
|
|
55
|
+
biggerIsBetter?: MetricTypeConfig['biggerIsBetter'];
|
|
56
|
+
/**
|
|
57
|
+
* Do not show the delta
|
|
58
|
+
*/
|
|
59
|
+
skipDelta?: boolean;
|
|
32
60
|
}
|
|
33
61
|
|
|
34
|
-
export
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
62
|
+
export type Metric = MetricTypeConfig & MetricConfig;
|
|
63
|
+
|
|
64
|
+
export type MetricRunInfoDeltaType =
|
|
65
|
+
| 'HIGH_NEGATIVE'
|
|
66
|
+
| 'NEGATIVE'
|
|
67
|
+
| 'LOW_NEGATIVE'
|
|
68
|
+
| 'NO_CHANGE'
|
|
69
|
+
| 'LOW_POSITIVE'
|
|
70
|
+
| 'POSITIVE'
|
|
71
|
+
| 'HIGH_POSITIVE';
|
|
43
72
|
|
|
44
73
|
export interface MetricRun {
|
|
45
74
|
value: number;
|
|
46
75
|
}
|
|
47
76
|
|
|
77
|
+
export interface MetricRunDelta {
|
|
78
|
+
delta: number;
|
|
79
|
+
deltaPercentage: number;
|
|
80
|
+
}
|
|
81
|
+
|
|
48
82
|
export interface MetricRunInfo {
|
|
49
83
|
value: number;
|
|
50
84
|
displayValue: string;
|
|
@@ -53,6 +87,7 @@ export interface MetricRunInfo {
|
|
|
53
87
|
deltaType?: MetricRunInfoDeltaType;
|
|
54
88
|
displayDelta?: string;
|
|
55
89
|
displayDeltaPercentage?: string;
|
|
90
|
+
regression?: boolean | null;
|
|
56
91
|
}
|
|
57
92
|
|
|
58
93
|
export type JobSection<T = object> = Record<Source, T>;
|
|
@@ -77,6 +112,7 @@ export interface JobInsight<T = object> {
|
|
|
77
112
|
|
|
78
113
|
export interface JobInsightAssetsSizeTotalData {
|
|
79
114
|
md: string;
|
|
115
|
+
text: string;
|
|
80
116
|
info: MetricRunInfo;
|
|
81
117
|
}
|
|
82
118
|
export type JobInsightDuplicatePackagesData = Record<string, Array<string>>;
|
|
@@ -160,10 +196,10 @@ export interface BrowsertimeSource {
|
|
|
160
196
|
info?: {
|
|
161
197
|
browsertime: {
|
|
162
198
|
version: string;
|
|
163
|
-
}
|
|
199
|
+
};
|
|
164
200
|
timestamp: string;
|
|
165
201
|
url: string;
|
|
166
|
-
}
|
|
202
|
+
};
|
|
167
203
|
statistics?: {
|
|
168
204
|
timings: {
|
|
169
205
|
firstPaint: BrowsertimeSourceMetric;
|
|
@@ -179,12 +215,12 @@ export interface BrowsertimeSource {
|
|
|
179
215
|
redirectionTime: BrowsertimeSourceMetric;
|
|
180
216
|
serverConnectionTime: BrowsertimeSourceMetric;
|
|
181
217
|
serverResponseTime: BrowsertimeSourceMetric;
|
|
182
|
-
}
|
|
218
|
+
};
|
|
183
219
|
paintTiming: {
|
|
184
220
|
'first-contentful-paint': BrowsertimeSourceMetric;
|
|
185
|
-
}
|
|
221
|
+
};
|
|
186
222
|
rumSpeedIndex: BrowsertimeSourceMetric;
|
|
187
|
-
}
|
|
223
|
+
};
|
|
188
224
|
visualmetrics: {
|
|
189
225
|
FirstVisualChange: BrowsertimeSourceMetric;
|
|
190
226
|
LastVisualChange: BrowsertimeSourceMetric;
|
|
@@ -193,8 +229,8 @@ export interface BrowsertimeSource {
|
|
|
193
229
|
VisualComplete85: BrowsertimeSourceMetric;
|
|
194
230
|
VisualComplete95: BrowsertimeSourceMetric;
|
|
195
231
|
VisualComplete99: BrowsertimeSourceMetric;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
232
|
+
};
|
|
233
|
+
};
|
|
198
234
|
}
|
|
199
235
|
|
|
200
236
|
export interface BrowsertimeMetrics {
|