dalila 1.5.9 → 1.5.10
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 +1 -1
- package/scripts/dev-server.cjs +32 -77
package/package.json
CHANGED
package/scripts/dev-server.cjs
CHANGED
|
@@ -883,94 +883,49 @@ const notifyHmr = (filename) => {
|
|
|
883
883
|
};
|
|
884
884
|
|
|
885
885
|
/**
|
|
886
|
-
* Use
|
|
887
|
-
* Falls back to polling-based fs.watch if chokidar is not available.
|
|
886
|
+
* Use native fs.watch for file watching.
|
|
888
887
|
*/
|
|
889
888
|
function setupWatcher() {
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
} catch {
|
|
894
|
-
chokidar = null;
|
|
895
|
-
}
|
|
889
|
+
// Manual directory walking + fs.watch on each file/subdir
|
|
890
|
+
// fs.watch with recursive:true doesn't work reliably on Linux
|
|
891
|
+
console.log('[Watcher] Using fs.watch');
|
|
896
892
|
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
console.log('[Watcher] Using chokidar');
|
|
900
|
-
|
|
901
|
-
watchTargets.forEach((dir) => {
|
|
902
|
-
if (!fs.existsSync(dir)) return;
|
|
903
|
-
|
|
904
|
-
const watcher = chokidar.watch(dir, {
|
|
905
|
-
ignored: /(^|[\/\\])\../, // Ignore dotfiles
|
|
906
|
-
persistent: true,
|
|
907
|
-
ignoreInitial: true,
|
|
908
|
-
awaitWriteFinish: {
|
|
909
|
-
stabilityThreshold: 100,
|
|
910
|
-
pollInterval: 50,
|
|
911
|
-
},
|
|
912
|
-
});
|
|
893
|
+
function watchDirectory(dir) {
|
|
894
|
+
if (!fs.existsSync(dir)) return;
|
|
913
895
|
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
896
|
+
try {
|
|
897
|
+
// Watch the directory itself
|
|
898
|
+
const watcher = fs.watch(dir, (eventType, filename) => {
|
|
899
|
+
if (!filename) return;
|
|
900
|
+
if (filename.endsWith('.map')) return;
|
|
917
901
|
notifyHmr(filename);
|
|
918
|
-
});
|
|
919
902
|
|
|
920
|
-
|
|
921
|
-
if (
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
903
|
+
// Check if a new subdirectory was added
|
|
904
|
+
if (eventType === 'rename') {
|
|
905
|
+
const fullPath = path.join(dir, filename);
|
|
906
|
+
try {
|
|
907
|
+
const stat = fs.statSync(fullPath);
|
|
908
|
+
if (stat.isDirectory()) {
|
|
909
|
+
watchDirectory(fullPath);
|
|
910
|
+
}
|
|
911
|
+
} catch { /* file might have been deleted */ }
|
|
912
|
+
}
|
|
928
913
|
});
|
|
929
|
-
|
|
930
914
|
watchers.push(watcher);
|
|
931
|
-
});
|
|
932
|
-
} else {
|
|
933
|
-
// Fallback: Manual directory walking + fs.watch on each file/subdir
|
|
934
|
-
// fs.watch with recursive:true doesn't work reliably on Linux
|
|
935
|
-
console.log('[Watcher] Using fs.watch fallback (install chokidar for better performance)');
|
|
936
915
|
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
// Check if a new subdirectory was added
|
|
948
|
-
if (eventType === 'rename') {
|
|
949
|
-
const fullPath = path.join(dir, filename);
|
|
950
|
-
try {
|
|
951
|
-
const stat = fs.statSync(fullPath);
|
|
952
|
-
if (stat.isDirectory()) {
|
|
953
|
-
watchDirectory(fullPath);
|
|
954
|
-
}
|
|
955
|
-
} catch { /* file might have been deleted */ }
|
|
956
|
-
}
|
|
957
|
-
});
|
|
958
|
-
watchers.push(watcher);
|
|
959
|
-
|
|
960
|
-
// Watch subdirectories recursively
|
|
961
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
962
|
-
entries.forEach((entry) => {
|
|
963
|
-
if (entry.isDirectory() && !entry.name.startsWith('.')) {
|
|
964
|
-
watchDirectory(path.join(dir, entry.name));
|
|
965
|
-
}
|
|
966
|
-
});
|
|
967
|
-
} catch (err) {
|
|
968
|
-
console.warn('[Watcher] Could not watch:', dir, err.message);
|
|
969
|
-
}
|
|
916
|
+
// Watch subdirectories recursively
|
|
917
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
918
|
+
entries.forEach((entry) => {
|
|
919
|
+
if (entry.isDirectory() && !entry.name.startsWith('.')) {
|
|
920
|
+
watchDirectory(path.join(dir, entry.name));
|
|
921
|
+
}
|
|
922
|
+
});
|
|
923
|
+
} catch (err) {
|
|
924
|
+
console.warn('[Watcher] Could not watch:', dir, err.message);
|
|
970
925
|
}
|
|
971
|
-
|
|
972
|
-
watchTargets.forEach((dir) => watchDirectory(dir));
|
|
973
926
|
}
|
|
927
|
+
|
|
928
|
+
watchTargets.forEach((dir) => watchDirectory(dir));
|
|
974
929
|
}
|
|
975
930
|
|
|
976
931
|
// ============================================================================
|