rebuildjs 0.29.1 → 0.29.3

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.
@@ -5,6 +5,7 @@ export default (middleware_ctx:middleware_ctx_T)=>{
5
5
  return (request:Request)=>{
6
6
  const route_ctx = route_ctx_(middleware_ctx)
7
7
  return new Response(
8
+ '<!DOCTYPE html>' +
8
9
  '<html>' +
9
10
  '<head>' +
10
11
  assets_(route_ctx).css_a.map(css=>
package/app/index.test.ts CHANGED
@@ -45,9 +45,12 @@ test.after.each(()=>{
45
45
  app_ctx.s.app.clear()
46
46
  })
47
47
  test('app_ctx', ()=>{
48
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
48
49
  /* eslint-disable @typescript-eslint/no-unused-vars */
50
+ // @ts-ignore TS6196
49
51
  type test_app_ctx = Expect<Equal<typeof app_ctx, Ctx<'app'>>>
50
52
  /* eslint-enable @typescript-eslint/no-unused-vars */
53
+ /* eslint-enable @typescript-eslint/ban-ts-comment */
51
54
  })
52
55
  test('port', ()=>{
53
56
  equal(process.env.PORT, undefined)
package/asset/index.d.ts CHANGED
@@ -12,7 +12,7 @@ export declare const assets_:ctx__get_T<has_route_T, assets_T>
12
12
  export declare const assets__set:ctx__set_T<has_route_T, assets_T>
13
13
  export declare function assets__assign<ctx_T extends has_route_T>(
14
14
  ctx:ctx_T,
15
- ..._assets_a:assets_T[]
15
+ ..._assets_a:Partial<assets_T>[]
16
16
  ):assets_T
17
17
  export declare function assets__new(..._assets_a:(Partial<assets_T>|undefined)[]):assets_T
18
18
  export type assets_T = {
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
@@ -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
- /* eslint-disable @typescript-eslint/no-unused-vars */
29
- type test_ctx = Expect<Equal<typeof route_ctx, Ctx<''|'app'|'middleware'|'route'>>>
30
- /* eslint-enable @typescript-eslint/no-unused-vars */
31
- const assets = assets__new(
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, assets)
35
- equal(assets_(route_ctx), assets)
36
- equal(assets$_(route_ctx)(), assets)
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,57 @@ 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_(), assets))
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/ban-ts-comment */
72
+ /* eslint-disable @typescript-eslint/no-unused-vars */
73
+ // @ts-ignore TS6196
74
+ type test_ctx = Expect<Equal<typeof route_ctx, Ctx<''|'app'|'middleware'|'route'>>>
51
75
  // @ts-expect-error TS2345
52
- throws(()=>assets__set(middleware_ctx_(), assets))
76
+ type test_assets$_ = Expect<Equal<typeof assets$_, number>>
77
+ /* eslint-enable @typescript-eslint/no-unused-vars */
78
+ /* eslint-enable @typescript-eslint/ban-ts-comment */
53
79
  })
54
80
  test('assets__assign', async ()=>{
55
- assets__assign(route_ctx_(middleware_ctx_()), assets__new())
81
+ const route_ctx = route_ctx_(middleware_ctx_())
82
+ server__metafile__set(route_ctx, server__metafile0)
83
+ browser__metafile__set(route_ctx, browser__metafile0)
84
+ server__output__relative_path__set(route_ctx, 'dist/server--dev/index.server-SVR0SVR0.js')
85
+ equal(assets_(route_ctx), {
86
+ css_a: ['/index.server-SVR0SVR0.css', '/index.browser-BRS0BRS0.css'],
87
+ script_a: ['/index.browser-BRS0BRS0.js'],
88
+ })
89
+ assets__assign(route_ctx, assets__new())
90
+ equal(assets_(route_ctx), {
91
+ css_a: ['/index.server-SVR0SVR0.css', '/index.browser-BRS0BRS0.css'],
92
+ script_a: ['/index.browser-BRS0BRS0.js'],
93
+ })
94
+ assets__assign(route_ctx, {
95
+ css_a: ['/test0.css']
96
+ })
97
+ equal(assets_(route_ctx), {
98
+ css_a: ['/index.server-SVR0SVR0.css', '/index.browser-BRS0BRS0.css', '/test0.css'],
99
+ script_a: ['/index.browser-BRS0BRS0.js'],
100
+ })
101
+ assets__assign(route_ctx, {
102
+ script_a: ['/test0.js']
103
+ })
104
+ equal(assets_(route_ctx), {
105
+ css_a: ['/index.server-SVR0SVR0.css', '/index.browser-BRS0BRS0.css', '/test0.css'],
106
+ script_a: ['/index.browser-BRS0BRS0.js', '/test0.js'],
107
+ })
108
+ assets__assign(route_ctx, assets__new({
109
+ css_a: ['/test1.css'],
110
+ script_a: ['/test1.js'],
111
+ }))
112
+ equal(assets_(route_ctx), {
113
+ css_a: ['/index.server-SVR0SVR0.css', '/index.browser-BRS0BRS0.css', '/test0.css', '/test1.css'],
114
+ script_a: ['/index.browser-BRS0BRS0.js', '/test0.js', '/test1.js'],
115
+ })
56
116
  // @ts-expect-error TS2345
57
117
  throws(()=>assets__assign(ctx_()))
58
118
  // @ts-expect-error TS2345
@@ -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 + '.map')).then(buf=>buf + '')
213
- === await readFile(join(cwd_(app_ctx), server__entryPoint__output.esbuild_cssBundle + '.map')).then(buf=>buf + ''),
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 + '.map')).then(buf=>buf + '')
221
- === await readFile(join(cwd_(app_ctx), server__entryPoint__output.esbuild_cssBundle + '.map')).then(buf=>buf + ''),
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,6 +1,6 @@
1
1
  {
2
2
  "name": "rebuildjs",
3
- "version": "0.29.1",
3
+ "version": "0.29.3",
4
4
  "description": "Reactive esbuild...simple hackable alternative to vite for Multi Page Apps",
5
5
  "keywords": [
6
6
  "reactive",
@@ -60,8 +60,11 @@
60
60
  "picomatch": "^3.0.1"
61
61
  },
62
62
  "devDependencies": {
63
+ "@typescript-eslint/eslint-plugin": "^6.17.0",
64
+ "@typescript-eslint/parser": "^6.17.0",
63
65
  "c8": "^8.0.1",
64
66
  "check-dts": "^0.7.2",
67
+ "eslint": "^8.56.0",
65
68
  "esmock": "^2.6.0",
66
69
  "tsx": "^4.7.0",
67
70
  "typescript": "next",