Skip to content

Commit d6ee241

Browse files
committed
docs: add examples
1 parent afa8088 commit d6ee241

4 files changed

Lines changed: 26 additions & 31 deletions

File tree

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const config = {
2828
plugins: [
2929
await bundleStatsPlugin({
3030
artefactsPath:
31-
'./packages/plugin-bundle-stats/mocks/fixtures/stats/entain-bundle-stats.json',
31+
'./packages/plugin-bundle-stats/mocks/fixtures/stats/entain-host-app-main-bundle-stats.json',
3232
bundler: 'esbuild',
3333
grouping: [...DEFAULT_GROUPING],
3434
configs: [
@@ -40,22 +40,24 @@ const config = {
4040
artefactSize: [100 * 1024, 500 * 1024],
4141
},
4242
},
43-
// commented out for later
44-
/*
4543
{
4644
title: 'Shared Chunks',
4745
include: ['**\/chunk-*.js'],
4846
thresholds: {
4947
totalSize: [10, 100 * 1024],
5048
},
49+
pruning: {
50+
maxChildren: 10,
51+
maxDepth: 3,
52+
},
5153
},
5254
{
5355
title: 'CSS Assets',
5456
include: ['**\/*.css'],
5557
thresholds: {
5658
totalSize: [1 * 1024, 50 * 1024],
5759
},
58-
},*/
60+
},
5961
],
6062
penalty: {
6163
errorWeight: 1,

packages/plugin-bundle-stats/mocks/fixtures/stats/entain-bundle-stats.json renamed to packages/plugin-bundle-stats/mocks/fixtures/stats/entain-host-app-main-bundle-stats.json

File renamed without changes.

packages/plugin-bundle-stats/src/lib/constants.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ export const DEFAULT_GROUPING: GroupingRule[] = [
2121
},
2222
{
2323
title: 'preact',
24-
patterns: [
25-
'**/node_modules/preact/**',
26-
'**/node_modules/preact-render-to-string/**',
27-
],
24+
patterns: ['**/node_modules/preact/**', '**/node_modules/preact-*/**'],
2825
icon: '🪐',
2926
},
3027
{
@@ -34,10 +31,7 @@ export const DEFAULT_GROUPING: GroupingRule[] = [
3431
},
3532
{
3633
title: 'solid',
37-
patterns: [
38-
'**/node_modules/solid-js/**',
39-
'**/node_modules/solid-app-router/**',
40-
],
34+
patterns: ['**/node_modules/solid-js/**', '**/node_modules/solid-*/**'],
4135
icon: '🟢',
4236
},
4337
{

packages/plugin-bundle-stats/src/lib/runner/utils/formatting.ts

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,6 @@ export function formatNodeLabel(node: BundleStatsNode): string {
122122
return `${icon} ${displayName}${sizeInfo}`;
123123
}
124124

125-
/**
126-
* Enhanced tree connector that uses appropriate icons
127-
*/
128-
export function formatTreeConnector(
129-
node: BundleStatsNode,
130-
isLast: boolean,
131-
): string {
132-
const baseConnector = isLast ? '└─ ' : '├─ ';
133-
134-
if (node.values.type === 'import') {
135-
const arrow = node.values.importKind === 'dynamic' ? '▷' : '▶';
136-
return `${baseConnector}${arrow} `;
137-
}
138-
139-
return baseConnector;
140-
}
141-
142125
export const short = (p: string): string =>
143126
truncateText((p || '').replace(process.cwd(), '⟨CWD⟩'), { maxChars: 80 });
144127

@@ -214,18 +197,34 @@ export function getNodeIconAndPrefix(
214197

215198
switch (node.values.type) {
216199
case 'chunk':
200+
if (node.values.path?.endsWith('.css') || node.name.endsWith('.css')) {
201+
return { icon: '🎨', prefix: '' };
202+
}
217203
return { icon: '📄', prefix: '' };
218204
case 'import':
219-
const arrow = node.values.importKind === 'dynamic' ? '▷' : '▶';
220-
return { icon: arrow, prefix: 'imported from ' };
205+
if (node.values.path?.endsWith('.css') || node.name.endsWith('.css')) {
206+
return { icon: '🎨', prefix: '' };
207+
}
208+
return { icon: '📄', prefix: '' };
221209
case 'input':
222210
if (node.values.path?.endsWith('.css') || node.name.endsWith('.css')) {
223211
return { icon: '🎨', prefix: '' };
224212
}
225213
return { icon: '📄', prefix: '' };
226214
case 'asset':
215+
if (node.values.path?.endsWith('.css') || node.name.endsWith('.css')) {
216+
return { icon: '🎨', prefix: '' };
217+
}
227218
return { icon: '📄', prefix: '' };
228219
case 'group':
220+
// Check for CSS-related group names first
221+
if (
222+
node.name.includes('css-assets') ||
223+
node.name.includes('css') ||
224+
node.name.includes('styles')
225+
) {
226+
return { icon: '🎨', prefix: '' };
227+
}
229228
// Group nodes use custom icons from grouping rules
230229
return { icon: (node.values as any).icon || '📦', prefix: '' };
231230
default:

0 commit comments

Comments
 (0)