Skip to content

Commit

Permalink
fix: Exclude analysis files from the build summary (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
aklinker1 authored Feb 6, 2024
1 parent 22f82a6 commit bba8cda
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/core/builders/vite/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export async function createViteBuilder(
wxtPlugins.defineImportMeta(),
);
if (wxtConfig.analysis.enabled) {
config.plugins.push(wxtPlugins.bundleAnalysis());
config.plugins.push(wxtPlugins.bundleAnalysis(wxtConfig));
}

return config;
Expand Down
9 changes: 6 additions & 3 deletions src/core/builders/vite/plugins/bundleAnalysis.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import type * as vite from 'vite';
import { visualizer } from 'rollup-plugin-visualizer';
import { ResolvedConfig } from '~/types';
import path from 'node:path';

let increment = 0;

export function bundleAnalysis(): vite.Plugin {
export function bundleAnalysis(
config: Omit<ResolvedConfig, 'builder'>,
): vite.Plugin {
return visualizer({
emitFile: true,
template: 'raw-data',
filename: `stats-${increment++}.json`,
filename: path.resolve(config.outDir, `stats-${increment++}.json`),
}) as vite.Plugin;
}
1 change: 1 addition & 0 deletions src/core/utils/building/build-entrypoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export async function buildEntrypoints(
try {
steps.push(await wxt.config.builder.build(group));
} catch (err) {
wxt.logger.error(err);
throw Error(`Failed to build ${groupNames.join(', ')}`, { cause: err });
}
}
Expand Down
1 change: 1 addition & 0 deletions src/core/utils/building/internal-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ async function combineAnalysisStats(): Promise<void> {
[...absolutePaths, '--template', wxt.config.analysis.template],
{ cwd: wxt.config.root, stdio: 'inherit' },
);
await Promise.all(absolutePaths.map((statsFile) => fs.remove(statsFile)));
}

function printValidationResults({
Expand Down

0 comments on commit bba8cda

Please sign in to comment.