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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dalila",
3
- "version": "1.5.9",
3
+ "version": "1.5.10",
4
4
  "description": "DOM-first reactive framework based on signals",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -883,94 +883,49 @@ const notifyHmr = (filename) => {
883
883
  };
884
884
 
885
885
  /**
886
- * Use chokidar for reliable cross-platform watching.
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
- let chokidar;
891
- try {
892
- chokidar = require('chokidar');
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
- if (chokidar) {
898
- // Use chokidar for reliable watching on all platforms
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
- watcher.on('change', (filePath) => {
915
- if (filePath.endsWith('.map')) return;
916
- const filename = path.relative(dir, filePath);
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
- watcher.on('add', (filePath) => {
921
- if (filePath.endsWith('.map')) return;
922
- const filename = path.relative(dir, filePath);
923
- notifyHmr(filename);
924
- });
925
-
926
- watcher.on('error', (err) => {
927
- console.error('[Watcher] Error:', err);
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
- function watchDirectory(dir) {
938
- if (!fs.existsSync(dir)) return;
939
-
940
- try {
941
- // Watch the directory itself
942
- const watcher = fs.watch(dir, (eventType, filename) => {
943
- if (!filename) return;
944
- if (filename.endsWith('.map')) return;
945
- notifyHmr(filename);
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
  // ============================================================================