@commercebuild/extension 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -19,8 +19,13 @@ export default function ViteHMRNotifierPlugin() {
|
|
|
19
19
|
});
|
|
20
20
|
console.debug("[hmr-notifier] WebSocket mounted at /hmr-notifier");
|
|
21
21
|
let building = false;
|
|
22
|
+
let pendingChanges = false;
|
|
23
|
+
|
|
22
24
|
server.watcher.on("change", async (file) => {
|
|
23
|
-
if (building)
|
|
25
|
+
if (building) {
|
|
26
|
+
pendingChanges = true;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
24
29
|
building = true;
|
|
25
30
|
console.debug(`[hmr-notifier] File changed: ${file}, Rebuilding...`);
|
|
26
31
|
try {
|
|
@@ -36,8 +41,14 @@ export default function ViteHMRNotifierPlugin() {
|
|
|
36
41
|
});
|
|
37
42
|
} catch (err) {
|
|
38
43
|
console.error(`[hmr-notifier] Build failed:`, err);
|
|
44
|
+
} finally {
|
|
45
|
+
building = false;
|
|
46
|
+
if (pendingChanges) {
|
|
47
|
+
pendingChanges = false;
|
|
48
|
+
// Emit change event to re-trigger build after current build completes
|
|
49
|
+
server.watcher.emit("change", file);
|
|
50
|
+
}
|
|
39
51
|
}
|
|
40
|
-
building = false;
|
|
41
52
|
});
|
|
42
53
|
},
|
|
43
54
|
};
|