@ecopages/core 0.2.0-beta.21 → 0.2.0-beta.22
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecopages/core",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.22",
|
|
4
4
|
"description": "Core package for Ecopages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecopages",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"directory": "packages/core"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@ecopages/file-system": "0.2.0-beta.
|
|
20
|
+
"@ecopages/file-system": "0.2.0-beta.22",
|
|
21
21
|
"@ecopages/logger": "^0.2.3",
|
|
22
22
|
"@ecopages/scripts-injector": "^0.1.5",
|
|
23
23
|
"@oxc-project/runtime": "0.134.0",
|
|
@@ -41,3 +41,9 @@ export declare function removeStaleHmrEntrypointOutput(outputPath: string, scope
|
|
|
41
41
|
* fresher artifact than the edited source file.
|
|
42
42
|
*/
|
|
43
43
|
export declare function isHmrOutputFresh(outputPath: string, sourcePath: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* @remarks
|
|
46
|
+
* Missing output is treated as a benign rebuild race. This helper isolates the
|
|
47
|
+
* post-build case where a bundle exists but is still older than its source.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isHmrOutputOlderThanSource(outputPath: string, sourcePath: string): boolean;
|
|
@@ -43,10 +43,17 @@ function isHmrOutputFresh(outputPath, sourcePath) {
|
|
|
43
43
|
const sourceMtimeMs = fs.statSync(sourcePath).mtimeMs;
|
|
44
44
|
return outputMtimeMs >= sourceMtimeMs;
|
|
45
45
|
}
|
|
46
|
+
function isHmrOutputOlderThanSource(outputPath, sourcePath) {
|
|
47
|
+
if (!fileSystem.exists(outputPath) || !fileSystem.exists(sourcePath)) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
return fs.statSync(outputPath).mtimeMs < fs.statSync(sourcePath).mtimeMs;
|
|
51
|
+
}
|
|
46
52
|
export {
|
|
47
53
|
encodeHmrDynamicSegments,
|
|
48
54
|
isBrowserOnlyRegisteredScriptEntrypoint,
|
|
49
55
|
isHmrOutputFresh,
|
|
56
|
+
isHmrOutputOlderThanSource,
|
|
50
57
|
isRegisteredScriptEntrypoint,
|
|
51
58
|
removeStaleHmrEntrypointOutput,
|
|
52
59
|
resolveHmrEntrypointOutputPaths
|
|
@@ -6,7 +6,8 @@ import {
|
|
|
6
6
|
removeStaleHmrEntrypointOutput,
|
|
7
7
|
resolveHmrEntrypointOutputPaths,
|
|
8
8
|
isRegisteredScriptEntrypoint,
|
|
9
|
-
isHmrOutputFresh
|
|
9
|
+
isHmrOutputFresh,
|
|
10
|
+
isHmrOutputOlderThanSource
|
|
10
11
|
} from "../hmr-entrypoint-output.js";
|
|
11
12
|
class JsHmrStrategy extends HmrStrategy {
|
|
12
13
|
type = HmrStrategyType.SCRIPT;
|
|
@@ -200,7 +201,11 @@ class JsHmrStrategy extends HmrStrategy {
|
|
|
200
201
|
async processOutput(filepath, url, sourcePath) {
|
|
201
202
|
try {
|
|
202
203
|
if (sourcePath && !isHmrOutputFresh(filepath, sourcePath)) {
|
|
203
|
-
|
|
204
|
+
if (isHmrOutputOlderThanSource(filepath, sourcePath)) {
|
|
205
|
+
appLogger.warn(
|
|
206
|
+
`[JsHmrStrategy] HMR output is older than source after rebuild; skipping broadcast for ${url}`
|
|
207
|
+
);
|
|
208
|
+
}
|
|
204
209
|
return { success: false, requiresReload: false };
|
|
205
210
|
}
|
|
206
211
|
const code = await fileSystem.readFile(filepath);
|