Skip to content

Commit 1bb1c77

Browse files
committed
chore(examples): add esbuild to Express example
1 parent 8999417 commit 1bb1c77

File tree

4 files changed

+97
-96
lines changed

4 files changed

+97
-96
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { build } from 'esbuild'
2+
import { FlytrapTransformPlugin } from 'useflytrap/transform'
3+
4+
await build({
5+
entryPoints: ['./src/index.ts'],
6+
outdir: 'dist',
7+
outExtension: {
8+
'.js': '.cjs'
9+
},
10+
format: 'cjs',
11+
bundle: true,
12+
platform: 'node',
13+
target: 'node18',
14+
packages: 'external',
15+
plugins: [FlytrapTransformPlugin.esbuild()]
16+
})

examples/with-express/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
"private": true,
55
"type": "module",
66
"scripts": {
7-
"build": "rollup -c"
7+
"build": "rollup -c",
8+
"build:esbuild": "node esbuild.build.js"
89
},
910
"dependencies": {
1011
"@rollup/plugin-commonjs": "^25.0.0",
1112
"@rollup/plugin-node-resolve": "^15.1.0",
1213
"@rollup/plugin-typescript": "^11.1.1",
14+
"esbuild": "0.18.10",
1315
"express": "^4.18.2",
1416
"typescript": "4.8.4",
1517
"useflytrap": "workspace:*"

examples/with-nextjs-api/src/app/api/user/route.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ export async function GET(request: Request) {
4343
* We will place a flytrap capture function here, so in case it happens (which ends up happening)
4444
* we are able to see the context, replay and quickly fix the bug causing the invariant state.
4545
*/
46-
await capture({ error: new Error('User not found'), message: '/api/user invariant state, user not found.' })
46+
await capture({
47+
error: new Error('User not found'),
48+
message: '/api/user invariant state, user not found.'
49+
})
4750
return NextResponse.json({ success: false }, { status: 500 })
4851
}
4952

0 commit comments

Comments
 (0)