vaderjs 2.0.9 → 2.1.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.
Files changed (2) hide show
  1. package/main.js +17 -54
  2. package/package.json +1 -1
package/main.js CHANGED
@@ -4,48 +4,9 @@ import ansiColors from 'ansi-colors'
4
4
  import { Glob } from 'bun'
5
5
  const args = Bun.argv.slice(2)
6
6
  globalThis.isBuilding = false;
7
- import fs from 'fs'
8
- import { spawn } from 'child_process'
9
- import { platform } from 'os'
7
+ import fs from 'fs'
10
8
  import path from 'path'
11
9
 
12
- let bunPath = 'bun'; // Default for Linux/Mac
13
- if (platform() === 'win32') {
14
- bunPath ='bun'; // Bun path for Windows
15
- } else {
16
- bunPath = path.resolve(process.env.HOME || process.env.USERPROFILE, '.bun', 'bin', 'bun');
17
- }
18
- async function checkIfBunInstalled(){
19
- return new Promise((resolve, reject) => {
20
- // dont log spawn output
21
- const install = spawn('bash', [ 'curl -fsSL https://bun.sh/install | bash && export PATH=$HOME/.bun/bin:$PATH'], {
22
- stdio: 'ignore',
23
- shell: true, // Allows running shell commands
24
- });
25
-
26
- install.on('close', (code) => {
27
- if (code === 0) {
28
- console.log('Bun installed successfully.');
29
- resolve(true);
30
- } else {
31
- console.error('Failed to install Bun.');
32
- reject(new Error('Bun installation failed.'));
33
- }
34
- });
35
-
36
- install.on('error', (err) => {
37
- console.error('Error during Bun installation:', err);
38
- reject(err);
39
- });
40
- });
41
- }
42
-
43
- if(!fs.existsSync(bunPath)){
44
- console.log('Bun is not installed, installing now...')
45
- await checkIfBunInstalled()
46
- }
47
-
48
-
49
10
 
50
11
  if (!fs.existsSync(process.cwd() + '/app') && !args.includes('init')) {
51
12
  console.error(`App directory not found in ${process.cwd()}/app`)
@@ -206,9 +167,8 @@ const handleReplacements = (code) => {
206
167
  line = b4
207
168
  }
208
169
  if (!hasImport && line.includes('useRef')) {
209
- line = line.replace(' ', '')
210
170
  let b4 = line
211
- let key = line.split('=')[0].split(' ').filter(Boolean)[1]
171
+ let key = line.split(' ')[1].split('=')[0]
212
172
  b4 = line.replace('useRef(', `this.useRef('${key}',`)
213
173
  line = b4
214
174
  }
@@ -226,7 +186,8 @@ if (!fs.existsSync(process.cwd() + '/dev/bundler.js')) {
226
186
  let start = Date.now()
227
187
  async function generateApp() {
228
188
  globalThis.isBuilding = true;
229
- console.log(ansiColors.green('Building...'))
189
+ console.log(ansiColors.green('Building...'))
190
+ console.log(`Starting build at ${new Date().toLocaleTimeString()}`)
230
191
  let plugins = config.plugins || []
231
192
  for (let plugin of plugins) {
232
193
  if (plugin.onBuildStart) {
@@ -296,14 +257,14 @@ async function generateApp() {
296
257
  loader: 'ts',
297
258
  }).transformSync(await Bun.file(require.resolve('vaderjs')).text()))
298
259
  Bun.spawn({
299
- cmd: [bunPath, 'run', './dev/bundler.js'] ,
260
+ cmd: ['bun', 'run', './dev/bundler.js'],
300
261
  cwd: process.cwd(),
301
262
  stdout: 'inherit',
302
263
  env: {
303
- ENTRYPOINT: path.join(process.cwd(), 'dist', path.dirname(r), path.basename(r)),
304
- ROOT: path.join(process.cwd(), 'app/'),
264
+ ENTRYPOINT: path.join(process.cwd() + '/dist/' + path.dirname(r) + '/' + path.basename(r)),
265
+ ROOT: process.cwd() + '/app/',
305
266
  OUT: path.dirname(r),
306
- file: path.join(process.cwd(), 'dist', path.dirname(r), path.basename(r)),
267
+ file: process.cwd() + '/dist/' + path.dirname(r) + '/' + path.basename(r),
307
268
  DEV: mode === 'development',
308
269
  size,
309
270
  bindes: bindes.join('\n'),
@@ -314,13 +275,15 @@ async function generateApp() {
314
275
  },
315
276
  onExit({ exitCode: code }) {
316
277
  if (code === 0) {
317
- bindes = [];
318
- resolve();
278
+ bindes = []
279
+ console.log(`Built ${r} in ${Date.now() - start}ms`)
280
+ resolve()
319
281
  } else {
320
- reject();
282
+ reject()
321
283
  }
322
- },
323
- });
284
+ }
285
+ })
286
+
324
287
  })
325
288
 
326
289
  switch (host_provider) {
@@ -391,7 +354,7 @@ function handleFiles() {
391
354
  file = file.replace('.jsx', '.js').replace('.tsx', '.js')
392
355
  fs.writeFileSync(path.join(process.cwd() + '/dist', file.replace('.jsx', '.js').replace('.tsx', '.js')), code)
393
356
  await Bun.spawn({
394
- cmd: [bunPath, 'run', './dev/bundler.js'],
357
+ cmd: ['bun', 'run', './dev/bundler.js'],
395
358
  cwd: process.cwd(),
396
359
  stdout: 'inherit',
397
360
  env: {
@@ -420,7 +383,7 @@ function handleFiles() {
420
383
  file = file.replace('.ts', '.js')
421
384
  fs.writeFileSync(path.join(process.cwd() + '/dist', file.replace('.ts', '.js')), code)
422
385
  await Bun.spawn({
423
- cmd: [bunPath, 'run', './dev/bundler.js'],
386
+ cmd: ['bun', 'run', './dev/bundler.js'],
424
387
  cwd: process.cwd(),
425
388
  stdout: 'inherit',
426
389
  env: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vaderjs",
3
- "version": "2.0.9",
3
+ "version": "2.1.0",
4
4
  "description": "A simple and powerful JavaScript library for building modern web applications.",
5
5
  "bin": {
6
6
  "vaderjs": "./main.js"