Skip to content

Commit a3cdfdd

Browse files
joeldicksondicko2
andauthored
Add logs, change response codes, change type for hmr vite (#36)
Co-authored-by: jdickson <joel.dickson@agoda.com>
1 parent 00aee1b commit a3cdfdd

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

packages/common/src/lib/common.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,7 @@ export const sendBuildData = async (
102102
return;
103103
}
104104

105-
console.log(`Your build stats has successfully been sent.`);
105+
console.log(
106+
`Your build stats has successfully been sent to ${endpoint} for ${buildStats.type}.`,
107+
);
106108
};

packages/common/src/lib/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export interface ViteBundleStats {
4949
}
5050

5151
export interface ViteBuildData extends CommonMetadata {
52-
type: 'vite';
52+
type: string;
5353
viteVersion: string | null;
5454
bundleStats?: ViteBundleStats;
5555
file: string | null;

packages/vite-plugin/src/lib/vite-build-stats-plugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export function viteBuildStatsPlugin(
9696

9797
const metricsData: ViteBuildData = {
9898
...getCommonMetadata(totalTime, customIdentifier),
99-
type: 'vite',
99+
type: 'vite-hmr',
100100
viteVersion: rollupVersion ?? null,
101101
bundleStats: {
102102
bootstrapChunkSizeBytes: undefined,
@@ -111,7 +111,7 @@ export function viteBuildStatsPlugin(
111111
res.writeHead(200, { 'Content-Type': 'application/json' });
112112
res.end(JSON.stringify({ success: true }));
113113
} else {
114-
res.writeHead(200, { 'Content-Type': 'application/json' });
114+
res.writeHead(404, { 'Content-Type': 'application/json' });
115115
res.end(
116116
JSON.stringify({
117117
success: false,
@@ -123,7 +123,7 @@ export function viteBuildStatsPlugin(
123123
}
124124
} catch (err) {
125125
console.error('[vite-timing] Error processing timing data:', err);
126-
res.writeHead(200, { 'Content-Type': 'application/json' });
126+
res.writeHead(500, { 'Content-Type': 'application/json' });
127127
res.end(
128128
JSON.stringify({
129129
success: false,

0 commit comments

Comments
 (0)