@atlaspack/reporter-bundle-stats 2.14.5-canary.138 → 2.14.5-canary.139
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.
@@ -0,0 +1,23 @@
|
|
1
|
+
import type { PackagedBundle, PluginOptions } from '@atlaspack/types';
|
2
|
+
import { Reporter } from '@atlaspack/plugin';
|
3
|
+
export type AssetStat = {
|
4
|
+
size: number;
|
5
|
+
name: string;
|
6
|
+
bundles: Array<string>;
|
7
|
+
};
|
8
|
+
export type BundleStat = {
|
9
|
+
size: number;
|
10
|
+
id: string;
|
11
|
+
assets: Array<string>;
|
12
|
+
};
|
13
|
+
export type BundleStats = {
|
14
|
+
bundles: {
|
15
|
+
[key: string]: BundleStat;
|
16
|
+
};
|
17
|
+
assets: {
|
18
|
+
[key: string]: AssetStat;
|
19
|
+
};
|
20
|
+
};
|
21
|
+
declare const _default: Reporter;
|
22
|
+
export default _default;
|
23
|
+
export declare function getBundleStats(bundles: Array<PackagedBundle>, options: PluginOptions): BundleStats;
|
package/package.json
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@atlaspack/reporter-bundle-stats",
|
3
|
-
"version": "2.14.5-canary.
|
3
|
+
"version": "2.14.5-canary.139+d2fd84977",
|
4
4
|
"publishConfig": {
|
5
5
|
"access": "public"
|
6
6
|
},
|
7
|
-
"main": "lib/BundleStatsReporter.js",
|
8
|
-
"source": "src/BundleStatsReporter.
|
7
|
+
"main": "./lib/BundleStatsReporter.js",
|
8
|
+
"source": "./src/BundleStatsReporter.ts",
|
9
|
+
"types": "./lib/BundleStatsReporter.d.ts",
|
9
10
|
"bin": {
|
10
11
|
"atlaspack-bundle-stats": "bin.js"
|
11
12
|
},
|
@@ -13,13 +14,16 @@
|
|
13
14
|
"node": ">= 16.0.0"
|
14
15
|
},
|
15
16
|
"dependencies": {
|
16
|
-
"@atlaspack/core": "2.16.2-canary.
|
17
|
-
"@atlaspack/plugin": "2.14.5-canary.
|
18
|
-
"@atlaspack/utils": "2.14.5-canary.
|
17
|
+
"@atlaspack/core": "2.16.2-canary.139+d2fd84977",
|
18
|
+
"@atlaspack/plugin": "2.14.5-canary.139+d2fd84977",
|
19
|
+
"@atlaspack/utils": "2.14.5-canary.139+d2fd84977"
|
19
20
|
},
|
20
21
|
"devDependencies": {
|
21
|
-
"@atlaspack/types": "2.14.5-canary.
|
22
|
+
"@atlaspack/types": "2.14.5-canary.139+d2fd84977"
|
22
23
|
},
|
23
24
|
"type": "commonjs",
|
24
|
-
"
|
25
|
-
|
25
|
+
"scripts": {
|
26
|
+
"check-ts": "tsc --emitDeclarationOnly --rootDir src"
|
27
|
+
},
|
28
|
+
"gitHead": "d2fd849770fe6305e9c694bd97b1bd905abd9d94"
|
29
|
+
}
|
@@ -1,5 +1,3 @@
|
|
1
|
-
// @flow strict-local
|
2
|
-
|
3
1
|
import type {PackagedBundle, PluginOptions} from '@atlaspack/types';
|
4
2
|
|
5
3
|
import {Reporter} from '@atlaspack/plugin';
|
@@ -8,24 +6,28 @@ import {DefaultMap} from '@atlaspack/utils';
|
|
8
6
|
import assert from 'assert';
|
9
7
|
import path from 'path';
|
10
8
|
|
11
|
-
export type AssetStat = {
|
12
|
-
size: number
|
13
|
-
name: string
|
14
|
-
bundles: Array<string
|
15
|
-
|
16
|
-
|
17
|
-
export type BundleStat = {
|
18
|
-
size: number
|
19
|
-
id: string
|
20
|
-
assets: Array<string
|
21
|
-
|
22
|
-
|
23
|
-
export type BundleStats = {
|
24
|
-
bundles: {
|
25
|
-
|
26
|
-
|
9
|
+
export type AssetStat = {
|
10
|
+
size: number;
|
11
|
+
name: string;
|
12
|
+
bundles: Array<string>;
|
13
|
+
};
|
14
|
+
|
15
|
+
export type BundleStat = {
|
16
|
+
size: number;
|
17
|
+
id: string;
|
18
|
+
assets: Array<string>;
|
19
|
+
};
|
20
|
+
|
21
|
+
export type BundleStats = {
|
22
|
+
bundles: {
|
23
|
+
[key: string]: BundleStat;
|
24
|
+
};
|
25
|
+
assets: {
|
26
|
+
[key: string]: AssetStat;
|
27
|
+
};
|
28
|
+
};
|
27
29
|
|
28
|
-
export default
|
30
|
+
export default new Reporter({
|
29
31
|
async report({event, options}) {
|
30
32
|
if (event.type !== 'buildSuccess') {
|
31
33
|
return;
|
@@ -33,7 +35,7 @@ export default (new Reporter({
|
|
33
35
|
|
34
36
|
let bundlesByTarget: DefaultMap<
|
35
37
|
string /* target name */,
|
36
|
-
Array<PackagedBundle
|
38
|
+
Array<PackagedBundle>
|
37
39
|
> = new DefaultMap(() => []);
|
38
40
|
for (let bundle of event.bundleGraph.getBundles()) {
|
39
41
|
bundlesByTarget.get(bundle.target.name).push(bundle);
|
@@ -43,7 +45,7 @@ export default (new Reporter({
|
|
43
45
|
await options.outputFS.mkdirp(reportsDir);
|
44
46
|
|
45
47
|
await Promise.all(
|
46
|
-
[...bundlesByTarget.entries()].map(([targetName, bundles]) =>
|
48
|
+
[...bundlesByTarget.entries()].map(([targetName, bundles]: [any, any]) =>
|
47
49
|
options.outputFS.writeFile(
|
48
50
|
path.join(reportsDir, `${targetName}-stats.json`),
|
49
51
|
JSON.stringify(getBundleStats(bundles, options), null, 2),
|
@@ -51,7 +53,7 @@ export default (new Reporter({
|
|
51
53
|
),
|
52
54
|
);
|
53
55
|
},
|
54
|
-
})
|
56
|
+
}) as Reporter;
|
55
57
|
|
56
58
|
export function getBundleStats(
|
57
59
|
bundles: Array<PackagedBundle>,
|
@@ -72,7 +74,7 @@ export function getBundleStats(
|
|
72
74
|
continue;
|
73
75
|
}
|
74
76
|
|
75
|
-
let assets = [];
|
77
|
+
let assets: Array<string> = [];
|
76
78
|
bundle.traverseAssets(({id, filePath, stats: {size}}) => {
|
77
79
|
assets.push(id);
|
78
80
|
let assetName = path.relative(options.projectRoot, filePath);
|
package/tsconfig.json
ADDED