rebuildjs 0.24.3 → 0.26.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.
@@ -0,0 +1,231 @@
1
+ import { type rebuildjs_metafile_T } from '../metafile_l0/index.js'
2
+ export const browser__metafile0 = Object.freeze({
3
+ inputs: {
4
+ '../input/path0': {
5
+ 'bytes': 224,
6
+ 'imports': [],
7
+ 'format': 'esm'
8
+ },
9
+ },
10
+ outputs: {
11
+ 'dist/browser--dev/index.browser-BRS0BRS0.js.map': {
12
+ 'imports': [],
13
+ 'exports': [],
14
+ 'inputs': {},
15
+ 'bytes': 323
16
+ },
17
+ 'dist/browser--dev/index.browser-BRS0BRS0.js': {
18
+ 'imports': [],
19
+ 'exports': [],
20
+ 'entryPoint': 'src/app/index.browser.ts',
21
+ 'inputs': {
22
+ '../input/path0': {
23
+ 'bytesInOutput': 98
24
+ },
25
+ },
26
+ 'bytes': 98
27
+ }
28
+ },
29
+ rebuildjs_target: 'browser',
30
+ build_id: '1703808862263-OuJG4giiT8K7+PMT4mK+Bg',
31
+ }) as rebuildjs_metafile_T
32
+ export const server__metafile0 = Object.freeze({
33
+ inputs: {
34
+ '../input/path0': {
35
+ 'bytes': 224,
36
+ 'imports': [],
37
+ 'format': 'esm'
38
+ },
39
+ },
40
+ outputs: {
41
+ 'dist/server--dev/index.server-SVR0SVR0.js.map': {
42
+ 'imports': [],
43
+ 'exports': [],
44
+ 'inputs': {},
45
+ 'bytes': 323
46
+ },
47
+ 'dist/server--dev/index.server-SVR0SVR0.js': {
48
+ 'imports': [],
49
+ 'exports': [],
50
+ 'entryPoint': 'src/app/index.server.ts',
51
+ 'cssBundle': 'dist/server--dev/index.server-SVR0SVR0.css',
52
+ 'inputs': {
53
+ '../input/path0': {
54
+ 'bytesInOutput': 98
55
+ },
56
+ },
57
+ 'bytes': 98
58
+ }
59
+ },
60
+ rebuildjs_target: 'server',
61
+ build_id: '1703808862263-OuJG4giiT8K7+PMT4mK+Bg',
62
+ }) as rebuildjs_metafile_T
63
+ export const browser__metafile1 = Object.freeze({
64
+ inputs: {
65
+ '../input/path0': {
66
+ 'bytes': 224,
67
+ 'imports': [],
68
+ 'format': 'esm'
69
+ },
70
+ '../input/path1': {
71
+ 'bytes': 62,
72
+ 'imports': [],
73
+ 'format': 'esm'
74
+ }
75
+ },
76
+ outputs: {
77
+ 'dist/browser--dev/index.browser-BRS1BRS1.js.map': {
78
+ 'imports': [],
79
+ 'exports': [],
80
+ 'inputs': {},
81
+ 'bytes': 323
82
+ },
83
+ 'dist/browser--dev/index.browser-BRS1BRS1.js': {
84
+ 'imports': [],
85
+ 'exports': [],
86
+ 'entryPoint': 'src/app/index.browser.ts',
87
+ 'inputs': {
88
+ '../input/path0': {
89
+ 'bytesInOutput': 98
90
+ },
91
+ '../input/path1': {
92
+ 'bytesInOutput': 50
93
+ },
94
+ },
95
+ 'bytes': 148
96
+ },
97
+ },
98
+ "rebuildjs_target": "browser",
99
+ "build_id": "1703809126591-ihwT4FatSz6ubDMbQLEQNA",
100
+ }) as rebuildjs_metafile_T
101
+ export const server__metafile1 = Object.freeze({
102
+ inputs: {
103
+ '../input/path0': {
104
+ 'bytes': 224,
105
+ 'imports': [],
106
+ 'format': 'esm'
107
+ },
108
+ '../input/path1': {
109
+ 'bytes': 62,
110
+ 'imports': [],
111
+ 'format': 'esm'
112
+ }
113
+ },
114
+ outputs: {
115
+ 'dist/server--dev/index.server-SVR1SVR1.js.map': {
116
+ 'imports': [],
117
+ 'exports': [],
118
+ 'inputs': {},
119
+ 'bytes': 323
120
+ },
121
+ 'dist/server--dev/index.server-SVR1SVR1.js': {
122
+ 'imports': [],
123
+ 'exports': [],
124
+ 'entryPoint': 'src/app/index.server.ts',
125
+ 'cssBundle': 'dist/server--dev/index.server-SVR1SVR1.css',
126
+ 'inputs': {
127
+ '../input/path0': {
128
+ 'bytesInOutput': 98
129
+ },
130
+ '../input/path1': {
131
+ 'bytesInOutput': 50
132
+ },
133
+ },
134
+ 'bytes': 148
135
+ },
136
+ },
137
+ "rebuildjs_target": "server",
138
+ "build_id": "1703809126591-ihwT4FatSz6ubDMbQLEQNA",
139
+ }) as rebuildjs_metafile_T
140
+ export const browser__metafile2 = Object.freeze({
141
+ inputs: {
142
+ '../input/path0': {
143
+ 'bytes': 224,
144
+ 'imports': [],
145
+ 'format': 'esm'
146
+ },
147
+ '../input/path1': {
148
+ 'bytes': 62,
149
+ 'imports': [],
150
+ 'format': 'esm'
151
+ },
152
+ '../input/path2': {
153
+ 'bytes': 100,
154
+ 'imports': [],
155
+ 'format': 'esm'
156
+ }
157
+ },
158
+ outputs: {
159
+ 'dist/browser--dev/index.browser-BRS2BRS2.js.map': {
160
+ 'imports': [],
161
+ 'exports': [],
162
+ 'inputs': {},
163
+ 'bytes': 323
164
+ },
165
+ 'dist/browser--dev/index.browser-BRS2BRS2.js': {
166
+ 'imports': [],
167
+ 'exports': [],
168
+ 'entryPoint': 'src/app/index.browser.ts',
169
+ 'inputs': {
170
+ '../input/path0': {
171
+ 'bytesInOutput': 98
172
+ },
173
+ '../input/path1': {
174
+ 'bytesInOutput': 50
175
+ },
176
+ '../input/path2': {
177
+ 'bytesInOutput': 80
178
+ }
179
+ },
180
+ 'bytes': 228
181
+ }
182
+ },
183
+ "rebuildjs_target": "browser",
184
+ "build_id": "1703809154281-B6Mt0emJRWqIylzx4ZlOBQ",
185
+ }) as rebuildjs_metafile_T
186
+ export const server__metafile2 = Object.freeze({
187
+ inputs: {
188
+ '../input/path0': {
189
+ 'bytes': 224,
190
+ 'imports': [],
191
+ 'format': 'esm'
192
+ },
193
+ '../input/path1': {
194
+ 'bytes': 62,
195
+ 'imports': [],
196
+ 'format': 'esm'
197
+ },
198
+ '../input/path2': {
199
+ 'bytes': 100,
200
+ 'imports': [],
201
+ 'format': 'esm'
202
+ }
203
+ },
204
+ outputs: {
205
+ 'dist/server--dev/index.server-SVR2SVR2.js.map': {
206
+ 'imports': [],
207
+ 'exports': [],
208
+ 'inputs': {},
209
+ 'bytes': 323
210
+ },
211
+ 'dist/server--dev/index.server-SVR2SVR2.js': {
212
+ 'imports': [],
213
+ 'exports': [],
214
+ 'entryPoint': 'src/app/index.server.ts',
215
+ 'inputs': {
216
+ '../input/path0': {
217
+ 'bytesInOutput': 98
218
+ },
219
+ '../input/path1': {
220
+ 'bytesInOutput': 50
221
+ },
222
+ '../input/path2': {
223
+ 'bytesInOutput': 80
224
+ }
225
+ },
226
+ 'bytes': 228
227
+ }
228
+ },
229
+ "rebuildjs_target": "server",
230
+ "build_id": "1703809154281-B6Mt0emJRWqIylzx4ZlOBQ",
231
+ }) as rebuildjs_metafile_T
@@ -0,0 +1,3 @@
1
+ div.pass {
2
+ font-weight: bold;
3
+ }
@@ -0,0 +1,4 @@
1
+ import './index.browser.css'
2
+ window.addEventListener('load', ()=>{
3
+ document.querySelector('div')!.classList.add('pass')
4
+ })
@@ -0,0 +1,3 @@
1
+ div.pass {
2
+ color: green;
3
+ }
@@ -0,0 +1,29 @@
1
+ import './index.server.css'
2
+ import { assets_ } from '../../../asset/index.js'
3
+ import { type middleware_ctx_T, route_ctx_ } from '../../../ctx/index.js'
4
+ export default (middleware_ctx:middleware_ctx_T)=>{
5
+ return (request:Request)=>{
6
+ const route_ctx = route_ctx_(middleware_ctx)
7
+ return new Response(
8
+ '<html>' +
9
+ '<head>' +
10
+ assets_(route_ctx).css_a.map(css=>
11
+ '<link rel="stylesheet" type="text/css" href="' + css + '"></link>'
12
+ ).join('') +
13
+ assets_(route_ctx).script_a.map(script=>
14
+ '<script type="module" src="' + script + '"></script>'
15
+ ).join('') +
16
+ '</head>' +
17
+ '<body>' +
18
+ '<div>' +
19
+ request.url +
20
+ '</div>' +
21
+ '</body>' +
22
+ '</html>',
23
+ {
24
+ headers: {
25
+ 'Content-Type': 'text/html;charset=UTF-8'
26
+ }
27
+ })
28
+ }
29
+ }
@@ -0,0 +1,9 @@
1
+ import { is_entry_file_ } from 'ctx-core/fs'
2
+ import { browser__build, server__build } from '../../build/index.js'
3
+ is_entry_file_(import.meta.url, process.argv[1])
4
+ .then(async is_entry_file=>{
5
+ if (is_entry_file) {
6
+ await server__build()
7
+ await browser__build()
8
+ }
9
+ })
package/build/index.d.ts CHANGED
@@ -5,6 +5,12 @@ export declare const build_id$_:ctx__be_T<has_app_T, sig_T<string|undefined>, 'a
5
5
  export declare const build_id_:ctx__get_T<has_app_T, string|undefined>
6
6
  export declare const build_id__set:ctx__set_T<has_app_T, string|undefined>
7
7
  export declare function build_id__refresh():string
8
+ export declare const rebuildjs__build_id$_:ctx__be_T<has_app_T, sig_T<string>, 'app'>
9
+ export declare const rebuildjs__build_id_:ctx__get_T<has_app_T, string>
10
+ export declare const rebuildjs__build_id__set:ctx__set_T<has_app_T, string>
11
+ export declare const rebuildjs__ready$_:ctx__be_T<has_app_T, sig_T<boolean>, 'app'>
12
+ export declare const rebuildjs__ready_:ctx__get_T<has_app_T, boolean>
13
+ export declare function rebuildjs__ready__wait(timeout?:number):Promise<void>
8
14
  export declare function browser__build(config?:rebuildjs_build_config_T):Promise<BuildContext>
9
15
  export declare function server__build(config?:rebuildjs_build_config_T):Promise<BuildContext>
10
16
  export declare function server__external_(config?:Partial<BuildOptions>):Promise<string[]>
package/build/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  /// <reference types="./index.d.ts" />
3
3
  import { file_exists__waitfor } from 'ctx-core/fs'
4
4
  import { nullish__none_, run } from 'ctx-core/function'
5
- import { be, be_sig_triple_, memo_ } from 'ctx-core/rmemo'
5
+ import { be, be_memo_pair_, be_sig_triple_, memo_, off, rmemo__wait } from 'ctx-core/rmemo'
6
6
  import { short_uuid_ } from 'ctx-core/uuid'
7
7
  import { context } from 'esbuild'
8
8
  import { fdir } from 'fdir'
@@ -35,6 +35,31 @@ export function build_id__refresh() {
35
35
  build_id__set(app_ctx, build_id)
36
36
  return build_id
37
37
  }
38
+ export const [
39
+ rebuildjs__build_id$_,
40
+ rebuildjs__build_id_,
41
+ rebuildjs__build_id__set,
42
+ ] = be_sig_triple_(()=>undefined,
43
+ { id: 'rebuildjs_plugin__build_id', ns: 'app' })
44
+ export const [
45
+ rebuildjs__ready$_,
46
+ rebuildjs__ready_,
47
+ ] = be_memo_pair_(ctx=>
48
+ !!(
49
+ build_id_(ctx)
50
+ && build_id_(ctx) === metafile__build_id_(ctx)
51
+ && build_id_(ctx) === rebuildjs__build_id_(ctx)),
52
+ { id: 'rebuildjs__ready', ns: 'app' })
53
+ /**
54
+ * @param {number}[timeout]
55
+ * @returns {Promise<void>}}
56
+ */
57
+ export function rebuildjs__ready__wait(timeout) {
58
+ return rmemo__wait(
59
+ rebuildjs__ready$_(app_ctx),
60
+ ready=>ready,
61
+ timeout ?? 5000)
62
+ }
38
63
  /**
39
64
  * @param {import('esbuild').Plugin}config
40
65
  * @returns {Promise<void>}
@@ -228,11 +253,20 @@ export function rebuildjs_plugin_() {
228
253
  if (err instanceof RebuildjsInterrupt) return
229
254
  throw err
230
255
  }
256
+ rebuildjs__build_id__set(ctx, build_id)
231
257
  })
232
258
  }
233
259
  async function cmd(fn) {
234
260
  if (cancel_()) throw new RebuildjsInterrupt()
235
- const ret = await fn()
261
+ const promise = fn()
262
+ promise.rebuildjs_cancel$ = run(memo_(rebuildjs_cancel$=>{
263
+ if (cancel_()) {
264
+ promise.cancel?.()
265
+ off(rebuildjs_cancel$)
266
+ }
267
+ return rebuildjs_cancel$
268
+ }))
269
+ const ret = await promise
236
270
  if (cancel_()) throw new RebuildjsInterrupt()
237
271
  return ret
238
272
  }
@@ -6,12 +6,25 @@ import { rm } from 'node:fs/promises'
6
6
  import { dirname, join } from 'path'
7
7
  import { test } from 'uvu'
8
8
  import { equal, throws } from 'uvu/assert'
9
+ import { browser__metafile0, server__metafile0 } from '../_fixtures/metafiles.js'
9
10
  import { cwd__set } from '../app/index.js'
10
- import { browser__metafile_ } from '../browser/index.js'
11
+ import { browser__metafile_, browser__metafile__set } from '../browser/index.js'
11
12
  import { app_ctx } from '../ctx/index.js'
12
- import { metafile__wait } from '../metafile/index.js'
13
- import { server__metafile_ } from '../server/index.js'
14
- import { browser__build, build_id$_, build_id_, build_id__refresh, build_id__set, server__build } from './index.js'
13
+ import { server__metafile_, server__metafile__set } from '../server/index.js'
14
+ import {
15
+ browser__build,
16
+ build_id$_,
17
+ build_id_,
18
+ build_id__refresh,
19
+ build_id__set,
20
+ rebuildjs__build_id$_,
21
+ rebuildjs__build_id_,
22
+ rebuildjs__build_id__set,
23
+ rebuildjs__ready$_,
24
+ rebuildjs__ready_,
25
+ rebuildjs__ready__wait,
26
+ server__build
27
+ } from './index.js'
15
28
  test.after.each(()=>{
16
29
  app_ctx.s.app.clear()
17
30
  })
@@ -37,6 +50,68 @@ test('build_id__refresh', ()=>{
37
50
  parseInt(build_id.split('-')[0]) > Date.now() - 1000,
38
51
  true)
39
52
  })
53
+ test('rebuildjs__build_id', ()=>{
54
+ equal(rebuildjs__build_id$_(app_ctx)(), undefined)
55
+ equal(rebuildjs__build_id_(app_ctx), undefined)
56
+ build_id__refresh()
57
+ equal(typeof build_id_(app_ctx), 'string')
58
+ rebuildjs__build_id__set(app_ctx, build_id_(app_ctx)!)
59
+ equal(rebuildjs__build_id$_(app_ctx)(), build_id_(app_ctx)!)
60
+ equal(rebuildjs__build_id_(app_ctx), build_id_(app_ctx)!)
61
+ // @ts-expect-error TS2345
62
+ throws(()=>rebuildjs__build_id$_(ctx_()))
63
+ // @ts-expect-error TS2345
64
+ throws(()=>rebuildjs__build_id_(ctx_()))
65
+ })
66
+ test('rebuildjs__ready', ()=>{
67
+ equal(rebuildjs__ready$_(app_ctx)(), false)
68
+ equal(rebuildjs__ready_(app_ctx), false)
69
+ const build_id = server__metafile0.build_id!
70
+ build_id__set(app_ctx, build_id)
71
+ equal(rebuildjs__ready$_(app_ctx)(), false)
72
+ equal(rebuildjs__ready_(app_ctx), false)
73
+ server__metafile__set(app_ctx, server__metafile0)
74
+ equal(rebuildjs__ready$_(app_ctx)(), false)
75
+ equal(rebuildjs__ready_(app_ctx), false)
76
+ browser__metafile__set(app_ctx, browser__metafile0)
77
+ equal(rebuildjs__ready$_(app_ctx)(), false)
78
+ equal(rebuildjs__ready_(app_ctx), false)
79
+ rebuildjs__build_id__set(app_ctx, build_id)
80
+ equal(rebuildjs__ready$_(app_ctx)(), true)
81
+ equal(rebuildjs__ready_(app_ctx), true)
82
+ // @ts-expect-error TS2345
83
+ throws(()=>rebuildjs__ready$_(ctx_()))
84
+ // @ts-expect-error TS2345
85
+ throws(()=>rebuildjs__ready_(ctx_()))
86
+ })
87
+ test('rebuildjs__ready__wait', async ()=>{
88
+ let done = false
89
+ rebuildjs__ready__wait()
90
+ .then(()=>done = true)
91
+ equal(done, false)
92
+ const build_id = server__metafile0.build_id!
93
+ build_id__set(app_ctx, build_id)
94
+ await sleep(0)
95
+ equal(done, false)
96
+ server__metafile__set(app_ctx, server__metafile0)
97
+ await sleep(0)
98
+ equal(done, false)
99
+ browser__metafile__set(app_ctx, browser__metafile0)
100
+ await sleep(0)
101
+ equal(done, false)
102
+ rebuildjs__build_id__set(app_ctx, build_id)
103
+ await sleep(0)
104
+ equal(done, true)
105
+ })
106
+ test('rebuildjs__ready__wait|timeout', async ()=>{
107
+ let err:Error|undefined = undefined
108
+ try {
109
+ await rebuildjs__ready__wait(0)
110
+ } catch (_err) {
111
+ err = _err as Error
112
+ }
113
+ equal(err!.message, 'Timeout 0ms')
114
+ })
40
115
  test('browser__build|server__build|rebuildjs_plugin_|metafile', async ()=>{
41
116
  const test_dir = dirname(new URL(import.meta.url).pathname)
42
117
  const cwd = join(test_dir, '../_fixtures')
@@ -47,7 +122,7 @@ test('browser__build|server__build|rebuildjs_plugin_|metafile', async ()=>{
47
122
  try {
48
123
  server__build_context = await server__build()
49
124
  browser__build_context = await browser__build()
50
- await metafile__wait()
125
+ await rebuildjs__ready__wait()
51
126
  equal(await file_exists_(join(cwd, 'dist')), true)
52
127
  equal(await file_exists_(join(cwd, 'dist', 'browser--dev')), true)
53
128
  equal(await file_exists_(join(cwd, 'dist', 'server--dev')), true)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rebuildjs",
3
- "version": "0.24.3",
3
+ "version": "0.26.0",
4
4
  "description": "Reactive esbuild...simple hackable alternative to vite for Multi Page Apps",
5
5
  "keywords": [
6
6
  "reactive",
@@ -26,6 +26,7 @@
26
26
  "*.d.ts",
27
27
  "*.js",
28
28
  "*.json",
29
+ "_fixtures",
29
30
  "app",
30
31
  "asset",
31
32
  "browser",
@@ -52,7 +53,7 @@
52
53
  "./package.json": "./package.json"
53
54
  },
54
55
  "dependencies": {
55
- "ctx-core": "^5.6.1",
56
+ "ctx-core": "^5.8.0",
56
57
  "elysia": "^0.8.6",
57
58
  "esbuild": "^0.19.11",
58
59
  "fdir": "^6.1.1",
package/tsconfig.json CHANGED
@@ -6,8 +6,7 @@
6
6
  "target": "ESNext",
7
7
  "strict": true
8
8
  },
9
- "exclude": [
10
- "node_modules"
11
- ],
9
+ "include": ["_fixtures/**/*"],
10
+ "exclude": ["node_modules"],
12
11
  "references": []
13
12
  }