Skip to content

Commit

Permalink
0.1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
dicko2 committed Jan 22, 2025
1 parent 9564f40 commit 4a7093f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "agoda-devfeedback-vite",
"version": "0.1.11",
"version": "0.1.12",
"description": "Vite plugin for collecting and reporting development feedback metrics",
"type": "module",
"exports": {
Expand Down
53 changes: 27 additions & 26 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,35 +44,36 @@ export default function viteTimingPlugin(): ViteTimingPlugin {
`,
// Create a virtual module for our HMR hooks
virtualHmrModule: `
import { createHotContext } from 'vite/client';
// Use Vite's client entry point
import { createHotContext as __vite__createHotContext } from '/@vite/client';
const hot = createHotContext('/@vite-timing/hmr');
console.log('[vite-timing] Setting up HMR hooks with hot context:', !!hot);
const hot = __vite__createHotContext('/@vite-timing/hmr');
console.log('[vite-timing] Setting up HMR hooks with hot context:', !!hot);
if (hot) {
hot.on('vite:beforeUpdate', (data) => {
console.log('[vite-timing] beforeUpdate:', data);
if (window.__VITE_TIMING__ && Array.isArray(data.updates)) {
data.updates.forEach(update => {
if (update.path) {
window.__VITE_TIMING__.markHMRStart(update.path);
}
});
}
});
if (hot) {
hot.on('vite:beforeUpdate', (data) => {
console.log('[vite-timing] beforeUpdate:', data);
if (window.__VITE_TIMING__ && Array.isArray(data.updates)) {
data.updates.forEach(update => {
if (update.path) {
window.__VITE_TIMING__.markHMRStart(update.path);
}
});
}
});
hot.on('vite:afterUpdate', (data) => {
console.log('[vite-timing] afterUpdate:', data);
if (window.__VITE_TIMING__ && Array.isArray(data.updates)) {
data.updates.forEach(update => {
if (update.path) {
window.__VITE_TIMING__.markHMREnd(update.path);
}
});
}
});
}
`
hot.on('vite:afterUpdate', (data) => {
console.log('[vite-timing] afterUpdate:', data);
if (window.__VITE_TIMING__ && Array.isArray(data.updates)) {
data.updates.forEach(update => {
if (update.path) {
window.__VITE_TIMING__.markHMREnd(update.path);
}
});
}
});
}
`
};

const handleHMRComplete = async (
Expand Down

0 comments on commit 4a7093f

Please sign in to comment.