effect-start 0.17.2 → 0.19.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/dist/Development.d.ts +7 -2
- package/dist/Development.js +12 -6
- package/dist/PlatformRuntime.d.ts +4 -0
- package/dist/PlatformRuntime.js +9 -0
- package/dist/Route.d.ts +6 -2
- package/dist/Route.js +22 -0
- package/dist/RouteHttp.d.ts +1 -1
- package/dist/RouteHttp.js +12 -19
- package/dist/RouteMount.d.ts +2 -1
- package/dist/Start.d.ts +1 -5
- package/dist/Start.js +1 -8
- package/dist/Unique.d.ts +50 -0
- package/dist/Unique.js +187 -0
- package/dist/bun/BunHttpServer.js +5 -6
- package/dist/bun/BunRoute.d.ts +1 -1
- package/dist/bun/BunRoute.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/node/Effectify.d.ts +209 -0
- package/dist/node/Effectify.js +19 -0
- package/dist/node/FileSystem.d.ts +3 -5
- package/dist/node/FileSystem.js +42 -62
- package/dist/node/PlatformError.d.ts +46 -0
- package/dist/node/PlatformError.js +43 -0
- package/dist/testing/TestLogger.js +1 -1
- package/package.json +10 -5
- package/src/Development.ts +13 -18
- package/src/PlatformRuntime.ts +11 -0
- package/src/Route.ts +31 -2
- package/src/RouteHttp.ts +15 -31
- package/src/RouteMount.ts +1 -1
- package/src/Start.ts +1 -15
- package/src/Unique.ts +232 -0
- package/src/bun/BunHttpServer.ts +6 -9
- package/src/bun/BunRoute.ts +3 -3
- package/src/index.ts +1 -0
- package/src/node/Effectify.ts +262 -0
- package/src/node/FileSystem.ts +59 -97
- package/src/node/PlatformError.ts +102 -0
- package/src/testing/TestLogger.ts +1 -1
- package/dist/Random.d.ts +0 -5
- package/dist/Random.js +0 -49
- package/src/Commander.test.ts +0 -1639
- package/src/ContentNegotiation.test.ts +0 -603
- package/src/Development.test.ts +0 -119
- package/src/Entity.test.ts +0 -592
- package/src/FileRouterPattern.test.ts +0 -147
- package/src/FileRouter_files.test.ts +0 -64
- package/src/FileRouter_path.test.ts +0 -145
- package/src/FileRouter_tree.test.ts +0 -132
- package/src/Http.test.ts +0 -319
- package/src/HttpAppExtra.test.ts +0 -103
- package/src/HttpUtils.test.ts +0 -85
- package/src/PathPattern.test.ts +0 -648
- package/src/Random.ts +0 -59
- package/src/RouteBody.test.ts +0 -232
- package/src/RouteHook.test.ts +0 -40
- package/src/RouteHttp.test.ts +0 -2909
- package/src/RouteMount.test.ts +0 -481
- package/src/RouteSchema.test.ts +0 -427
- package/src/RouteSse.test.ts +0 -249
- package/src/RouteTree.test.ts +0 -494
- package/src/RouteTrie.test.ts +0 -322
- package/src/RouterPattern.test.ts +0 -676
- package/src/Values.test.ts +0 -263
- package/src/bun/BunBundle.test.ts +0 -268
- package/src/bun/BunBundle_imports.test.ts +0 -48
- package/src/bun/BunHttpServer.test.ts +0 -251
- package/src/bun/BunImportTrackerPlugin.test.ts +0 -77
- package/src/bun/BunRoute.test.ts +0 -162
- package/src/bundler/BundleHttp.test.ts +0 -132
- package/src/effect/HttpRouter.test.ts +0 -548
- package/src/experimental/EncryptedCookies.test.ts +0 -488
- package/src/hyper/HyperHtml.test.ts +0 -209
- package/src/hyper/HyperRoute.test.tsx +0 -197
- package/src/middlewares/BasicAuthMiddleware.test.ts +0 -84
- package/src/testing/TestHttpClient.test.ts +0 -83
- package/src/testing/TestLogger.test.ts +0 -51
- package/src/x/datastar/Datastar.test.ts +0 -266
- package/src/x/tailwind/TailwindPlugin.test.ts +0 -333
package/src/Values.test.ts
DELETED
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import * as test from "bun:test"
|
|
2
|
-
import * as Values from "./Values.ts"
|
|
3
|
-
|
|
4
|
-
test.describe("isPlainObject", () => {
|
|
5
|
-
test.it("returns true for plain objects", () => {
|
|
6
|
-
test
|
|
7
|
-
.expect(Values.isPlainObject({}))
|
|
8
|
-
.toBe(true)
|
|
9
|
-
|
|
10
|
-
test
|
|
11
|
-
.expect(Values.isPlainObject({ a: 1, b: 2 }))
|
|
12
|
-
.toBe(true)
|
|
13
|
-
|
|
14
|
-
test
|
|
15
|
-
.expect(Values.isPlainObject({ nested: { value: true } }))
|
|
16
|
-
.toBe(true)
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
test.it("returns false for null", () => {
|
|
20
|
-
test
|
|
21
|
-
.expect(Values.isPlainObject(null))
|
|
22
|
-
.toBe(false)
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
test.it("returns false for primitives", () => {
|
|
26
|
-
test
|
|
27
|
-
.expect(Values.isPlainObject("string"))
|
|
28
|
-
.toBe(false)
|
|
29
|
-
|
|
30
|
-
test
|
|
31
|
-
.expect(Values.isPlainObject(42))
|
|
32
|
-
.toBe(false)
|
|
33
|
-
|
|
34
|
-
test
|
|
35
|
-
.expect(Values.isPlainObject(true))
|
|
36
|
-
.toBe(false)
|
|
37
|
-
|
|
38
|
-
test
|
|
39
|
-
.expect(Values.isPlainObject(undefined))
|
|
40
|
-
.toBe(false)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
test.it("returns false for ArrayBuffer", () => {
|
|
44
|
-
test
|
|
45
|
-
.expect(Values.isPlainObject(new ArrayBuffer(8)))
|
|
46
|
-
.toBe(false)
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
test.it("returns false for ArrayBufferView (Uint8Array)", () => {
|
|
50
|
-
test
|
|
51
|
-
.expect(Values.isPlainObject(new Uint8Array([1, 2, 3])))
|
|
52
|
-
.toBe(false)
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
test.it("returns false for Blob", () => {
|
|
56
|
-
test
|
|
57
|
-
.expect(Values.isPlainObject(new Blob(["test"])))
|
|
58
|
-
.toBe(false)
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
test.it("returns false for FormData", () => {
|
|
62
|
-
test
|
|
63
|
-
.expect(Values.isPlainObject(new FormData()))
|
|
64
|
-
.toBe(false)
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
test.it("returns false for URLSearchParams", () => {
|
|
68
|
-
test
|
|
69
|
-
.expect(Values.isPlainObject(new URLSearchParams()))
|
|
70
|
-
.toBe(false)
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
test.it("returns false for ReadableStream", () => {
|
|
74
|
-
test
|
|
75
|
-
.expect(Values.isPlainObject(new ReadableStream()))
|
|
76
|
-
.toBe(false)
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
test.it("returns false for arrays", () => {
|
|
80
|
-
test
|
|
81
|
-
.expect(Values.isPlainObject([]))
|
|
82
|
-
.toBe(false)
|
|
83
|
-
|
|
84
|
-
test
|
|
85
|
-
.expect(Values.isPlainObject([1, 2, 3]))
|
|
86
|
-
.toBe(false)
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
test.it("returns false for functions", () => {
|
|
90
|
-
test
|
|
91
|
-
.expect(Values.isPlainObject(() => {}))
|
|
92
|
-
.toBe(false)
|
|
93
|
-
|
|
94
|
-
test
|
|
95
|
-
.expect(Values.isPlainObject(function() {}))
|
|
96
|
-
.toBe(false)
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
test.it("returns false for class instances", () => {
|
|
100
|
-
class MyClass {
|
|
101
|
-
value = 42
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
test
|
|
105
|
-
.expect(Values.isPlainObject(new MyClass()))
|
|
106
|
-
.toBe(false)
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
test.it("returns false for Date", () => {
|
|
110
|
-
test
|
|
111
|
-
.expect(Values.isPlainObject(new Date()))
|
|
112
|
-
.toBe(false)
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
test.it("returns false for Map", () => {
|
|
116
|
-
test
|
|
117
|
-
.expect(Values.isPlainObject(new Map()))
|
|
118
|
-
.toBe(false)
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
test.it("returns false for Set", () => {
|
|
122
|
-
test
|
|
123
|
-
.expect(Values.isPlainObject(new Set()))
|
|
124
|
-
.toBe(false)
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
test.it("returns false for RegExp", () => {
|
|
128
|
-
test
|
|
129
|
-
.expect(Values.isPlainObject(/test/))
|
|
130
|
-
.toBe(false)
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
test.it("returns false for Error", () => {
|
|
134
|
-
test
|
|
135
|
-
.expect(Values.isPlainObject(new Error("test")))
|
|
136
|
-
.toBe(false)
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
test.it("returns false for Promise", () => {
|
|
140
|
-
test
|
|
141
|
-
.expect(Values.isPlainObject(Promise.resolve()))
|
|
142
|
-
.toBe(false)
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
test.it("returns true for Object.create(null)", () => {
|
|
146
|
-
test
|
|
147
|
-
.expect(Values.isPlainObject(Object.create(null)))
|
|
148
|
-
.toBe(true)
|
|
149
|
-
})
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
test.describe("IsPlainObject", () => {
|
|
153
|
-
test.it("returns true for plain objects", () => {
|
|
154
|
-
test
|
|
155
|
-
.expectTypeOf<Values.IsPlainObject<{ a: number }>>()
|
|
156
|
-
.toEqualTypeOf<true>()
|
|
157
|
-
|
|
158
|
-
test
|
|
159
|
-
.expectTypeOf<Values.IsPlainObject<{ a: number; b: string }>>()
|
|
160
|
-
.toEqualTypeOf<true>()
|
|
161
|
-
|
|
162
|
-
test
|
|
163
|
-
.expectTypeOf<Values.IsPlainObject<{}>>()
|
|
164
|
-
.toEqualTypeOf<true>()
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
test.it("returns false for functions", () => {
|
|
168
|
-
test
|
|
169
|
-
.expectTypeOf<Values.IsPlainObject<() => void>>()
|
|
170
|
-
.toEqualTypeOf<false>()
|
|
171
|
-
|
|
172
|
-
test
|
|
173
|
-
.expectTypeOf<Values.IsPlainObject<(a: number) => string>>()
|
|
174
|
-
.toEqualTypeOf<false>()
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
test.it("returns false for built-in classes", () => {
|
|
178
|
-
test
|
|
179
|
-
.expectTypeOf<Values.IsPlainObject<Request>>()
|
|
180
|
-
.toEqualTypeOf<false>()
|
|
181
|
-
|
|
182
|
-
test
|
|
183
|
-
.expectTypeOf<Values.IsPlainObject<Response>>()
|
|
184
|
-
.toEqualTypeOf<false>()
|
|
185
|
-
|
|
186
|
-
test
|
|
187
|
-
.expectTypeOf<Values.IsPlainObject<Date>>()
|
|
188
|
-
.toEqualTypeOf<false>()
|
|
189
|
-
|
|
190
|
-
test
|
|
191
|
-
.expectTypeOf<Values.IsPlainObject<Map<string, number>>>()
|
|
192
|
-
.toEqualTypeOf<false>()
|
|
193
|
-
})
|
|
194
|
-
|
|
195
|
-
test.it("returns false for primitives", () => {
|
|
196
|
-
test
|
|
197
|
-
.expectTypeOf<Values.IsPlainObject<string>>()
|
|
198
|
-
.toEqualTypeOf<false>()
|
|
199
|
-
|
|
200
|
-
test
|
|
201
|
-
.expectTypeOf<Values.IsPlainObject<number>>()
|
|
202
|
-
.toEqualTypeOf<false>()
|
|
203
|
-
|
|
204
|
-
test
|
|
205
|
-
.expectTypeOf<Values.IsPlainObject<boolean>>()
|
|
206
|
-
.toEqualTypeOf<false>()
|
|
207
|
-
})
|
|
208
|
-
})
|
|
209
|
-
|
|
210
|
-
test.describe("Simplify", () => {
|
|
211
|
-
test.it("expands nested plain objects", () => {
|
|
212
|
-
type Input = {
|
|
213
|
-
readonly a: { readonly x: number }
|
|
214
|
-
readonly b: string
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
test
|
|
218
|
-
.expectTypeOf<Values.Simplify<Input>>()
|
|
219
|
-
.toEqualTypeOf<{
|
|
220
|
-
a: { x: number }
|
|
221
|
-
b: string
|
|
222
|
-
}>()
|
|
223
|
-
})
|
|
224
|
-
|
|
225
|
-
test.it("preserves Request type", () => {
|
|
226
|
-
type Input = {
|
|
227
|
-
request: Request
|
|
228
|
-
data: { value: number }
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
type Result = Values.Simplify<Input>
|
|
232
|
-
|
|
233
|
-
test
|
|
234
|
-
.expectTypeOf<Result["request"]>()
|
|
235
|
-
.toEqualTypeOf<Request>()
|
|
236
|
-
|
|
237
|
-
test
|
|
238
|
-
.expectTypeOf<Result["data"]>()
|
|
239
|
-
.toEqualTypeOf<{ value: number }>()
|
|
240
|
-
})
|
|
241
|
-
|
|
242
|
-
test.it("preserves other built-in types", () => {
|
|
243
|
-
type Input = {
|
|
244
|
-
date: Date
|
|
245
|
-
map: Map<string, number>
|
|
246
|
-
response: Response
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
type Result = Values.Simplify<Input>
|
|
250
|
-
|
|
251
|
-
test
|
|
252
|
-
.expectTypeOf<Result["date"]>()
|
|
253
|
-
.toEqualTypeOf<Date>()
|
|
254
|
-
|
|
255
|
-
test
|
|
256
|
-
.expectTypeOf<Result["map"]>()
|
|
257
|
-
.toEqualTypeOf<Map<string, number>>()
|
|
258
|
-
|
|
259
|
-
test
|
|
260
|
-
.expectTypeOf<Result["response"]>()
|
|
261
|
-
.toEqualTypeOf<Response>()
|
|
262
|
-
})
|
|
263
|
-
})
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import * as HttpRouter from "@effect/platform/HttpRouter"
|
|
2
|
-
import * as test from "bun:test"
|
|
3
|
-
import * as Effect from "effect/Effect"
|
|
4
|
-
import * as Layer from "effect/Layer"
|
|
5
|
-
import * as NFS from "node:fs/promises"
|
|
6
|
-
import * as NOS from "node:os"
|
|
7
|
-
import * as NPath from "node:path"
|
|
8
|
-
import * as Bundle from "../bundler/Bundle.ts"
|
|
9
|
-
import * as BundleHttp from "../bundler/BundleHttp.ts"
|
|
10
|
-
import * as TestHttpClient from "../testing/TestHttpClient.ts"
|
|
11
|
-
import * as BunBundle from "./BunBundle.ts"
|
|
12
|
-
|
|
13
|
-
test.describe("BunBundle manifest structure", () => {
|
|
14
|
-
test.it("should generate manifest with inputs and outputs arrays", async () => {
|
|
15
|
-
const tmpDir = await NFS.mkdtemp(
|
|
16
|
-
NPath.join(NOS.tmpdir(), "effect-start-test-"),
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
const htmlContent = `<!DOCTYPE html>
|
|
21
|
-
<html>
|
|
22
|
-
<head><title>Test</title></head>
|
|
23
|
-
<body>
|
|
24
|
-
<div id="app"></div>
|
|
25
|
-
<script src="./index.ts" type="module"></script>
|
|
26
|
-
</body>
|
|
27
|
-
</html>`
|
|
28
|
-
|
|
29
|
-
const jsContent = `console.log("Hello from test bundle");
|
|
30
|
-
export const greeting = "Hello World";`
|
|
31
|
-
|
|
32
|
-
const htmlPath = NPath.join(tmpDir, "index.html")
|
|
33
|
-
const jsPath = NPath.join(tmpDir, "index.ts")
|
|
34
|
-
|
|
35
|
-
await NFS.writeFile(htmlPath, htmlContent)
|
|
36
|
-
await NFS.writeFile(jsPath, jsContent)
|
|
37
|
-
|
|
38
|
-
const bundle = await Effect.runPromise(
|
|
39
|
-
BunBundle.buildClient({
|
|
40
|
-
entrypoints: [htmlPath],
|
|
41
|
-
}),
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
test
|
|
45
|
-
.expect(bundle.entrypoints)
|
|
46
|
-
.toBeObject()
|
|
47
|
-
test
|
|
48
|
-
.expect(bundle.artifacts)
|
|
49
|
-
.toBeArray()
|
|
50
|
-
test
|
|
51
|
-
.expect(Object.keys(bundle.entrypoints).length)
|
|
52
|
-
.toBe(1)
|
|
53
|
-
test
|
|
54
|
-
.expect(bundle.artifacts.length)
|
|
55
|
-
.toBe(3)
|
|
56
|
-
|
|
57
|
-
const entrypointKeys = Object.keys(bundle.entrypoints)
|
|
58
|
-
const firstEntrypoint = entrypointKeys[0]
|
|
59
|
-
|
|
60
|
-
test
|
|
61
|
-
.expect(firstEntrypoint)
|
|
62
|
-
.toBeString()
|
|
63
|
-
test
|
|
64
|
-
.expect(bundle.entrypoints[firstEntrypoint])
|
|
65
|
-
.toBeString()
|
|
66
|
-
|
|
67
|
-
const firstArtifact = bundle.artifacts[0]
|
|
68
|
-
|
|
69
|
-
test
|
|
70
|
-
.expect(firstArtifact)
|
|
71
|
-
.toHaveProperty("path")
|
|
72
|
-
test
|
|
73
|
-
.expect(firstArtifact)
|
|
74
|
-
.toHaveProperty("type")
|
|
75
|
-
test
|
|
76
|
-
.expect(firstArtifact)
|
|
77
|
-
.toHaveProperty("size")
|
|
78
|
-
test
|
|
79
|
-
.expect(firstArtifact.size)
|
|
80
|
-
.toBeGreaterThan(0)
|
|
81
|
-
} finally {
|
|
82
|
-
await NFS.rm(tmpDir, {
|
|
83
|
-
recursive: true,
|
|
84
|
-
force: true,
|
|
85
|
-
})
|
|
86
|
-
}
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
test.it("should serve manifest via HTTP with correct structure", async () => {
|
|
90
|
-
const tmpDir = await NFS.mkdtemp(
|
|
91
|
-
NPath.join(NOS.tmpdir(), "effect-start-test-"),
|
|
92
|
-
)
|
|
93
|
-
|
|
94
|
-
try {
|
|
95
|
-
const htmlContent = `<!DOCTYPE html>
|
|
96
|
-
<html>
|
|
97
|
-
<head><title>Test App</title></head>
|
|
98
|
-
<body><h1>Test</h1></body>
|
|
99
|
-
</html>`
|
|
100
|
-
|
|
101
|
-
const htmlPath = NPath.join(tmpDir, "app.html")
|
|
102
|
-
|
|
103
|
-
await NFS.writeFile(htmlPath, htmlContent)
|
|
104
|
-
|
|
105
|
-
const testLayer = Layer.effect(
|
|
106
|
-
Bundle.ClientBundle,
|
|
107
|
-
BunBundle.buildClient({
|
|
108
|
-
entrypoints: [htmlPath],
|
|
109
|
-
}),
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
const result = await Effect.runPromise(
|
|
113
|
-
Effect
|
|
114
|
-
.scoped(
|
|
115
|
-
Effect.gen(function*() {
|
|
116
|
-
const App = HttpRouter.empty.pipe(
|
|
117
|
-
HttpRouter.mountApp(
|
|
118
|
-
"/_bundle",
|
|
119
|
-
BundleHttp.httpApp(),
|
|
120
|
-
),
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
const Client = TestHttpClient.make(App)
|
|
124
|
-
|
|
125
|
-
const response = yield* Client.get("/_bundle/manifest.json")
|
|
126
|
-
|
|
127
|
-
const manifestText = yield* response.text
|
|
128
|
-
|
|
129
|
-
return JSON.parse(manifestText)
|
|
130
|
-
}),
|
|
131
|
-
)
|
|
132
|
-
.pipe(
|
|
133
|
-
Effect.provide(testLayer),
|
|
134
|
-
),
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
test
|
|
138
|
-
.expect(result)
|
|
139
|
-
.toHaveProperty("entrypoints")
|
|
140
|
-
test
|
|
141
|
-
.expect(result)
|
|
142
|
-
.toHaveProperty("artifacts")
|
|
143
|
-
test
|
|
144
|
-
.expect(result.entrypoints)
|
|
145
|
-
.toBeObject()
|
|
146
|
-
test
|
|
147
|
-
.expect(result.artifacts)
|
|
148
|
-
.toBeArray()
|
|
149
|
-
test
|
|
150
|
-
.expect(Object.keys(result.entrypoints).length)
|
|
151
|
-
.toBe(1)
|
|
152
|
-
test
|
|
153
|
-
.expect(result.artifacts.length)
|
|
154
|
-
.toBe(3)
|
|
155
|
-
|
|
156
|
-
const entrypointKeys = Object.keys(result.entrypoints)
|
|
157
|
-
const firstKey = entrypointKeys[0]
|
|
158
|
-
|
|
159
|
-
test
|
|
160
|
-
.expect(firstKey)
|
|
161
|
-
.toBeString()
|
|
162
|
-
test
|
|
163
|
-
.expect(result.entrypoints[firstKey])
|
|
164
|
-
.toBeString()
|
|
165
|
-
|
|
166
|
-
const artifact = result.artifacts[0]
|
|
167
|
-
|
|
168
|
-
test
|
|
169
|
-
.expect(artifact)
|
|
170
|
-
.toHaveProperty("path")
|
|
171
|
-
test
|
|
172
|
-
.expect(artifact)
|
|
173
|
-
.toHaveProperty("type")
|
|
174
|
-
test
|
|
175
|
-
.expect(artifact)
|
|
176
|
-
.toHaveProperty("size")
|
|
177
|
-
} finally {
|
|
178
|
-
await NFS.rm(tmpDir, {
|
|
179
|
-
recursive: true,
|
|
180
|
-
force: true,
|
|
181
|
-
})
|
|
182
|
-
}
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
test.it("should resolve entrypoints to artifacts correctly", async () => {
|
|
186
|
-
const tmpDir = await NFS.mkdtemp(
|
|
187
|
-
NPath.join(NOS.tmpdir(), "effect-start-test-"),
|
|
188
|
-
)
|
|
189
|
-
|
|
190
|
-
try {
|
|
191
|
-
const htmlContent = `<!DOCTYPE html>
|
|
192
|
-
<html><body>Test</body></html>`
|
|
193
|
-
|
|
194
|
-
const htmlPath = NPath.join(tmpDir, "test.html")
|
|
195
|
-
|
|
196
|
-
await NFS.writeFile(htmlPath, htmlContent)
|
|
197
|
-
|
|
198
|
-
const bundle = await Effect.runPromise(
|
|
199
|
-
BunBundle.buildClient({
|
|
200
|
-
entrypoints: [htmlPath],
|
|
201
|
-
}),
|
|
202
|
-
)
|
|
203
|
-
|
|
204
|
-
const entrypointKeys = Object.keys(bundle.entrypoints)
|
|
205
|
-
const firstEntrypoint = entrypointKeys[0]
|
|
206
|
-
const expectedOutput = bundle.entrypoints[firstEntrypoint]
|
|
207
|
-
const resolvedOutput = bundle.resolve(firstEntrypoint)
|
|
208
|
-
|
|
209
|
-
test
|
|
210
|
-
.expect(resolvedOutput)
|
|
211
|
-
.toBe(expectedOutput)
|
|
212
|
-
|
|
213
|
-
const artifact = bundle.getArtifact(resolvedOutput!)
|
|
214
|
-
|
|
215
|
-
test
|
|
216
|
-
.expect(artifact)
|
|
217
|
-
.not
|
|
218
|
-
.toBeNull()
|
|
219
|
-
test
|
|
220
|
-
.expect(artifact)
|
|
221
|
-
.toBeTruthy()
|
|
222
|
-
} finally {
|
|
223
|
-
await NFS.rm(tmpDir, {
|
|
224
|
-
recursive: true,
|
|
225
|
-
force: true,
|
|
226
|
-
})
|
|
227
|
-
}
|
|
228
|
-
})
|
|
229
|
-
|
|
230
|
-
test.it("should include all artifact metadata", async () => {
|
|
231
|
-
const tmpDir = await NFS.mkdtemp(
|
|
232
|
-
NPath.join(NOS.tmpdir(), "effect-start-test-"),
|
|
233
|
-
)
|
|
234
|
-
|
|
235
|
-
try {
|
|
236
|
-
const jsContent = `export const value = 42;`
|
|
237
|
-
const jsPath = NPath.join(tmpDir, "module.ts")
|
|
238
|
-
|
|
239
|
-
await NFS.writeFile(jsPath, jsContent)
|
|
240
|
-
|
|
241
|
-
const bundle = await Effect.runPromise(
|
|
242
|
-
BunBundle.buildClient({
|
|
243
|
-
entrypoints: [jsPath],
|
|
244
|
-
}),
|
|
245
|
-
)
|
|
246
|
-
|
|
247
|
-
const artifact = bundle.artifacts[0]
|
|
248
|
-
|
|
249
|
-
test
|
|
250
|
-
.expect(artifact.path)
|
|
251
|
-
.toBeString()
|
|
252
|
-
test
|
|
253
|
-
.expect(artifact.type)
|
|
254
|
-
.toBeString()
|
|
255
|
-
test
|
|
256
|
-
.expect(artifact.size)
|
|
257
|
-
.toBeNumber()
|
|
258
|
-
test
|
|
259
|
-
.expect(artifact.type)
|
|
260
|
-
.toContain("javascript")
|
|
261
|
-
} finally {
|
|
262
|
-
await NFS.rm(tmpDir, {
|
|
263
|
-
recursive: true,
|
|
264
|
-
force: true,
|
|
265
|
-
})
|
|
266
|
-
}
|
|
267
|
-
})
|
|
268
|
-
})
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import * as test from "bun:test"
|
|
2
|
-
import { effectFn } from "../testing"
|
|
3
|
-
import * as BunBundle from "./BunBundle.ts"
|
|
4
|
-
import * as BunImportTrackerPlugin from "./BunImportTrackerPlugin.ts"
|
|
5
|
-
|
|
6
|
-
const effect = effectFn()
|
|
7
|
-
|
|
8
|
-
test.it("imports", () =>
|
|
9
|
-
effect(function*() {
|
|
10
|
-
const importTracker = BunImportTrackerPlugin.make()
|
|
11
|
-
yield* BunBundle.build({
|
|
12
|
-
target: "bun",
|
|
13
|
-
plugins: [
|
|
14
|
-
importTracker,
|
|
15
|
-
],
|
|
16
|
-
entrypoints: [
|
|
17
|
-
Bun.fileURLToPath(import.meta.resolve("./BunBundle_imports.test.ts")),
|
|
18
|
-
],
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
const [
|
|
22
|
-
e0,
|
|
23
|
-
] = importTracker.state.entries()
|
|
24
|
-
|
|
25
|
-
test
|
|
26
|
-
.expect(e0)
|
|
27
|
-
.toEqual([
|
|
28
|
-
"src/bun/BunBundle_imports.test.ts",
|
|
29
|
-
[
|
|
30
|
-
{
|
|
31
|
-
kind: "import-statement",
|
|
32
|
-
path: "bun:test",
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
kind: "import-statement",
|
|
36
|
-
path: "src/testing",
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
kind: "import-statement",
|
|
40
|
-
path: "src/bun/BunBundle.ts",
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
kind: "import-statement",
|
|
44
|
-
path: "src/bun/BunImportTrackerPlugin.ts",
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
])
|
|
48
|
-
}))
|