Skip to content

Commit

Permalink
Merge branch 'master' into feature/rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
ratchapol-an authored Feb 19, 2025
2 parents 74cdfc5 + 1743e9a commit 1199c61
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion packages/common/src/lib/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const getEndpointFromType = (type: string) => {
return {
webpack: process.env.WEBPACK_ENDPOINT || 'http://compilation-metrics/webpack',
vite: process.env.VITE_ENDPOINT || 'http://compilation-metrics/vite',
vitehmr: process.env.VITE_ENDPOINT || 'http://compilation-metrics/vite',
rsbuild: process.env.WEBPACK_ENDPOINT || 'http://compilation-metrics/webpack',
}[type];
};
Expand Down Expand Up @@ -102,5 +103,7 @@ export const sendBuildData = async (
return;
}

console.log(`Your build stats has successfully been sent.`);
console.log(
`Your build stats has successfully been sent to ${endpoint} for ${buildStats.type}.`,
);
};
2 changes: 1 addition & 1 deletion packages/common/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export interface ViteBundleStats {
}

export interface ViteBuildData extends CommonMetadata {
type: 'vite';
type: 'vite' | 'vitehmr';
viteVersion: string | null;
bundleStats?: ViteBundleStats;
file: string | null;
Expand Down
6 changes: 3 additions & 3 deletions packages/vite-plugin/src/lib/vite-build-stats-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function viteBuildStatsPlugin(

const metricsData: ViteBuildData = {
...getCommonMetadata(totalTime, customIdentifier),
type: 'vite',
type: 'vitehmr',
viteVersion: rollupVersion ?? null,
bundleStats: {
bootstrapChunkSizeBytes: undefined,
Expand All @@ -111,7 +111,7 @@ export function viteBuildStatsPlugin(
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ success: true }));
} else {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.writeHead(404, { 'Content-Type': 'application/json' });
res.end(
JSON.stringify({
success: false,
Expand All @@ -123,7 +123,7 @@ export function viteBuildStatsPlugin(
}
} catch (err) {
console.error('[vite-timing] Error processing timing data:', err);
res.writeHead(200, { 'Content-Type': 'application/json' });
res.writeHead(500, { 'Content-Type': 'application/json' });
res.end(
JSON.stringify({
success: false,
Expand Down

0 comments on commit 1199c61

Please sign in to comment.