Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kbn/optimizer] ignore compressed files when reporting stats #71940

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions packages/kbn-optimizer/src/report_optimizer_stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ interface Entry {
stats: Fs.Stats;
}

const IGNORED_EXTNAME = ['.map', '.br', '.gz'];

const getFiles = (dir: string, parent?: string) =>
flatten(
Fs.readdirSync(dir).map((name): Entry | Entry[] => {
Expand All @@ -51,7 +53,19 @@ const getFiles = (dir: string, parent?: string) =>
stats,
};
})
);
).filter((file) => {
const filename = Path.basename(file.relPath);
if (filename.startsWith('.')) {
return false;
}

const ext = Path.extname(filename);
if (IGNORED_EXTNAME.includes(ext)) {
return false;
}

return true;
});

export function reportOptimizerStats(reporter: CiStatsReporter, config: OptimizerConfig) {
return pipeClosure((update$: OptimizerUpdate$) => {
Expand All @@ -70,10 +84,7 @@ export function reportOptimizerStats(reporter: CiStatsReporter, config: Optimize
// make the cache read from the cache file since it was likely updated by the worker
bundle.cache.refresh();

const outputFiles = getFiles(bundle.outputDir).filter(
(file) => !(file.relPath.startsWith('.') || file.relPath.endsWith('.map'))
);

const outputFiles = getFiles(bundle.outputDir);
const entryName = `${bundle.id}.${bundle.type}.js`;
const entry = outputFiles.find((f) => f.relPath === entryName);
if (!entry) {
Expand Down