vaderjs 1.6.2 → 1.6.4

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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/main.js +30 -14
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  <a href="https://vader-js.pages.dev">
3
3
  <picture>
4
4
  <source media="(prefers-color-scheme: dark)" srcset="/icon.jpeg">
5
- <img src="./logo.png" height="128">
5
+ <img src="https://github.com/Postr-Inc/Vader.js/blob/main/logo.png" height="128">
6
6
  </picture>
7
7
  <h1 align="center">Vader.js</h1>
8
8
  </a>
@@ -86,4 +86,4 @@ export default defineConfig({
86
86
  plugins: [cloudflare, tailwindcss],
87
87
  });
88
88
 
89
- ```
89
+ ```
package/main.js CHANGED
@@ -3,6 +3,7 @@
3
3
  import ansiColors from 'ansi-colors'
4
4
  import { Glob } from 'bun'
5
5
  const args = Bun.argv.slice(2)
6
+ globalThis.isBuilding = false;
6
7
  import fs from 'fs'
7
8
  import path from 'path'
8
9
  if (!fs.existsSync(process.cwd() + '/app') && !args.includes('init')) {
@@ -23,10 +24,11 @@ export default defineConfig({
23
24
  host_provider: 'apache'
24
25
  })`)
25
26
  }
26
- const mode = args.includes('dev') ? 'development' : args.includes('prod') || args.includes('build') ? 'production' : args.includes('init') ? 'init' : null
27
+ const mode = args.includes('dev') ? 'development' : args.includes('prod') || args.includes('build') ? 'production' : args.includes('init') ? 'init' : args.includes('serve') ? 'serve' : null;
27
28
  if (!mode) {
28
29
  console.log(`
29
30
  Usage:
31
+ bun vaderjs serve - Start the server
30
32
  bun vaderjs dev - Start development server output in dist/
31
33
  bun vaderjs prod - Build for production output in dist/
32
34
  bun vaderjs init - Initialize a new vaderjs project
@@ -39,7 +41,7 @@ if (mode === 'init') {
39
41
  console.error('App directory already exists: just run `bun vaderjs dev` to start the development server')
40
42
  process.exit(1)
41
43
  }
42
- fs.mkdirSync(process.cwd() + '/app')
44
+ fs.mkdirSync(process.cwd() + '/app')
43
45
  fs.copyFileSync(path.join(process.cwd(), "/node_modules/vaderjs/example/counter/index.jsx"), path.join(process.cwd(), "/app/index.jsx"))
44
46
 
45
47
  console.log('Initialized new vaderjs project: run `bun vaderjs dev` to start the development server')
@@ -51,13 +53,11 @@ console.log(
51
53
  Mode: ${mode}
52
54
  SSR: ${require(process.cwd() + '/vader.config.ts').default.ssr ? 'Enabled' : 'Disabled'}
53
55
  PORT: ${require(process.cwd() + '/vader.config.ts').default.port || 8080}
56
+ ${mode == 'serve' ? `SSL: ${require(process.cwd() + '/vader.config.ts').default?.ssl?.enabled ? 'Enabled' : 'Disabled'} ` : ``}
54
57
  `
55
58
  )
56
59
 
57
60
 
58
- console.log(ansiColors.green('Building...'))
59
- let start = Date.now()
60
- console.log(`Starting build at ${new Date().toLocaleTimeString()}`)
61
61
  let { port, host, host_provider } = require(process.cwd() + '/vader.config.ts').default
62
62
  if (host_provider === 'apache' && mode === 'development') {
63
63
  console.warn('Note: SSR will not work with Apache')
@@ -140,7 +140,11 @@ const handleReplacements = (code) => {
140
140
  }
141
141
 
142
142
 
143
+ let start = Date.now()
143
144
  async function generateApp() {
145
+ globalThis.isBuilding = true;
146
+ console.log(ansiColors.green('Building...'))
147
+ console.log(`Starting build at ${new Date().toLocaleTimeString()}`)
144
148
  // remove files from dist
145
149
  if (mode === 'development') {
146
150
  fs.rmdirSync(process.cwd() + '/dist', { recursive: true })
@@ -240,14 +244,13 @@ async function generateApp() {
240
244
  break;
241
245
  case 'apache':
242
246
  let data = ''
243
-
247
+
244
248
  }
245
249
 
246
250
  })
247
251
 
248
252
  }
249
253
 
250
- await generateApp()
251
254
  function handleFiles() {
252
255
  return new Promise(async (resolve, reject) => {
253
256
  try {
@@ -283,6 +286,7 @@ function handleFiles() {
283
286
  DEV: mode === 'development',
284
287
  size: code.length / 1024,
285
288
  filePath: file.replace('.jsx', '.js'),
289
+ isTs: file.includes('.tsx'),
286
290
  INPUT: path.join(process.cwd(), file.replace('.js', '.jsx').replace('.tsx', '.js')),
287
291
  },
288
292
  onExit({ exitCode: code }) {
@@ -331,10 +335,11 @@ function handleFiles() {
331
335
  }
332
336
  })
333
337
  }
334
- await handleFiles()
335
338
  globalThis.clients = []
336
339
 
337
340
  if (mode === 'development') {
341
+ await generateApp()
342
+ await handleFiles()
338
343
  const watcher = fs.watch(path.join(process.cwd() + '/'), { recursive: true })
339
344
  let isBuilding = false; // Flag to track build status
340
345
 
@@ -370,6 +375,19 @@ if (mode === 'development') {
370
375
 
371
376
  // Event listeners with debounced handling
372
377
  watcher.on('change', handleFileChangeDebounced);
378
+
379
+ }
380
+ else if(mode == 'production'){
381
+ await handleFiles()
382
+ await generateApp()
383
+ }
384
+ else {
385
+ if (isBuilding) console.log(`Build complete in ${Date.now() - start}ms at ${new Date().toLocaleTimeString()}`);
386
+
387
+ }
388
+
389
+
390
+ if (mode == 'development' || mode == 'serve') {
373
391
  let server = Bun.serve({
374
392
  port: port || 8080,
375
393
  websocket: {
@@ -426,6 +444,7 @@ if (mode === 'development') {
426
444
  let ws = new WebSocket('ws://localhost:${server.port}')
427
445
  ws.onmessage = (e) => {
428
446
  if(e.data === 'reload'){
447
+ console.log('Reloading to display changes from server')
429
448
  window.location.reload()
430
449
  }
431
450
  }
@@ -445,9 +464,6 @@ if (mode === 'development') {
445
464
 
446
465
  }
447
466
  })
448
- } else {
449
- console.log(`Build complete in ${Date.now() - start}ms at ${new Date().toLocaleTimeString()}`)
450
- process.exit(0)
451
- }
452
-
453
- console.log(ansiColors.green('Server started at http://localhost:' + port || 8080))
467
+
468
+ console.log(ansiColors.green('Server started at http://localhost:' + port || 8080))
469
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vaderjs",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "description": "A simple and powerful JavaScript library for building modern web applications.",
5
5
  "bin": {
6
6
  "vaderjs": "./main.js"