rebuildjs 0.29.1 → 0.29.2
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/_fixtures/src/app/index.server.ts +1 -0
- package/asset/index.js +5 -4
- package/asset/index.test.ts +73 -14
- package/build/index.test.ts +4 -4
- package/package.json +87 -83
package/asset/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="./index.d.ts" />
|
|
2
|
+
import { compact } from 'ctx-core/array'
|
|
2
3
|
import { be_lock_memosig_triple_ } from 'ctx-core/rmemo'
|
|
3
|
-
import { browser__script_ } from '../browser/index.js'
|
|
4
|
+
import { browser__css_, browser__script_ } from '../browser/index.js'
|
|
4
5
|
import { server__css_ } from '../server/index.js'
|
|
5
6
|
export async function asset_path_(mod_promise) {
|
|
6
7
|
return (await mod_promise.then(mod=>mod.default)).replace(/^\.\//, '/')
|
|
@@ -14,12 +15,12 @@ export const [
|
|
|
14
15
|
assets__set,
|
|
15
16
|
] = be_lock_memosig_triple_(ctx=>
|
|
16
17
|
assets__new({
|
|
17
|
-
css_a: [server__css_(ctx)],
|
|
18
|
-
script_a: [browser__script_(ctx)]
|
|
18
|
+
css_a: compact([server__css_(ctx), browser__css_(ctx)]),
|
|
19
|
+
script_a: compact([browser__script_(ctx)]),
|
|
19
20
|
}),
|
|
20
21
|
{ ns: 'route', id: 'assets' })
|
|
21
22
|
export function assets__assign(route_ctx, ..._assets_a) {
|
|
22
|
-
assets__set(route_ctx, assets__new(assets_(route_ctx, ..._assets_a))
|
|
23
|
+
assets__set(route_ctx, assets__new(assets_(route_ctx), ..._assets_a))
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* @param {assets_T[]}_assets_a
|
package/asset/index.test.ts
CHANGED
|
@@ -2,7 +2,10 @@ import { type Ctx, ctx_, ns_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, throws } from 'uvu/assert'
|
|
5
|
+
import { browser__metafile0, server__metafile0 } from '../_fixtures/metafiles.js'
|
|
6
|
+
import { browser__metafile__set } from '../browser/index.js'
|
|
5
7
|
import { app_ctx, middleware_ctx_, route_ctx_ } from '../ctx/index.js'
|
|
8
|
+
import { server__metafile__set, server__output__relative_path__set } from '../server/index.js'
|
|
6
9
|
import { asset_path_, asset_path_a_, assets$_, assets_, assets__assign, assets__new, assets__set } from './index.js'
|
|
7
10
|
test.after.each(()=>{
|
|
8
11
|
app_ctx.s.app.clear()
|
|
@@ -25,19 +28,31 @@ test('asset_path_a_', async ()=>{
|
|
|
25
28
|
})
|
|
26
29
|
test('assets', ()=>{
|
|
27
30
|
const route_ctx = route_ctx_(middleware_ctx_())
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
equal(assets$_(route_ctx)(), {
|
|
32
|
+
css_a: [],
|
|
33
|
+
script_a: [],
|
|
34
|
+
})
|
|
35
|
+
server__metafile__set(route_ctx, server__metafile0)
|
|
36
|
+
equal(assets$_(route_ctx)(), {
|
|
37
|
+
css_a: [],
|
|
38
|
+
script_a: [],
|
|
39
|
+
})
|
|
40
|
+
server__output__relative_path__set(route_ctx, 'dist/server--dev/index.server-SVR0SVR0.js')
|
|
41
|
+
equal(assets_(route_ctx), {
|
|
42
|
+
css_a: ['/index.server-SVR0SVR0.css'],
|
|
43
|
+
script_a: [],
|
|
44
|
+
})
|
|
45
|
+
browser__metafile__set(route_ctx, browser__metafile0)
|
|
46
|
+
equal(assets_(route_ctx), {
|
|
47
|
+
css_a: ['/index.server-SVR0SVR0.css', '/index.browser-BRS0BRS0.css'],
|
|
48
|
+
script_a: ['/index.browser-BRS0BRS0.js'],
|
|
49
|
+
})
|
|
50
|
+
const test_assets = assets__new(
|
|
32
51
|
{ css_a: ['/foo.css'], script_a: ['/foo.js'] },
|
|
33
52
|
undefined)
|
|
34
|
-
assets__set(route_ctx,
|
|
35
|
-
equal(
|
|
36
|
-
equal(
|
|
37
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
38
|
-
// @ts-expect-error TS2345
|
|
39
|
-
type test_assets$_ = Expect<Equal<typeof assets$_, number>>
|
|
40
|
-
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
53
|
+
assets__set(route_ctx, test_assets)
|
|
54
|
+
equal(assets$_(route_ctx)(), test_assets)
|
|
55
|
+
equal(assets_(route_ctx), test_assets)
|
|
41
56
|
// @ts-expect-error TS2345
|
|
42
57
|
throws(()=>assets$_(ctx_()))
|
|
43
58
|
// @ts-expect-error TS2345
|
|
@@ -47,12 +62,56 @@ test('assets', ()=>{
|
|
|
47
62
|
// @ts-expect-error TS2345
|
|
48
63
|
throws(()=>assets_(middleware_ctx_()))
|
|
49
64
|
// @ts-expect-error TS2345
|
|
50
|
-
throws(()=>assets__set(ctx_(),
|
|
65
|
+
throws(()=>assets__set(ctx_(), test_assets))
|
|
66
|
+
// @ts-expect-error TS2345
|
|
67
|
+
throws(()=>assets__set(middleware_ctx_(), test_assets))
|
|
68
|
+
})
|
|
69
|
+
test('assets|types', ()=>{
|
|
70
|
+
const route_ctx = route_ctx_(middleware_ctx_())
|
|
71
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
72
|
+
type test_ctx = Expect<Equal<typeof route_ctx, Ctx<''|'app'|'middleware'|'route'>>>
|
|
73
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
74
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
51
75
|
// @ts-expect-error TS2345
|
|
52
|
-
|
|
76
|
+
type test_assets$_ = Expect<Equal<typeof assets$_, number>>
|
|
77
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
53
78
|
})
|
|
54
79
|
test('assets__assign', async ()=>{
|
|
55
|
-
|
|
80
|
+
const route_ctx = route_ctx_(middleware_ctx_())
|
|
81
|
+
server__metafile__set(route_ctx, server__metafile0)
|
|
82
|
+
browser__metafile__set(route_ctx, browser__metafile0)
|
|
83
|
+
server__output__relative_path__set(route_ctx, 'dist/server--dev/index.server-SVR0SVR0.js')
|
|
84
|
+
equal(assets_(route_ctx), {
|
|
85
|
+
css_a: ['/index.server-SVR0SVR0.css', '/index.browser-BRS0BRS0.css'],
|
|
86
|
+
script_a: ['/index.browser-BRS0BRS0.js'],
|
|
87
|
+
})
|
|
88
|
+
assets__assign(route_ctx, assets__new())
|
|
89
|
+
equal(assets_(route_ctx), {
|
|
90
|
+
css_a: ['/index.server-SVR0SVR0.css', '/index.browser-BRS0BRS0.css'],
|
|
91
|
+
script_a: ['/index.browser-BRS0BRS0.js'],
|
|
92
|
+
})
|
|
93
|
+
assets__assign(route_ctx, assets__new({
|
|
94
|
+
css_a: ['/test0.css']
|
|
95
|
+
}))
|
|
96
|
+
equal(assets_(route_ctx), {
|
|
97
|
+
css_a: ['/index.server-SVR0SVR0.css', '/index.browser-BRS0BRS0.css', '/test0.css'],
|
|
98
|
+
script_a: ['/index.browser-BRS0BRS0.js'],
|
|
99
|
+
})
|
|
100
|
+
assets__assign(route_ctx, assets__new({
|
|
101
|
+
script_a: ['/test0.js']
|
|
102
|
+
}))
|
|
103
|
+
equal(assets_(route_ctx), {
|
|
104
|
+
css_a: ['/index.server-SVR0SVR0.css', '/index.browser-BRS0BRS0.css', '/test0.css'],
|
|
105
|
+
script_a: ['/index.browser-BRS0BRS0.js', '/test0.js'],
|
|
106
|
+
})
|
|
107
|
+
assets__assign(route_ctx, assets__new({
|
|
108
|
+
css_a: ['/test1.css'],
|
|
109
|
+
script_a: ['/test1.js'],
|
|
110
|
+
}))
|
|
111
|
+
equal(assets_(route_ctx), {
|
|
112
|
+
css_a: ['/index.server-SVR0SVR0.css', '/index.browser-BRS0BRS0.css', '/test0.css', '/test1.css'],
|
|
113
|
+
script_a: ['/index.browser-BRS0BRS0.js', '/test0.js', '/test1.js'],
|
|
114
|
+
})
|
|
56
115
|
// @ts-expect-error TS2345
|
|
57
116
|
throws(()=>assets__assign(ctx_()))
|
|
58
117
|
// @ts-expect-error TS2345
|
package/build/index.test.ts
CHANGED
|
@@ -209,16 +209,16 @@ test('browser__build|server__build|rebuildjs_plugin_|css', async ()=>{
|
|
|
209
209
|
equal(server__entryPoint__output.cssBundle !== server__entryPoint__output.esbuild_cssBundle, true)
|
|
210
210
|
equal(browser__entryPoint__output.cssBundle !== browser__entryPoint__output.esbuild_cssBundle, true)
|
|
211
211
|
equal(
|
|
212
|
-
await readFile(join(cwd_(app_ctx), server__entryPoint__output.cssBundle
|
|
213
|
-
=== await readFile(join(cwd_(app_ctx), server__entryPoint__output.esbuild_cssBundle
|
|
212
|
+
await readFile(join(cwd_(app_ctx), server__entryPoint__output.cssBundle!)).then(buf=>buf + '')
|
|
213
|
+
=== await readFile(join(cwd_(app_ctx), server__entryPoint__output.esbuild_cssBundle!)).then(buf=>buf + ''),
|
|
214
214
|
true)
|
|
215
215
|
equal(
|
|
216
216
|
await readFile(join(cwd_(app_ctx), browser__entryPoint__output.cssBundle + '.map')).then(buf=>buf + '')
|
|
217
217
|
=== await readFile(join(cwd_(app_ctx), browser__entryPoint__output.esbuild_cssBundle + '.map')).then(buf=>buf + ''),
|
|
218
218
|
true)
|
|
219
219
|
equal(
|
|
220
|
-
await readFile(join(cwd_(app_ctx), server__entryPoint__output.cssBundle
|
|
221
|
-
=== await readFile(join(cwd_(app_ctx), server__entryPoint__output.esbuild_cssBundle
|
|
220
|
+
await readFile(join(cwd_(app_ctx), server__entryPoint__output.cssBundle!)).then(buf=>buf + '')
|
|
221
|
+
=== await readFile(join(cwd_(app_ctx), server__entryPoint__output.esbuild_cssBundle!)).then(buf=>buf + ''),
|
|
222
222
|
true)
|
|
223
223
|
equal(
|
|
224
224
|
await readFile(join(cwd_(app_ctx), browser__entryPoint__output.cssBundle + '.map')).then(buf=>buf + '')
|
package/package.json
CHANGED
|
@@ -1,84 +1,88 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
2
|
+
"name": "rebuildjs",
|
|
3
|
+
"version": "0.29.2",
|
|
4
|
+
"description": "Reactive esbuild...simple hackable alternative to vite for Multi Page Apps",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"reactive",
|
|
7
|
+
"multi page apps",
|
|
8
|
+
"web app",
|
|
9
|
+
"web server",
|
|
10
|
+
"esbuild",
|
|
11
|
+
"rmemo",
|
|
12
|
+
"ctx-core"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/rebuildjs/rebuildjs#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/rebuildjs/rebuildjs/issues"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/rebuildjs/rebuildjs.git"
|
|
21
|
+
},
|
|
22
|
+
"license": "Apache-2.0",
|
|
23
|
+
"author": "Brian Takita",
|
|
24
|
+
"type": "module",
|
|
25
|
+
"files": [
|
|
26
|
+
"*.d.ts",
|
|
27
|
+
"*.js",
|
|
28
|
+
"*.json",
|
|
29
|
+
"_fixtures",
|
|
30
|
+
"app",
|
|
31
|
+
"asset",
|
|
32
|
+
"browser",
|
|
33
|
+
"build",
|
|
34
|
+
"ctx",
|
|
35
|
+
"metafile",
|
|
36
|
+
"metafile_l0",
|
|
37
|
+
"middleware",
|
|
38
|
+
"server",
|
|
39
|
+
"types"
|
|
40
|
+
],
|
|
41
|
+
"types": "./index.d.ts",
|
|
42
|
+
"exports": {
|
|
43
|
+
".": "./index.js",
|
|
44
|
+
"./app": "./app/index.js",
|
|
45
|
+
"./asset": "./asset/index.js",
|
|
46
|
+
"./browser": "./browser/index.js",
|
|
47
|
+
"./build": "./build/index.js",
|
|
48
|
+
"./ctx": "./ctx/index.js",
|
|
49
|
+
"./metafile": "./metafile/index.js",
|
|
50
|
+
"./middleware": "./middleware/index.js",
|
|
51
|
+
"./server": "./server/index.js",
|
|
52
|
+
"./types": "./types/index.js",
|
|
53
|
+
"./package.json": "./package.json"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": ":",
|
|
57
|
+
"clean": ":",
|
|
58
|
+
"exec": "$@",
|
|
59
|
+
"prepublishOnly": "pnpm clean && pnpm build && pnpm test",
|
|
60
|
+
"test": "pnpm test:unit && pnpm test:types",
|
|
61
|
+
"test:types": "check-dts",
|
|
62
|
+
"test:unit": "NODE_OPTIONS=--loader=esmock tsx node_modules/uvu/bin.js . '\\.test\\.(ts|js)$'",
|
|
63
|
+
"test:unit:coverage": "c8 pnpm test:unit"
|
|
64
|
+
},
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"ctx-core": "^5.10.0",
|
|
67
|
+
"elysia": "^0.8.8",
|
|
68
|
+
"esbuild": "^0.19.11",
|
|
69
|
+
"fdir": "^6.1.1",
|
|
70
|
+
"picomatch": "^3.0.1"
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@typescript-eslint/eslint-plugin": "^6.17.0",
|
|
74
|
+
"@typescript-eslint/parser": "^6.17.0",
|
|
75
|
+
"c8": "^8.0.1",
|
|
76
|
+
"check-dts": "^0.7.2",
|
|
77
|
+
"eslint": "^8.56.0",
|
|
78
|
+
"esmock": "^2.6.0",
|
|
79
|
+
"tsx": "^4.7.0",
|
|
80
|
+
"typescript": "next",
|
|
81
|
+
"uvu": "^0.5.6"
|
|
82
|
+
},
|
|
83
|
+
"publishConfig": {
|
|
84
|
+
"access": "public",
|
|
85
|
+
"cache": "~/.npm"
|
|
86
|
+
},
|
|
87
|
+
"sideEffects": false
|
|
88
|
+
}
|