Skip to content

Commit 94c63cc

Browse files
committed
🎉 release: 1.2.1
1 parent c325fd6 commit 94c63cc

File tree

5 files changed

+14
-35
lines changed

5 files changed

+14
-35
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.2.2 - 24 Dec 2024
2+
Bug fix:
3+
- conditional import and require
4+
15
# 1.2.1 - 23 Dec 2024
26
Bug fix:
37
- conditional import for fs

build.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,8 @@ await Promise.all([
9090

9191
await $`cp dist/index*.d.ts dist/bun`
9292

93+
const fsMjs = Bun.file('dist/universal/fs.mjs')
94+
const fsMjsContent = await fsMjs.text()
95+
Bun.write(fsMjs, fsMjsContent.replace(`require("fs")`, `await import("fs")`))
96+
9397
process.exit()

example/a.ts

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,4 @@
1-
import { Elysia, t } from '../src'
1+
import { Elysia, file, t } from '../src'
22
import { req } from '../test/utils'
33

4-
export const userService = new Elysia({ name: 'user/service' })
5-
.macro({
6-
isSignIn(enabled: boolean) {
7-
if (!enabled) return
8-
9-
return {
10-
beforeHandle({ error, cookie: { token }, store: { session } }) {
11-
if (!token.value)
12-
return error(401, {
13-
success: false,
14-
message: 'Unauthorized'
15-
})
16-
17-
const username = session[token.value as unknown as number]
18-
19-
if (!username)
20-
return error(401, {
21-
success: false,
22-
message: 'Unauthorized'
23-
})
24-
}
25-
}
26-
}
27-
})
28-
.get('/', () => 'a', {
29-
isSignIn: false
30-
})
31-
32-
userService
33-
.handle(req('/'))
34-
.then((x) => x.text())
35-
.then(console.log)
4+
new Elysia().get('/', () => file('test/kyuukurarin.mp4')).listen(3000)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "elysia",
33
"description": "Ergonomic Framework for Human",
4-
"version": "1.2.1",
4+
"version": "1.2.2",
55
"author": {
66
"name": "saltyAom",
77
"url": "https://github.com/SaltyAom",

src/universal/fs.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import type * as Fs from 'fs'
22
import { env } from './env'
33

44
const fs: typeof Fs =
5-
typeof process !== 'undefined' && env.NODE_ENV ? require('fs') : {}
5+
typeof process !== 'undefined' && env.NODE_ENV
6+
? require('fs')
7+
: {}
68

79
const noop = () => {}
810

0 commit comments

Comments
 (0)