neutronium 3.3.5 → 3.3.7

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.
@@ -71,57 +71,6 @@ async function compileProject(projectDir = process.cwd()) {
71
71
  code = `import * as _neutronium from './${neutroniumPath.replace(/\\/g, '/')}';\n\n${code}`;
72
72
  }
73
73
 
74
- // Check if code uses node_modules (detect imports that aren't relative)
75
- const nodeModuleImportRegex = /from\s+['"]((?!\.\/|\.\.\/|neutronium)[^'"]+)['"]/g;
76
- const matches = [...code.matchAll(nodeModuleImportRegex)];
77
-
78
- if (matches.length > 0) {
79
- log(`📦 Detected node_modules imports in ${file}`);
80
-
81
- // Copy node_modules to dist if it exists
82
- const srcNodeModules = path.join(projectDir, 'node_modules');
83
- const distNodeModules = path.join(distDir, 'node_modules');
84
-
85
- if (fs.existsSync(srcNodeModules)) {
86
- if (!fs.existsSync(distNodeModules)) {
87
- log('📂 Copying node_modules to dist...');
88
-
89
- // Create a symlink instead of copying (faster)
90
- try {
91
- fs.symlinkSync(srcNodeModules, distNodeModules, 'junction');
92
- log('🔗 Created symlink to node_modules');
93
- } catch (err) {
94
- // If symlink fails, fall back to copying specific packages
95
- log('📋 Symlinking failed, copying required packages...');
96
- ensureDir(distNodeModules);
97
-
98
- // Copy only the packages that are actually imported
99
- const packagesToCopy = new Set();
100
- matches.forEach(match => {
101
- const packageName = match[1].split('/')[0];
102
- if (packageName.startsWith('@')) {
103
- // Scoped package like @babel/core
104
- packagesToCopy.add(match[1].split('/').slice(0, 2).join('/'));
105
- } else {
106
- packagesToCopy.add(packageName);
107
- }
108
- });
109
-
110
- packagesToCopy.forEach(pkg => {
111
- const srcPkg = path.join(srcNodeModules, pkg);
112
- const distPkg = path.join(distNodeModules, pkg);
113
- if (fs.existsSync(srcPkg)) {
114
- copyRecursiveSync(srcPkg, distPkg);
115
- log(` ✓ Copied ${pkg}`);
116
- }
117
- });
118
- }
119
- }
120
- } else {
121
- log('⚠️ Warning: node_modules not found, imports may fail');
122
- }
123
- }
124
-
125
74
  // Replace imports to "neutronium" with local path
126
75
  code = code.replace(/from\s+['"]neutronium['"]/g, `from './${neutroniumPath.replace(/\\/g, '/')}'`);
127
76
 
@@ -187,9 +136,6 @@ function compileProjectWatch(projectDir = process.cwd(), port = 3000) {
187
136
  if (filePath.includes(path.sep + 'dist' + path.sep) || filePath.includes('/dist/')) {
188
137
  return;
189
138
  }
190
- if (filePath.includes(path.sep + 'node_modules' + path.sep) || filePath.includes('/node_modules/')) {
191
- return;
192
- }
193
139
  if (filePath.includes(path.sep + '.git' + path.sep) || filePath.includes('/.git/')) {
194
140
  return;
195
141
  }
@@ -218,18 +164,12 @@ function compileProjectWatch(projectDir = process.cwd(), port = 3000) {
218
164
  });
219
165
 
220
166
  watcher.on('add', filePath => {
221
- if (filePath.includes(path.sep + 'dist' + path.sep) || filePath.includes('/dist/') || filePath.includes(path.sep + 'node_modules' + path.sep) || filePath.includes("node_modules")) {
222
- return;
223
- }
224
167
  if (/\.(js|ts|tsx)$/.test(filePath)) {
225
168
  log(`📝 New file added: ${path.relative(projectDir, filePath)}`);
226
169
  }
227
170
  });
228
171
 
229
172
  watcher.on('unlink', filePath => {
230
- if (filePath.includes(path.sep + 'dist' + path.sep) || filePath.includes('/dist/')) {
231
- return;
232
- }
233
173
  if (/\.(js|ts|tsx)$/.test(filePath)) {
234
174
  log(`🗑️ File removed: ${path.relative(projectDir, filePath)}`);
235
175
  }
@@ -259,7 +199,11 @@ function serveProject(projectDir = process.cwd(), port = 3000) {
259
199
  if (reqPath === '/' || reqPath === '/index.html') {
260
200
  reqPath = '/dist/index.html';
261
201
  }
262
- else if (!reqPath.startsWith('/dist/')) {
202
+ else if (reqPath.startsWith('node_modules')) {
203
+ reqPath = reqPath.replace('/node_modules', '');
204
+ reqPath = "/node_modules/" + reqPath;
205
+ }
206
+ else if (!reqPath.startsWith('/dist/') && !reqPath.startsWith('node_modules')) {
263
207
  reqPath = '/dist' + reqPath;
264
208
  }
265
209
 
@@ -342,29 +286,8 @@ function serveProject(projectDir = process.cwd(), port = 3000) {
342
286
 
343
287
  }
344
288
 
345
- function copyRecursiveSync(src, dest) {
346
- const exists = fs.existsSync(src);
347
- const stats = exists && fs.statSync(src);
348
- const isDirectory = exists && stats.isDirectory();
349
-
350
- if (isDirectory) {
351
- if (!fs.existsSync(dest)) {
352
- fs.mkdirSync(dest, { recursive: true });
353
- }
354
- fs.readdirSync(src).forEach(childItemName => {
355
- copyRecursiveSync(
356
- path.join(src, childItemName),
357
- path.join(dest, childItemName)
358
- );
359
- });
360
- } else {
361
- fs.copyFileSync(src, dest);
362
- }
363
- }
364
-
365
289
  module.exports = {
366
290
  compileProject,
367
291
  compileProjectWatch,
368
- serveProject,
369
- copyRecursiveSync
292
+ serveProject
370
293
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neutronium",
3
- "version": "3.3.5",
3
+ "version": "3.3.7",
4
4
  "description": "Ultra-dense JavaScript framework – maximum performance, minimal overhead",
5
5
  "main": "src/index.js",
6
6
  "type": "commonjs",