rebuildjs 0.36.3 → 0.37.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.
- package/.eslintrc.json +30 -0
- package/_fixtures/src/app/index.server.ts +2 -2
- package/asset/index.test.ts +8 -8
- package/browser/index.test.ts +7 -7
- package/ctx/index.d.ts +2 -2
- package/ctx/index.js +4 -4
- package/ctx/index.test.ts +19 -14
- package/package.json +1 -1
- package/server/index.js +2 -2
- package/server/index.test.ts +6 -6
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"env": {
|
|
3
|
+
"browser": true,
|
|
4
|
+
"es2021": true,
|
|
5
|
+
"node": true
|
|
6
|
+
},
|
|
7
|
+
"extends": [
|
|
8
|
+
"eslint:recommended",
|
|
9
|
+
"plugin:@typescript-eslint/recommended"
|
|
10
|
+
],
|
|
11
|
+
"parser": "@typescript-eslint/parser",
|
|
12
|
+
"parserOptions": {
|
|
13
|
+
"ecmaVersion": "latest",
|
|
14
|
+
"sourceType": "module"
|
|
15
|
+
},
|
|
16
|
+
"plugins": [
|
|
17
|
+
"@typescript-eslint"
|
|
18
|
+
],
|
|
19
|
+
"rules": {
|
|
20
|
+
"block-spacing": ["error", "always"],
|
|
21
|
+
"comma-spacing": "error",
|
|
22
|
+
"indent": ["error", "tab", { "SwitchCase": 1 }],
|
|
23
|
+
"multiline-ternary": ["error", "always-multiline"],
|
|
24
|
+
"no-mixed-spaces-and-tabs": ["error", "smart-tabs"],
|
|
25
|
+
"no-multi-spaces": "error",
|
|
26
|
+
"no-unused-vars": "off",
|
|
27
|
+
"@typescript-eslint/no-unused-vars": "error",
|
|
28
|
+
"object-curly-spacing": ["error", "always"]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import './index.server.css'
|
|
2
2
|
import { assets_ } from '../../../asset/index.js'
|
|
3
|
-
import { type middleware_ctx_T,
|
|
3
|
+
import { type middleware_ctx_T, route_ctx__new } from '../../../ctx/index.js'
|
|
4
4
|
export default (middleware_ctx:middleware_ctx_T)=>{
|
|
5
5
|
return (request:Request)=>{
|
|
6
|
-
const route_ctx =
|
|
6
|
+
const route_ctx = route_ctx__new(middleware_ctx)
|
|
7
7
|
return new Response(
|
|
8
8
|
'<!DOCTYPE html>' +
|
|
9
9
|
'<html>' +
|
package/asset/index.test.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { test } from 'uvu'
|
|
|
4
4
|
import { equal, throws } from 'uvu/assert'
|
|
5
5
|
import { browser__metafile0, server__metafile0 } from '../_fixtures/metafiles.js'
|
|
6
6
|
import { browser__metafile__set } from '../browser/index.js'
|
|
7
|
-
import { app_ctx,
|
|
7
|
+
import { app_ctx, middleware_ctx__new, route_ctx__new } from '../ctx/index.js'
|
|
8
8
|
import { server__metafile__set, server__output__relative_path__set } from '../server/index.js'
|
|
9
9
|
import { asset_path_, asset_path_a_, assets$_, assets_, assets__assign, assets__new, assets__set } from './index.js'
|
|
10
10
|
test.after.each(()=>{
|
|
@@ -27,7 +27,7 @@ test('asset_path_a_', async ()=>{
|
|
|
27
27
|
])
|
|
28
28
|
})
|
|
29
29
|
test('assets', ()=>{
|
|
30
|
-
const route_ctx =
|
|
30
|
+
const route_ctx = route_ctx__new(middleware_ctx__new())
|
|
31
31
|
equal(assets$_(route_ctx)(), {
|
|
32
32
|
css_a: [],
|
|
33
33
|
script_a: [],
|
|
@@ -56,18 +56,18 @@ test('assets', ()=>{
|
|
|
56
56
|
// @ts-expect-error TS2345
|
|
57
57
|
throws(()=>assets$_(ctx_()))
|
|
58
58
|
// @ts-expect-error TS2345
|
|
59
|
-
throws(()=>assets$_(
|
|
59
|
+
throws(()=>assets$_(middleware_ctx__new()))
|
|
60
60
|
// @ts-expect-error TS2345
|
|
61
61
|
throws(()=>assets_(ctx_()))
|
|
62
62
|
// @ts-expect-error TS2345
|
|
63
|
-
throws(()=>assets_(
|
|
63
|
+
throws(()=>assets_(middleware_ctx__new()))
|
|
64
64
|
// @ts-expect-error TS2345
|
|
65
65
|
throws(()=>assets__set(ctx_(), test_assets))
|
|
66
66
|
// @ts-expect-error TS2345
|
|
67
|
-
throws(()=>assets__set(
|
|
67
|
+
throws(()=>assets__set(middleware_ctx__new(), test_assets))
|
|
68
68
|
})
|
|
69
69
|
test('assets|types', ()=>{
|
|
70
|
-
const route_ctx =
|
|
70
|
+
const route_ctx = route_ctx__new(middleware_ctx__new())
|
|
71
71
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
72
72
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
73
73
|
// @ts-ignore TS6196
|
|
@@ -78,7 +78,7 @@ test('assets|types', ()=>{
|
|
|
78
78
|
/* eslint-enable @typescript-eslint/ban-ts-comment */
|
|
79
79
|
})
|
|
80
80
|
test('assets__assign', async ()=>{
|
|
81
|
-
const route_ctx =
|
|
81
|
+
const route_ctx = route_ctx__new(middleware_ctx__new())
|
|
82
82
|
server__metafile__set(route_ctx, server__metafile0)
|
|
83
83
|
browser__metafile__set(route_ctx, browser__metafile0)
|
|
84
84
|
server__output__relative_path__set(route_ctx, 'dist/server--dev/index.server-SVR0SVR0.js')
|
|
@@ -118,7 +118,7 @@ test('assets__assign', async ()=>{
|
|
|
118
118
|
// @ts-expect-error TS2345
|
|
119
119
|
throws(()=>assets__assign(ns_ctx_(ctx_())))
|
|
120
120
|
// @ts-expect-error TS2345
|
|
121
|
-
throws(()=>assets__assign(
|
|
121
|
+
throws(()=>assets__assign(middleware_ctx__new()))
|
|
122
122
|
// @ts-expect-error TS2345
|
|
123
123
|
throws(()=>assets__assign(app_ctx, assets__new()))
|
|
124
124
|
})
|
package/browser/index.test.ts
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
server__metafile0
|
|
13
13
|
} from '../_fixtures/metafiles.js'
|
|
14
14
|
import { cwd__set, dist_path__set, is_prod__set } from '../app/index.js'
|
|
15
|
-
import { app_ctx,
|
|
15
|
+
import { app_ctx, middleware_ctx__new } from '../ctx/index.js'
|
|
16
16
|
import { server__metafile__set, server__output_, server__output__relative_path__set } from '../server/index.js'
|
|
17
17
|
import {
|
|
18
18
|
browser__css$_,
|
|
@@ -147,7 +147,7 @@ test('browser__metafile', async ()=>{
|
|
|
147
147
|
throws(()=>_browser__metafile__set(ctx_(), browser__metafile0))
|
|
148
148
|
})
|
|
149
149
|
test('browser__output__relative_path', ()=>{
|
|
150
|
-
const middleware_ctx =
|
|
150
|
+
const middleware_ctx = middleware_ctx__new()
|
|
151
151
|
equal(browser__output__relative_path$_(middleware_ctx)._, undefined)
|
|
152
152
|
equal(browser__output__relative_path_(middleware_ctx), undefined)
|
|
153
153
|
server__metafile__set(middleware_ctx, server__metafile0)
|
|
@@ -178,7 +178,7 @@ test('browser__output__relative_path', ()=>{
|
|
|
178
178
|
throws(()=>browser__output__relative_path_(ctx_()))
|
|
179
179
|
})
|
|
180
180
|
test('browser__output', ()=>{
|
|
181
|
-
const middleware_ctx =
|
|
181
|
+
const middleware_ctx = middleware_ctx__new()
|
|
182
182
|
equal(browser__output$_(middleware_ctx)(), undefined)
|
|
183
183
|
equal(browser__output_(middleware_ctx), undefined)
|
|
184
184
|
server__metafile__set(middleware_ctx, server__metafile0)
|
|
@@ -194,7 +194,7 @@ test('browser__output', ()=>{
|
|
|
194
194
|
throws(()=>browser__output_(app_ctx))
|
|
195
195
|
})
|
|
196
196
|
test('browser__cssBundle__relative_path', ()=>{
|
|
197
|
-
const middleware_ctx =
|
|
197
|
+
const middleware_ctx = middleware_ctx__new()
|
|
198
198
|
equal(browser__cssBundle__relative_path$_(middleware_ctx)(), undefined)
|
|
199
199
|
equal(browser__cssBundle__relative_path_(middleware_ctx), undefined)
|
|
200
200
|
server__metafile__set(middleware_ctx, server__metafile0)
|
|
@@ -210,7 +210,7 @@ test('browser__cssBundle__relative_path', ()=>{
|
|
|
210
210
|
throws(()=>browser__cssBundle__relative_path_(app_ctx))
|
|
211
211
|
})
|
|
212
212
|
test('browser__cssBundle', ()=>{
|
|
213
|
-
const middleware_ctx =
|
|
213
|
+
const middleware_ctx = middleware_ctx__new()
|
|
214
214
|
equal(browser__cssBundle$_(middleware_ctx)(), undefined)
|
|
215
215
|
equal(browser__cssBundle_(middleware_ctx), undefined)
|
|
216
216
|
cwd__set(app_ctx, '/cwd')
|
|
@@ -227,7 +227,7 @@ test('browser__cssBundle', ()=>{
|
|
|
227
227
|
throws(()=>browser__cssBundle_(app_ctx))
|
|
228
228
|
})
|
|
229
229
|
test('browser__css', ()=>{
|
|
230
|
-
const middleware_ctx =
|
|
230
|
+
const middleware_ctx = middleware_ctx__new()
|
|
231
231
|
equal(browser__css$_(middleware_ctx)(), undefined)
|
|
232
232
|
equal(browser__css_(middleware_ctx), undefined)
|
|
233
233
|
server__metafile__set(middleware_ctx, server__metafile0)
|
|
@@ -243,7 +243,7 @@ test('browser__css', ()=>{
|
|
|
243
243
|
throws(()=>browser__css_(app_ctx))
|
|
244
244
|
})
|
|
245
245
|
test('browser__script', ()=>{
|
|
246
|
-
const middleware_ctx =
|
|
246
|
+
const middleware_ctx = middleware_ctx__new()
|
|
247
247
|
equal(browser__script$_(middleware_ctx)._, undefined)
|
|
248
248
|
equal(browser__script_(middleware_ctx), undefined)
|
|
249
249
|
server__metafile__set(middleware_ctx, server__metafile0)
|
package/ctx/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Ctx, Ctx_wide_T } from 'ctx-core/be'
|
|
2
2
|
export declare const app_ctx:app_ctx_T
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function
|
|
3
|
+
export declare function middleware_ctx__new():middleware_ctx_T
|
|
4
|
+
export declare function route_ctx__new(middleware_ctx:middleware_ctx_T):route_ctx_T
|
|
5
5
|
export type app_ctx_T = Ctx<'app'>
|
|
6
6
|
export type middleware_ctx_T = Ctx<'middleware'|'app'>
|
|
7
7
|
export type route_ctx_T = Ctx<''|'route'|'middleware'|'app'>
|
package/ctx/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/// <reference types="./index.d.ts" />
|
|
2
2
|
import { ns_ctx_ } from 'ctx-core/be'
|
|
3
|
-
export const app_ctx = globalThis.rebuildjs__app_ctx ??=
|
|
3
|
+
export const app_ctx = globalThis.rebuildjs__app_ctx ??= app_ctx__new()
|
|
4
4
|
/**
|
|
5
5
|
* @returns {app_ctx_T}
|
|
6
6
|
* @private
|
|
7
7
|
*/
|
|
8
|
-
function
|
|
8
|
+
function app_ctx__new() {
|
|
9
9
|
return ns_ctx_('app')
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* @returns {middleware_ctx_T}
|
|
13
13
|
* @private
|
|
14
14
|
*/
|
|
15
|
-
export function
|
|
15
|
+
export function middleware_ctx__new() {
|
|
16
16
|
return ns_ctx_('middleware', app_ctx)
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
@@ -20,6 +20,6 @@ export function middleware_ctx_() {
|
|
|
20
20
|
* @returns {route_ctx_T}
|
|
21
21
|
* @private
|
|
22
22
|
*/
|
|
23
|
-
export function
|
|
23
|
+
export function route_ctx__new(middleware_ctx) {
|
|
24
24
|
return ns_ctx_('', 'route', middleware_ctx)
|
|
25
25
|
}
|
package/ctx/index.test.ts
CHANGED
|
@@ -2,24 +2,22 @@ import { be_, type Ctx } from 'ctx-core/be'
|
|
|
2
2
|
import type { Equal, Expect } from 'ctx-core/test'
|
|
3
3
|
import { test } from 'uvu'
|
|
4
4
|
import { equal } from 'uvu/assert'
|
|
5
|
-
import { app_ctx,
|
|
5
|
+
import { app_ctx, middleware_ctx__new, route_ctx__new } from './index.js'
|
|
6
6
|
test.after.each(()=>{
|
|
7
7
|
app_ctx.s.app.clear()
|
|
8
8
|
})
|
|
9
9
|
test('app_ctx', ()=>{
|
|
10
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
11
|
-
type test_app_ctx = Expect<Equal<typeof app_ctx, Ctx<'app'>>>
|
|
12
|
-
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
13
10
|
const ns_app_ = be_(()=>
|
|
14
11
|
'app',
|
|
15
12
|
{ ns: 'app' })
|
|
16
13
|
equal(ns_app_(app_ctx), 'app')
|
|
17
14
|
})
|
|
18
|
-
test('
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
test('app_ctx|ns', ()=>{
|
|
16
|
+
type test_app_ctx = Expect<Equal<typeof app_ctx, Ctx<'app'>>>
|
|
17
|
+
equal({} as test_app_ctx, {})
|
|
18
|
+
})
|
|
19
|
+
test('middleware_ctx__new', ()=>{
|
|
20
|
+
const middleware_ctx = middleware_ctx__new()
|
|
23
21
|
const ns_middleware_ = be_(()=>
|
|
24
22
|
'middleware',
|
|
25
23
|
{ ns: 'middleware' })
|
|
@@ -29,11 +27,13 @@ test('middleware_ctx_', ()=>{
|
|
|
29
27
|
equal(ns_middleware_(middleware_ctx), 'middleware')
|
|
30
28
|
equal(ns_app_(middleware_ctx), 'app')
|
|
31
29
|
})
|
|
32
|
-
test('
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
test('middleware_ctx|ns', ()=>{
|
|
31
|
+
const middleware_ctx = middleware_ctx__new()
|
|
32
|
+
type test_middleware_ctx = Expect<Equal<typeof middleware_ctx, Ctx<'app'|'middleware'>>>
|
|
33
|
+
equal({} as test_middleware_ctx, {})
|
|
34
|
+
})
|
|
35
|
+
test('route_ctx__new', ()=>{
|
|
36
|
+
const route_ctx = route_ctx__new(middleware_ctx__new())
|
|
37
37
|
const ns_blank_ = be_(()=>
|
|
38
38
|
'',
|
|
39
39
|
{ ns: '' })
|
|
@@ -51,4 +51,9 @@ test('route_ctx_', ()=>{
|
|
|
51
51
|
equal(ns_middleware_(route_ctx), 'middleware')
|
|
52
52
|
equal(ns_app_(route_ctx), 'app')
|
|
53
53
|
})
|
|
54
|
+
test('route_ctx|ns', ()=>{
|
|
55
|
+
const route_ctx = route_ctx__new(middleware_ctx__new())
|
|
56
|
+
type test_route_ctx = Expect<Equal<typeof route_ctx, Ctx<''|'app'|'middleware'|'route'>>>
|
|
57
|
+
equal({} as test_route_ctx, {})
|
|
58
|
+
})
|
|
54
59
|
test.run()
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import { mkdir, readFile, writeFile } from 'node:fs/promises'
|
|
14
14
|
import { join, relative } from 'path'
|
|
15
15
|
import { cwd_, server__relative_path_, server_path_ } from '../app/index.js'
|
|
16
|
-
import { app_ctx,
|
|
16
|
+
import { app_ctx, middleware_ctx__new } from '../ctx/index.js'
|
|
17
17
|
export const [
|
|
18
18
|
server__metafile_path$_,
|
|
19
19
|
server__metafile_path_,
|
|
@@ -97,7 +97,7 @@ export const [
|
|
|
97
97
|
.filter(server__output__relative_path=>
|
|
98
98
|
server__metafile.outputs[server__output__relative_path].entryPoint)
|
|
99
99
|
.map(server__output__relative_path=>{
|
|
100
|
-
const middleware_ctx =
|
|
100
|
+
const middleware_ctx = middleware_ctx__new()
|
|
101
101
|
server__output__relative_path__set(middleware_ctx, server__output__relative_path)
|
|
102
102
|
return [server__output__relative_path, middleware_ctx]
|
|
103
103
|
}))),
|
package/server/index.test.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { test } from 'uvu'
|
|
|
7
7
|
import { equal, throws } from 'uvu/assert'
|
|
8
8
|
import { server__metafile0, server__metafile1, server__metafile2 } from '../_fixtures/metafiles.js'
|
|
9
9
|
import { cwd__set, dist_path_, dist_path__set, is_prod__set, server_path_ } from '../app/index.js'
|
|
10
|
-
import { app_ctx,
|
|
10
|
+
import { app_ctx, middleware_ctx__new } from '../ctx/index.js'
|
|
11
11
|
import {
|
|
12
12
|
server__css$_,
|
|
13
13
|
server__css_,
|
|
@@ -186,7 +186,7 @@ test('server__output__relative_path_M_middleware_ctx', ()=>{
|
|
|
186
186
|
throws(()=>server__output__relative_path_M_middleware_ctx_(ctx_()))
|
|
187
187
|
})
|
|
188
188
|
test('server__output__relative_path', ()=>{
|
|
189
|
-
const middleware_ctx =
|
|
189
|
+
const middleware_ctx = middleware_ctx__new()
|
|
190
190
|
equal(server__output__relative_path$_(middleware_ctx)._, undefined)
|
|
191
191
|
equal(server__output__relative_path_(middleware_ctx), undefined)
|
|
192
192
|
server__output__relative_path__set(middleware_ctx, 'dist/server--dev/index.server-SVR0SVR0.js')
|
|
@@ -200,7 +200,7 @@ test('server__output__relative_path', ()=>{
|
|
|
200
200
|
throws(()=>server__output__relative_path__set(app_ctx, 'dist/server--dev/index.HASH.js'))
|
|
201
201
|
})
|
|
202
202
|
test('server__output', ()=>{
|
|
203
|
-
const middleware_ctx =
|
|
203
|
+
const middleware_ctx = middleware_ctx__new()
|
|
204
204
|
is_prod__set(app_ctx, false)
|
|
205
205
|
equal(server__output$_(middleware_ctx)._, undefined)
|
|
206
206
|
equal(server__output_(middleware_ctx), undefined)
|
|
@@ -228,7 +228,7 @@ test('server__output', ()=>{
|
|
|
228
228
|
throws(()=>server__output_(app_ctx))
|
|
229
229
|
})
|
|
230
230
|
test('server__cssBundle__relative_path', ()=>{
|
|
231
|
-
const middleware_ctx =
|
|
231
|
+
const middleware_ctx = middleware_ctx__new()
|
|
232
232
|
is_prod__set(app_ctx, false)
|
|
233
233
|
equal(server__cssBundle__relative_path$_(middleware_ctx)._, undefined)
|
|
234
234
|
equal(server__cssBundle__relative_path_(middleware_ctx), undefined)
|
|
@@ -261,7 +261,7 @@ test('server__cssBundle__relative_path', ()=>{
|
|
|
261
261
|
throws(()=>server__cssBundle__relative_path_(app_ctx))
|
|
262
262
|
})
|
|
263
263
|
test('server__cssBundle', ()=>{
|
|
264
|
-
const middleware_ctx =
|
|
264
|
+
const middleware_ctx = middleware_ctx__new()
|
|
265
265
|
is_prod__set(app_ctx, false)
|
|
266
266
|
cwd__set(app_ctx, '/cwd')
|
|
267
267
|
equal(dist_path_(app_ctx), '/cwd/dist')
|
|
@@ -297,7 +297,7 @@ test('server__cssBundle', ()=>{
|
|
|
297
297
|
throws(()=>server__cssBundle_(app_ctx))
|
|
298
298
|
})
|
|
299
299
|
test('server__css', ()=>{
|
|
300
|
-
const middleware_ctx =
|
|
300
|
+
const middleware_ctx = middleware_ctx__new()
|
|
301
301
|
is_prod__set(app_ctx, false)
|
|
302
302
|
cwd__set(app_ctx, '/cwd')
|
|
303
303
|
equal(dist_path_(app_ctx), '/cwd/dist')
|