Skip to content

Commit

Permalink
Add logs, change response codes, change type for hmr vite (#36)
Browse files Browse the repository at this point in the history
Co-authored-by: jdickson <joel.dickson@agoda.com>
  • Loading branch information
joeldickson and dicko2 authored Feb 13, 2025
1 parent 00aee1b commit a3cdfdd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion packages/common/src/lib/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,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: string;
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: 'vite-hmr',
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 a3cdfdd

Please sign in to comment.