neutronium 3.2.8 → 3.3.0

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.
@@ -97,21 +97,19 @@ function compileProjectWatch(projectDir = process.cwd(), port = 3000) {
97
97
  compileProject(projectDir);
98
98
 
99
99
  log('👀 Watching project for changes...');
100
+ log(`Watching directory: ${projectDir}`);
100
101
  log('✋ Press Ctrl+C to stop the development server');
101
102
 
102
103
  let timeout;
103
104
 
104
- const watcher = chokidar.watch([
105
- path.join(projectDir, '**/*.js'),
106
- path.join(projectDir, '**/*.ts'),
107
- path.join(projectDir, '**/*.tsx'),
108
- ], {
105
+ const watcher = chokidar.watch(projectDir, {
109
106
  ignoreInitial: true,
110
107
  ignored: [
108
+ /(^|[\/\\])\../, // dot files
111
109
  '**/node_modules/**',
112
- '**/dist/**',
110
+ '**/dist/**', // ← THIS IS CRITICAL
113
111
  '**/.git/**',
114
- 'compiler.js'
112
+ '**/compiler.js'
115
113
  ],
116
114
  persistent: true,
117
115
  followSymlinks: false,
@@ -123,11 +121,33 @@ function compileProjectWatch(projectDir = process.cwd(), port = 3000) {
123
121
  });
124
122
 
125
123
  watcher.on('ready', () => {
124
+ const watched = watcher.getWatched();
126
125
  log('📡 File watcher ready and monitoring changes...');
126
+ log(`Watching ${Object.keys(watched).length} directories`);
127
127
  });
128
128
 
129
+ // REMOVE the 'all' event listener - it's just for debugging
130
+ // watcher.on('all', (event, filePath) => {
131
+ // log(`📊 Event: ${event} - ${path.relative(projectDir, filePath)}`);
132
+ // });
133
+
129
134
  watcher.on('change', filePath => {
130
- if (!/\.(js|ts|tsx)$/.test(filePath)) return;
135
+ // Extra safety check: ignore dist folder
136
+ if (filePath.includes(path.sep + 'dist' + path.sep) || filePath.includes('/dist/')) {
137
+ return;
138
+ }
139
+ if (filePath.includes(path.sep + 'node_modules' + path.sep) || filePath.includes('/node_modules/')) {
140
+ return;
141
+ }
142
+ if (filePath.includes(path.sep + '.git' + path.sep) || filePath.includes('/.git/')) {
143
+ return;
144
+ }
145
+ if (filePath.includes(path.sep + 'compiler.js') || filePath.includes('/compiler.js')) {
146
+ return;
147
+ }
148
+ if (!/\.(js|ts|tsx)$/.test(filePath)) {
149
+ return;
150
+ }
131
151
 
132
152
  log(`🔍 Detected change in: ${path.relative(projectDir, filePath)}`);
133
153
 
@@ -136,8 +156,8 @@ function compileProjectWatch(projectDir = process.cwd(), port = 3000) {
136
156
  log('🔨 Rebuilding project...');
137
157
  try {
138
158
  const success = compileProject(projectDir);
139
- if (success && server.broadcastReload) {
140
- server.broadcastReload();
159
+ if (success && server) {
160
+ server();
141
161
  log('🔄 Browser reload triggered');
142
162
  }
143
163
  } catch (err) {
@@ -147,12 +167,18 @@ function compileProjectWatch(projectDir = process.cwd(), port = 3000) {
147
167
  });
148
168
 
149
169
  watcher.on('add', filePath => {
170
+ if (filePath.includes(path.sep + 'dist' + path.sep) || filePath.includes('/dist/')) {
171
+ return;
172
+ }
150
173
  if (/\.(js|ts|tsx)$/.test(filePath)) {
151
174
  log(`📝 New file added: ${path.relative(projectDir, filePath)}`);
152
175
  }
153
176
  });
154
177
 
155
178
  watcher.on('unlink', filePath => {
179
+ if (filePath.includes(path.sep + 'dist' + path.sep) || filePath.includes('/dist/')) {
180
+ return;
181
+ }
156
182
  if (/\.(js|ts|tsx)$/.test(filePath)) {
157
183
  log(`🗑️ File removed: ${path.relative(projectDir, filePath)}`);
158
184
  }
@@ -227,10 +253,9 @@ function serveProject(projectDir = process.cwd(), port = 3000) {
227
253
 
228
254
  wss.on('connection', (ws) => {
229
255
  log('🔌 WebSocket client connected');
230
- ws.on('close', () => log('🔌 WebSocket client disconnected'));
231
256
  });
232
257
 
233
- server.broadcastReload = () => {
258
+ let broadcastReload = () => {
234
259
  wss.clients.forEach(client => {
235
260
  if (client.readyState === WebSocket.OPEN) {
236
261
  client.send('reload');
@@ -242,7 +267,8 @@ function serveProject(projectDir = process.cwd(), port = 3000) {
242
267
  log(`🌐 Open your browser and navigate to: http://localhost:${port}`);
243
268
  });
244
269
 
245
- return server;
270
+ return broadcastReload;
271
+
246
272
  }
247
273
 
248
274
  module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neutronium",
3
- "version": "3.2.8",
3
+ "version": "3.3.0",
4
4
  "description": "Ultra-dense JavaScript framework – maximum performance, minimal overhead",
5
5
  "main": "src/index.js",
6
6
  "type": "commonjs",