vaderjs 2.2.0 → 2.2.1
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/main.js +59 -54
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -207,7 +207,7 @@ async function generateApp() {
|
|
|
207
207
|
globalThis.isBuilding = true;
|
|
208
208
|
console.log(ansiColors.green('Building...'))
|
|
209
209
|
if (mode === 'development') {
|
|
210
|
-
|
|
210
|
+
|
|
211
211
|
} else {
|
|
212
212
|
fs.mkdirSync(process.cwd() + '/dist', { recursive: true })
|
|
213
213
|
}
|
|
@@ -271,11 +271,13 @@ async function generateApp() {
|
|
|
271
271
|
if (!fs.existsSync(process.cwd() + '/dev/readme.md')) {
|
|
272
272
|
fs.writeFileSync(process.cwd() + '/dev/readme.md', `# Please do not edit the bundler.js file in the dev directory. This file is automatically generated by the bundler. \n\n`)
|
|
273
273
|
}
|
|
274
|
-
fs.
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
274
|
+
if(!fs.existsSync(path.join(process.cwd(), '/dist/src/vader'))){
|
|
275
|
+
fs.mkdirSync(process.cwd() + '/dist/src/vader', { recursive: true })
|
|
276
|
+
fs.writeFileSync(process.cwd() + '/dist/src/vader/index.js', await new Bun.Transpiler({
|
|
277
|
+
loader: 'ts',
|
|
278
|
+
}).transformSync(await Bun.file(require.resolve('vaderjs')).text()))
|
|
279
|
+
}
|
|
280
|
+
await Bun.spawn({
|
|
279
281
|
cmd: [bunPath, 'run', './dev/bundler.js'] ,
|
|
280
282
|
cwd: process.cwd(),
|
|
281
283
|
stdout: 'inherit',
|
|
@@ -438,54 +440,57 @@ if (mode === 'development') {
|
|
|
438
440
|
try {
|
|
439
441
|
await generateApp()
|
|
440
442
|
await handleFiles()
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
host = config.host
|
|
460
|
-
|
|
461
|
-
globalThis.config = config
|
|
462
|
-
}
|
|
463
|
-
if (file.includes('dist')) return
|
|
464
|
-
clearTimeout(debounceTimeout);
|
|
465
|
-
debounceTimeout = setTimeout(async () => {
|
|
466
|
-
if (!isBuilding) { // Check if not already building
|
|
467
|
-
isBuilding = true; // Set build flag to true
|
|
468
|
-
try {
|
|
469
|
-
await generateApp();
|
|
470
|
-
await handleFiles();
|
|
471
|
-
let t = setTimeout(() => {
|
|
472
|
-
clients.forEach(c => {
|
|
473
|
-
c.send('reload');
|
|
474
|
-
});
|
|
475
|
-
clearTimeout(t)
|
|
476
|
-
}, 1000)
|
|
477
|
-
} catch (error) {
|
|
478
|
-
console.error(error);
|
|
479
|
-
} finally {
|
|
480
|
-
isBuilding = false; // Reset build flag
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
}, 500);
|
|
443
|
+
let watcher;
|
|
444
|
+
let isBuilding = false;
|
|
445
|
+
let debounceTimeout;
|
|
446
|
+
|
|
447
|
+
const startWatcher = () => {
|
|
448
|
+
if (watcher) watcher.close(); // Close any existing watcher
|
|
449
|
+
|
|
450
|
+
watcher = fs.watch(path.join(process.cwd(), '/'), { recursive: true }, (eventType, file) => {
|
|
451
|
+
if (!file) return; // Ensure file name is valid
|
|
452
|
+
if (file.includes('node_modules')) return;
|
|
453
|
+
|
|
454
|
+
if (
|
|
455
|
+
file.endsWith('.tsx') || file.endsWith('.jsx') || file.endsWith('.css') || file.endsWith('.ts')
|
|
456
|
+
) {
|
|
457
|
+
// Reset config if needed
|
|
458
|
+
if (file.endsWith('vader.config.ts')) {
|
|
459
|
+
delete require.cache[require.resolve(process.cwd() + '/vader.config.ts')];
|
|
460
|
+
globalThis.config = require(process.cwd() + '/vader.config.ts').default;
|
|
484
461
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
462
|
+
|
|
463
|
+
if (file.includes('dist')) return;
|
|
464
|
+
|
|
465
|
+
clearTimeout(debounceTimeout);
|
|
466
|
+
debounceTimeout = setTimeout(async () => {
|
|
467
|
+
if (!isBuilding) {
|
|
468
|
+
isBuilding = true;
|
|
469
|
+
try {
|
|
470
|
+
await generateApp();
|
|
471
|
+
await handleFiles();
|
|
472
|
+
setTimeout(() => {
|
|
473
|
+
clients.forEach(c => c.send('reload'));
|
|
474
|
+
}, 1000);
|
|
475
|
+
} catch (error) {
|
|
476
|
+
console.error(error);
|
|
477
|
+
} finally {
|
|
478
|
+
isBuilding = false;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}, 500);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// Restart watcher if a new directory is created
|
|
485
|
+
if (eventType === 'rename') {
|
|
486
|
+
setTimeout(startWatcher, 1000); // Slight delay to allow the OS to recognize new files
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
// Start the watcher and restart it periodically
|
|
492
|
+
setInterval(startWatcher, 10000);
|
|
493
|
+
startWatcher(); // Run initially
|
|
489
494
|
} catch (error) {
|
|
490
495
|
console.error(error)
|
|
491
496
|
}
|
|
@@ -611,4 +616,4 @@ if (mode == 'development' || mode == 'serve') {
|
|
|
611
616
|
}
|
|
612
617
|
|
|
613
618
|
|
|
614
|
-
|
|
619
|
+
|