rebuildjs 0.68.6 → 0.69.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/package.json +2 -2
  2. package/server/build/index.js +124 -125
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rebuildjs",
3
- "version": "0.68.6",
3
+ "version": "0.69.0",
4
4
  "description": "Reactive esbuild...simple hackable alternative to vite for Multi Page Apps",
5
5
  "keywords": [
6
6
  "reactive",
@@ -54,7 +54,7 @@
54
54
  "./package.json": "./package.json"
55
55
  },
56
56
  "dependencies": {
57
- "ctx-core": "^7.0.2",
57
+ "ctx-core": "^7.1.0",
58
58
  "elysia": "^1.0.10",
59
59
  "esbuild": "^0.20.2",
60
60
  "fdir": "^6.1.1",
@@ -2,10 +2,11 @@
2
2
  /// <reference types="./index.d.ts" />
3
3
  import { file_exists_, file_exists__waitfor } from 'ctx-core/fs'
4
4
  import {
5
- be,
5
+ calling,
6
6
  Cancel,
7
7
  cancel__period_,
8
8
  memo_,
9
+ ns_id_be,
9
10
  ns_id_be_memo_pair_,
10
11
  ns_id_be_sig_triple_,
11
12
  nullish__none_,
@@ -403,135 +404,133 @@ export function rebuildjs_plugin_() {
403
404
  */
404
405
  function rebuildjs_plugin__postprocess$_() {
405
406
  return (
406
- be(app_ctx, ctx=>
407
- run(memo_(rebuildjs__assets__link$=>{
408
- r()
409
- return rebuildjs__assets__link$
410
- function r() {
411
- if (!persist__metafile__ready_(ctx)) return
412
- nullish__none_([
413
- build_id_(ctx),
414
- metafile__build_id_(ctx),
415
- server__metafile_(ctx),
416
- browser__metafile_(ctx),
417
- cwd_(ctx),
418
- browser_path_(ctx),
419
- server__relative_path_(ctx),
420
- ], (
421
- build_id,
422
- metafile__build_id,
423
- server__metafile,
424
- browser__metafile,
425
- cwd,
426
- browser_path,
427
- server__relative_path,
428
- )=>{
429
- if (build_id === metafile__build_id) {
430
- run(async ()=>{
431
- try {
432
- await esbuild_cssBundle__cp()
433
- await Promise.all(
434
- rebuildjs__ready__add__ready$__a1_(ctx).map(ready$_=>
435
- cmd(rmemo__wait(
436
- ready$_(ctx),
437
- ready=>ready,
438
- 30_000))))
439
- await rebuildjs__assets__link()
440
- rebuildjs__build_id__set(ctx, build_id)
441
- } catch (err) {
442
- if (err instanceof Cancel) return
443
- throw err
444
- }
445
- }).catch(err=>console.error(err))
446
- }
447
- async function esbuild_cssBundle__cp() {
448
- for (const metafile of [server__metafile, browser__metafile]) {
449
- for (let output__relative_path in metafile.outputs) {
450
- let cssBundle, esbuild_cssBundle
451
- switch (extname(output__relative_path)) {
452
- case '.js':
453
- case '.mjs':
454
- ({ cssBundle, esbuild_cssBundle } = metafile.outputs[output__relative_path])
455
- if (cssBundle && esbuild_cssBundle) {
456
- const cssBundle_path = join(cwd_(ctx), cssBundle)
457
- const cssBundle_map_path = cssBundle_path + '.map'
458
- const esbuild_cssBundle_path = join(cwd_(ctx), esbuild_cssBundle)
459
- const esbuild_cssBundle_map_path = esbuild_cssBundle_path + '.map'
460
- if (!await file_exists_(esbuild_cssBundle_path)) {
461
- await file_exists__waitfor(async ()=>{
462
- await cmd(
463
- cp(cssBundle_path, esbuild_cssBundle_path))
464
- return true
465
- })
466
- }
467
- if (!await file_exists_(esbuild_cssBundle_map_path)) {
468
- await file_exists__waitfor(async ()=>{
469
- await cmd(
470
- cp(
471
- cssBundle_map_path,
472
- esbuild_cssBundle_map_path))
473
- return true
474
- })
475
- }
407
+ ns_id_be(
408
+ app_ctx,
409
+ 'app',
410
+ 'rebuildjs__assets__link$',
411
+ ctx=>calling(memo_(()=>{
412
+ if (!persist__metafile__ready_(ctx)) return
413
+ nullish__none_([
414
+ build_id_(ctx),
415
+ metafile__build_id_(ctx),
416
+ server__metafile_(ctx),
417
+ browser__metafile_(ctx),
418
+ cwd_(ctx),
419
+ browser_path_(ctx),
420
+ server__relative_path_(ctx),
421
+ ], (
422
+ build_id,
423
+ metafile__build_id,
424
+ server__metafile,
425
+ browser__metafile,
426
+ cwd,
427
+ browser_path,
428
+ server__relative_path,
429
+ )=>{
430
+ if (build_id === metafile__build_id) {
431
+ run(async ()=>{
432
+ try {
433
+ await esbuild_cssBundle__cp()
434
+ await Promise.all(
435
+ rebuildjs__ready__add__ready$__a1_(ctx).map(ready$_=>
436
+ cmd(rmemo__wait(
437
+ ready$_(ctx),
438
+ ready=>ready,
439
+ 30_000))))
440
+ await rebuildjs__assets__link()
441
+ rebuildjs__build_id__set(ctx, build_id)
442
+ } catch (err) {
443
+ if (err instanceof Cancel) return
444
+ throw err
445
+ }
446
+ }).catch(err=>console.error(err))
447
+ }
448
+ async function esbuild_cssBundle__cp() {
449
+ for (const metafile of [server__metafile, browser__metafile]) {
450
+ for (let output__relative_path in metafile.outputs) {
451
+ let cssBundle, esbuild_cssBundle
452
+ switch (extname(output__relative_path)) {
453
+ case '.js':
454
+ case '.mjs':
455
+ ({ cssBundle, esbuild_cssBundle } = metafile.outputs[output__relative_path])
456
+ if (cssBundle && esbuild_cssBundle) {
457
+ const cssBundle_path = join(cwd_(ctx), cssBundle)
458
+ const cssBundle_map_path = cssBundle_path + '.map'
459
+ const esbuild_cssBundle_path = join(cwd_(ctx), esbuild_cssBundle)
460
+ const esbuild_cssBundle_map_path = esbuild_cssBundle_path + '.map'
461
+ if (!await file_exists_(esbuild_cssBundle_path)) {
462
+ await file_exists__waitfor(async ()=>{
463
+ await cmd(
464
+ cp(cssBundle_path, esbuild_cssBundle_path))
465
+ return true
466
+ })
476
467
  }
477
- }
468
+ if (!await file_exists_(esbuild_cssBundle_map_path)) {
469
+ await file_exists__waitfor(async ()=>{
470
+ await cmd(
471
+ cp(
472
+ cssBundle_map_path,
473
+ esbuild_cssBundle_map_path))
474
+ return true
475
+ })
476
+ }
477
+ }
478
478
  }
479
479
  }
480
480
  }
481
- async function rebuildjs__assets__link() {
482
- const outputs = server__metafile.outputs ?? {}
483
- const promise_a1 = []
484
- for (let output__relative_path in outputs) {
485
- const _basename = basename(output__relative_path)
486
- if (
487
- _basename.endsWith('.js')
488
- || _basename.endsWith('.mjs')
489
- || _basename.endsWith('.js.map')
490
- || _basename.endsWith('.mjs.map')
491
- ) continue
492
- const server_asset_path = join(cwd, output__relative_path)
493
- const browser_asset_path = join(
494
- browser_path,
495
- relative(server__relative_path, output__relative_path))
496
- await file_exists__waitfor(async ()=>{
497
- await cmd(
498
- rm(browser_asset_path, { force: true }))
499
- await cmd(
500
- link(server_asset_path, browser_asset_path))
501
- return true
502
- }, Infinity)
503
- promise_a1.push(file_exists__waitfor(browser_asset_path))
504
- }
505
- await cmd(Promise.all(promise_a1))
506
- }
507
- async function cmd(promise) {
508
- if (cancel_()) promise__cancel__throw(promise)
509
- promise.rebuildjs_cancel$ = run(memo_(rebuildjs_cancel$=>{
510
- if (cancel_()) {
511
- promise__cancel(promise)
512
- off(rebuildjs_cancel$)
513
- }
514
- return rebuildjs_cancel$
515
- }))
516
- const ret = await promise
517
- if (cancel_()) promise__cancel__throw(promise)
518
- return ret
519
- }
520
- function cancel_() {
521
- return (
522
- build_id_(ctx) !== build_id
523
- || metafile__build_id_(ctx) !== metafile__build_id
524
- || server__metafile_(ctx) !== server__metafile
525
- || browser__metafile_(ctx) !== browser__metafile
526
- || cwd_(ctx) !== cwd
527
- || browser_path_(ctx) !== browser_path
528
- || server__relative_path_(ctx) !== server__relative_path
529
- )
481
+ }
482
+ async function rebuildjs__assets__link() {
483
+ const outputs = server__metafile.outputs ?? {}
484
+ const promise_a1 = []
485
+ for (let output__relative_path in outputs) {
486
+ const _basename = basename(output__relative_path)
487
+ if (
488
+ _basename.endsWith('.js')
489
+ || _basename.endsWith('.mjs')
490
+ || _basename.endsWith('.js.map')
491
+ || _basename.endsWith('.mjs.map')
492
+ ) continue
493
+ const server_asset_path = join(cwd, output__relative_path)
494
+ const browser_asset_path = join(
495
+ browser_path,
496
+ relative(server__relative_path, output__relative_path))
497
+ await file_exists__waitfor(async ()=>{
498
+ await cmd(
499
+ rm(browser_asset_path, { force: true }))
500
+ await cmd(
501
+ link(server_asset_path, browser_asset_path))
502
+ return true
503
+ }, Infinity)
504
+ promise_a1.push(file_exists__waitfor(browser_asset_path))
530
505
  }
531
- })
532
- }
533
- })),
534
- { id: 'rebuildjs__assets__link$', ns: 'app' })
506
+ await cmd(Promise.all(promise_a1))
507
+ }
508
+ async function cmd(promise) {
509
+ if (cancel_()) promise__cancel__throw(promise)
510
+ promise.rebuildjs_cancel$ = run(memo_(rebuildjs_cancel$=>{
511
+ if (cancel_()) {
512
+ promise__cancel(promise)
513
+ off(rebuildjs_cancel$)
514
+ }
515
+ return rebuildjs_cancel$
516
+ }))
517
+ const ret = await promise
518
+ if (cancel_()) promise__cancel__throw(promise)
519
+ return ret
520
+ }
521
+ function cancel_() {
522
+ return (
523
+ build_id_(ctx) !== build_id
524
+ || metafile__build_id_(ctx) !== metafile__build_id
525
+ || server__metafile_(ctx) !== server__metafile
526
+ || browser__metafile_(ctx) !== browser__metafile
527
+ || cwd_(ctx) !== cwd
528
+ || browser_path_(ctx) !== browser_path
529
+ || server__relative_path_(ctx) !== server__relative_path
530
+ )
531
+ }
532
+ })
533
+ })))
535
534
  )
536
535
  }
537
536
  }