Skip to content

Commit 383b305

Browse files
committed
test: builder++
1 parent c009534 commit 383b305

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+6592
-380
lines changed

packages/plugin-bundle-stats/CONTRIBUTING.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,32 @@
22

33
## Development
44

5-
### Running the plugin
5+
### Generate Build Artifacts
6+
7+
Before running the plugin, you need to generate the bundle stats files from the test fixtures. Each bundler produces different output formats:
68

79
```bash
8-
nx code-pushup plugin-bundle-stats
10+
# Navigate to the test fixture
11+
cd packages/plugin-bundle-stats/mocks/fixtures/node-minimal
12+
13+
# Generate artifacts for all bundlers
14+
npm run build
15+
16+
# Or generate artifacts for specific bundlers
17+
npm run build:esbuild # → dist/esbuild/stats.json
18+
npm run build:webpack # → dist/webpack/stats.json
19+
npm run build:rsbuild # → dist/rsbuild/stats.json
20+
npm run build:vite # → dist/vite/stats.json
921
```
1022

23+
### Running the Plugin
24+
25+
Once the artifacts are generated, you can run the Code PushUp plugin to analyze them:
26+
1127
```bash
12-
npx @code-pushup/cli collect --config packages/plugin-bundle-stats/code-pushup.config.ts
28+
# Run plugin analysis for each bundler
29+
nx run plugin-bundle-stats:code-pushup-minimal-esbuild
30+
nx run plugin-bundle-stats:code-pushup-minimal-webpack
31+
nx run plugin-bundle-stats:code-pushup-minimal-rsbuild
32+
nx run plugin-bundle-stats:code-pushup-minimal-vite
1333
```

packages/plugin-bundle-stats/code-pushup.large-angular.config.ts

Lines changed: 101 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -24,80 +24,119 @@ import bundleStatsPlugin, { DEFAULT_GROUPING } from './src';
2424
* nx code-pushup:minimal-angular plugin-bundle-stats
2525
*/
2626

27+
const GROUPING_PACKAGES = [
28+
{
29+
title: 'Payment',
30+
patterns: ['**/payments/**/*'],
31+
icon: '🚀',
32+
},
33+
{
34+
title: 'Loaders Library',
35+
patterns: ['**/loaders-lib/**/*'],
36+
icon: '🔄',
37+
},
38+
{
39+
title: 'Sports Platform',
40+
patterns: ['**/sports/**/*'],
41+
icon: '⚽',
42+
},
43+
{
44+
title: 'Host App',
45+
patterns: ['**/host-app/**/*'],
46+
icon: '🏠',
47+
},
48+
{
49+
title: 'Casino',
50+
patterns: ['**/casino/**/*'],
51+
icon: '🎰',
52+
},
53+
{
54+
title: 'Oxygen Framework',
55+
patterns: ['**/oxygen/**/*'],
56+
icon: '🔧',
57+
},
58+
];
59+
60+
const GROUPING_ANGULAR_BLOCKS = [
61+
{
62+
title: 'Components',
63+
patterns: ['**/*.component.ts'],
64+
icon: '🅰️',
65+
},
66+
{
67+
title: 'Directives',
68+
patterns: ['**/*.directive.ts'],
69+
icon: '🅰️',
70+
},
71+
{
72+
title: 'Pipes',
73+
patterns: ['**/*.pipe.ts'],
74+
icon: '🅰️',
75+
},
76+
{
77+
title: 'Modules',
78+
patterns: ['**/*.module.ts'],
79+
icon: '🅰️',
80+
},
81+
{
82+
title: 'Guards',
83+
patterns: ['**/*.guard.ts'],
84+
icon: '🅰️',
85+
},
86+
{
87+
title: 'Resolvers',
88+
patterns: ['**/*.resolver.ts'],
89+
icon: '🅰️',
90+
},
91+
{
92+
title: 'Interceptors',
93+
patterns: ['**/*.interceptor.ts'],
94+
icon: '🅰️',
95+
},
96+
{
97+
title: 'Providers',
98+
patterns: ['**/*.provider.ts'],
99+
icon: '🅰️',
100+
},
101+
{
102+
title: 'Services',
103+
patterns: ['**/*.service.ts'],
104+
icon: '🅰️',
105+
},
106+
];
107+
27108
const config = {
28109
plugins: [
29110
await bundleStatsPlugin({
30111
artefactsPath:
31112
'./packages/plugin-bundle-stats/mocks/fixtures/stats/angular-large.stats.json',
32-
bundler: 'esbuild',
33-
grouping: [...DEFAULT_GROUPING],
34-
configs: [
35-
{
36-
title: 'Entry Bundle',
37-
selection: {
38-
includeEntryPoints: ['**/payments.routes.ts'],
39-
},
40-
thresholds: {
41-
totalSize: [300 * 1024, 1 * 1024 * 1024],
42-
artefactSize: [100 * 1024, 500 * 1024],
43-
},
44-
},
45-
{
46-
title: 'All Chunks',
47-
selection: {
48-
includeOutputs: ['chunk-*.js'],
49-
},
50-
thresholds: {
51-
totalSize: [300 * 1024, 1 * 1024 * 1024],
52-
artefactSize: [100 * 1024, 500 * 1024],
53-
},
54-
},
55-
{
56-
title: 'Main Components',
57-
selection: {
58-
includeInputs: ['**/main/**', '**/main.*'],
59-
},
60-
thresholds: {
61-
totalSize: [300 * 1024, 1 * 1024 * 1024],
62-
artefactSize: [100 * 1024, 500 * 1024],
63-
},
64-
},
65-
/* keep commented out
113+
audits: [
66114
{
67115
title: 'Initial Bundles',
68-
include: ['main-*.js', 'polyfills-*.js'],
69-
thresholds: {
70-
totalSize: [300 * 1024, 1 * 1024 * 1024],
71-
artefactSize: [100 * 1024, 500 * 1024],
116+
selection: {
117+
includeOutputs: [
118+
'**/main*.js',
119+
'**/polyfills*.js',
120+
'**/runtime*.js',
121+
],
72122
},
73-
},
74-
{
75-
title: 'Shared Chunks',
76-
include: ['**\/chunk-*.js'],
77-
thresholds: {
78-
totalSize: [10, 100 * 1024],
123+
scoring: {
124+
totalSize: 100_000,
79125
},
80-
pruning: {
81-
maxChildren: 10,
82-
maxDepth: 3,
126+
artefactTree: {
127+
groups: GROUPING_PACKAGES,
83128
},
129+
insights: [
130+
...GROUPING_PACKAGES,
131+
...GROUPING_ANGULAR_BLOCKS,
132+
{
133+
title: 'Node Modules',
134+
patterns: ['**/node_modules/**/*'],
135+
icon: '📚',
136+
},
137+
],
84138
},
85-
{
86-
title: 'CSS Assets',
87-
include: ['**\/*.css'],
88-
thresholds: {
89-
totalSize: [1 * 1024, 50 * 1024],
90-
},
91-
},*/
92139
],
93-
penalty: {
94-
errorWeight: 1,
95-
warningWeight: 0.5,
96-
},
97-
pruning: {
98-
maxChildren: 30,
99-
maxDepth: 4,
100-
},
101140
}),
102141
],
103142
};

0 commit comments

Comments
 (0)