Skip to content

Commit 60afd22

Browse files
committed
fix: fix merge plugin and audit config
1 parent 581911f commit 60afd22

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export function getUnifyFunction(
132132
* @param optionsTree - Global plugin tree configuration
133133
* @returns Merged configuration or false/undefined for disabled states
134134
*/
135-
export function mergeArtefactTreeConfig(
135+
export function mergeDependencyTreeConfig(
136136
configTree: AuditTreeOptions | undefined,
137137
optionsTree: DependencyTreeOptions | false | undefined,
138138
): DependencyTreeOptions | undefined {
@@ -242,7 +242,7 @@ export function mergeScoringConfig(
242242
export function mergeInsightsConfig(
243243
configInsights: InsightsConfig | false | undefined,
244244
optionsInsights: InsightsConfig | undefined,
245-
): InsightsConfig | undefined {
245+
): InsightsConfig | false | undefined {
246246
if (configInsights === false) {
247247
return undefined;
248248
}
@@ -262,10 +262,10 @@ export async function bundleStatsRunner(
262262
artefactsPath,
263263
generateArtefacts,
264264
audits,
265-
dependencyTree: artefactTree,
265+
dependencyTree,
266266
scoring,
267267
bundler,
268-
insightsTable: insights,
268+
insightsTable,
269269
selection,
270270
} = opts;
271271

@@ -292,10 +292,10 @@ export async function bundleStatsRunner(
292292
const unifiedBundleStats = unifyBundlerStats(stats);
293293

294294
const mergedAuditConfigs = mergeAuditConfigs(audits, {
295-
insightsTable: insights,
295+
insightsTable,
296296
selection,
297297
scoring,
298-
dependencyTree: artefactTree,
298+
dependencyTree,
299299
});
300300

301301
const bundleStatsTree = unifiedBundleStats;
@@ -315,7 +315,7 @@ export function mergeAuditConfigs(
315315

316316
return {
317317
...configWithoutInsights,
318-
artefactTree: mergeArtefactTreeConfig(
318+
dependencyTree: mergeDependencyTreeConfig(
319319
config.dependencyTree,
320320
options.dependencyTree,
321321
),

packages/plugin-bundle-stats/src/lib/runner/bundle-stats-runner.unit.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import type { GlobalSelectionOptions } from '../types.js';
33
import type { PenaltyConfig } from './audits/details/issues.js';
44
import type { SelectionConfig } from './audits/selection.js';
55
import {
6-
mergeArtefactTreeConfig,
76
mergeAuditConfigs,
7+
mergeDependencyTreeConfig,
88
mergeInsightsConfig,
99
mergeScoringConfig,
1010
mergeSelectionConfig,
@@ -255,14 +255,14 @@ describe('mergeAuditConfigs', () => {
255255

256256
describe('mergeArtefactTreeConfig', () => {
257257
it('should return undefined when both global and config are undefined', () => {
258-
expect(mergeArtefactTreeConfig(undefined, undefined)).toBeUndefined();
258+
expect(mergeDependencyTreeConfig(undefined, undefined)).toBeUndefined();
259259
});
260260

261261
it('should use config when global is undefined', () => {
262262
const config = {
263263
groups: [{ patterns: ['**/*.ts'], title: 'TypeScript' } as GroupingRule],
264264
};
265-
const result = mergeArtefactTreeConfig(config, undefined);
265+
const result = mergeDependencyTreeConfig(config, undefined);
266266

267267
expect(result?.groups).toHaveLength(1);
268268
expect(result?.groups?.[0]).toMatchObject({ patterns: ['**/*.ts'] });
@@ -274,14 +274,14 @@ describe('mergeArtefactTreeConfig', () => {
274274
groups: [{ patterns: ['**/*.js'], title: 'JavaScript' } as GroupingRule],
275275
};
276276

277-
expect(mergeArtefactTreeConfig(config, global)).toBeUndefined();
277+
expect(mergeDependencyTreeConfig(config, global)).toBeUndefined();
278278
});
279279

280280
it('should merge when global options provided and config undefined', () => {
281281
const global = {
282282
groups: [{ patterns: ['**/*.js'], title: 'JavaScript' } as GroupingRule],
283283
};
284-
const result = mergeArtefactTreeConfig(undefined, global);
284+
const result = mergeDependencyTreeConfig(undefined, global);
285285

286286
expect(result?.groups).toHaveLength(1);
287287
expect(result?.groups?.[0]).toMatchObject({ patterns: ['**/*.js'] });
@@ -294,7 +294,7 @@ describe('mergeArtefactTreeConfig', () => {
294294
const global = {
295295
groups: [{ patterns: ['**/*.js'], title: 'JavaScript' } as GroupingRule],
296296
};
297-
const result = mergeArtefactTreeConfig(config, global);
297+
const result = mergeDependencyTreeConfig(config, global);
298298

299299
expect(result?.groups).toHaveLength(2);
300300
expect(result?.groups?.[0]).toMatchObject({ patterns: ['**/*.js'] });
@@ -304,14 +304,14 @@ describe('mergeArtefactTreeConfig', () => {
304304
it('should overwrite pruning options (config takes precedence)', () => {
305305
const config = { pruning: { maxDepth: 5 } };
306306
const global = { pruning: { maxDepth: 3 } };
307-
const result = mergeArtefactTreeConfig(config, global);
307+
const result = mergeDependencyTreeConfig(config, global);
308308

309309
expect(result?.pruning?.maxDepth).toBe(5);
310310
});
311311

312312
it('should provide DEFAULT pruning options when no options provided', () => {
313313
const config = { groups: [] };
314-
const result = mergeArtefactTreeConfig(config, undefined);
314+
const result = mergeDependencyTreeConfig(config, undefined);
315315

316316
expect(result?.pruning).toBeDefined();
317317
});

0 commit comments

Comments
 (0)