@ecopages/core
Advanced tools
+2
-2
| { | ||
| "name": "@ecopages/core", | ||
| "version": "0.2.0-beta.21", | ||
| "version": "0.2.0-beta.22", | ||
| "description": "Core package for Ecopages", | ||
@@ -20,3 +20,3 @@ "keywords": [ | ||
| "dependencies": { | ||
| "@ecopages/file-system": "0.2.0-beta.21", | ||
| "@ecopages/file-system": "0.2.0-beta.22", | ||
| "@ecopages/logger": "^0.2.3", | ||
@@ -23,0 +23,0 @@ "@ecopages/scripts-injector": "^0.1.5", |
@@ -44,1 +44,7 @@ /** | ||
| export declare function isHmrOutputFresh(outputPath: string, sourcePath: string): boolean; | ||
| /** | ||
| * @remarks | ||
| * Missing output is treated as a benign rebuild race. This helper isolates the | ||
| * post-build case where a bundle exists but is still older than its source. | ||
| */ | ||
| export declare function isHmrOutputOlderThanSource(outputPath: string, sourcePath: string): boolean; |
@@ -46,2 +46,8 @@ import fs from "node:fs"; | ||
| } | ||
| function isHmrOutputOlderThanSource(outputPath, sourcePath) { | ||
| if (!fileSystem.exists(outputPath) || !fileSystem.exists(sourcePath)) { | ||
| return false; | ||
| } | ||
| return fs.statSync(outputPath).mtimeMs < fs.statSync(sourcePath).mtimeMs; | ||
| } | ||
| export { | ||
@@ -51,2 +57,3 @@ encodeHmrDynamicSegments, | ||
| isHmrOutputFresh, | ||
| isHmrOutputOlderThanSource, | ||
| isRegisteredScriptEntrypoint, | ||
@@ -53,0 +60,0 @@ removeStaleHmrEntrypointOutput, |
@@ -9,3 +9,4 @@ import path from "node:path"; | ||
| isRegisteredScriptEntrypoint, | ||
| isHmrOutputFresh | ||
| isHmrOutputFresh, | ||
| isHmrOutputOlderThanSource | ||
| } from "../hmr-entrypoint-output.js"; | ||
@@ -204,3 +205,7 @@ class JsHmrStrategy extends HmrStrategy { | ||
| if (sourcePath && !isHmrOutputFresh(filepath, sourcePath)) { | ||
| appLogger.warn(`[JsHmrStrategy] Skipping broadcast for stale HMR output ${url}`); | ||
| if (isHmrOutputOlderThanSource(filepath, sourcePath)) { | ||
| appLogger.warn( | ||
| `[JsHmrStrategy] HMR output is older than source after rebuild; skipping broadcast for ${url}` | ||
| ); | ||
| } | ||
| return { success: false, requiresReload: false }; | ||
@@ -207,0 +212,0 @@ } |
1314290
0.05%32086
0.06%+ Added
- Removed