Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"scripts": {
"test": "vitest",
"build": "tsup",
"postbuild": "./patch-ws-d-ts.sh",
"prepack": "pnpm test && pnpm build",
"release": "release publish"
},
Expand Down Expand Up @@ -57,6 +58,6 @@
"tsup": "^8.2.4",
"typescript": "^5.5.4",
"undici": "^6.19.8",
"vitest": "^2.0.5"
"vitest": "^3.1.2"
}
}
}
10 changes: 10 additions & 0 deletions patch-ws-d-ts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
# This is an ugly and terrible hack to allow proper interoperability of the `ws` module,
# which is, sadly, a CommonJS module. The issue is that module publishes its types
# nested under the `default` export, which breaks `esInterop` compatibility.

FILE="./lib/ws.d.ts"

if [ -f "$FILE" ]; then
sed -i '' 's/import \* as ws from '\''ws'\'';/import ws from '\''ws'\'';/g' "$FILE"
fi
354 changes: 186 additions & 168 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/ws.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IncomingMessage } from 'node:http'
import type { Socket } from 'node:net'
import type EventEmitter from 'node:events'
import type { EventEmitter } from 'node:events'
import { randomUUID } from 'node:crypto'
import { WebSocketServer } from 'ws'
import { type ServerType } from '@hono/node-server'
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"compilerOptions": {
"strict": true,
"skipLibCheck": true,
"moduleDetection": "force",
"noUncheckedIndexedAccess": true,
"verbatimModuleSyntax": true,
"module": "nodenext",
"moduleResolution": "nodenext",
"esModuleInterop": true,
"verbatimModuleSyntax": true,
"types": ["node"]
},
"exclude": ["node_modules"]
Expand Down
1 change: 1 addition & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"outDir": "./lib",
"declaration": true,
"emitDeclarationOnly": true,
"sourceMap": true
}
}
2 changes: 1 addition & 1 deletion tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { defineConfig } from 'tsup'
export default defineConfig({
entry: ['./src/http.ts', './src/ws.ts'],
outDir: './lib',
format: ['esm'],
format: 'esm',
dts: true,
tsconfig: fileURLToPath(new URL('./tsconfig.build.json', import.meta.url)),
clean: true,
Expand Down