diff --git a/packages/dev-server/package.json b/packages/dev-server/package.json index 22ce3c7..b1e7124 100644 --- a/packages/dev-server/package.json +++ b/packages/dev-server/package.json @@ -60,6 +60,7 @@ "@playwright/test": "^1.37.1", "glob": "^10.3.10", "hono": "^4.4.11", + "miniflare": "^3.20240701.0", "playwright": "^1.39.0", "publint": "^0.2.5", "rimraf": "^5.0.1", @@ -69,14 +70,26 @@ "wrangler": "^3.63.1" }, "peerDependencies": { - "hono": "*" + "hono": "*", + "miniflare": "*", + "wrangler": "*" + }, + "peerDependenciesMeta": { + "hono": { + "optional": false + }, + "miniflare": { + "optional": true + }, + "wrangler": { + "optional": true + } }, "engines": { "node": ">=18.14.1" }, "dependencies": { "@hono/node-server": "^1.12.0", - "miniflare": "^3.20240701.0", "minimatch": "^9.0.3" } -} \ No newline at end of file +} diff --git a/packages/dev-server/src/adapter/bun.ts b/packages/dev-server/src/adapter/bun.ts new file mode 100644 index 0000000..a0d8b4c --- /dev/null +++ b/packages/dev-server/src/adapter/bun.ts @@ -0,0 +1,20 @@ +import type { Adapter } from "../types"; + +export const bunAdapter = (): Adapter => { + if (typeof globalThis.navigator === 'undefined') { + // @ts-expect-error not typed well + globalThis.navigator = { + userAgent: 'Bun', + } + } else { + Object.defineProperty(globalThis.navigator, 'userAgent', { + value: 'Bun', + writable: false, + }) + } + return { + env: process.env + } +} + +export default bunAdapter \ No newline at end of file diff --git a/packages/dev-server/src/adapter/node.ts b/packages/dev-server/src/adapter/node.ts new file mode 100644 index 0000000..0cec59d --- /dev/null +++ b/packages/dev-server/src/adapter/node.ts @@ -0,0 +1,19 @@ +import type { Adapter } from "../types" +export const nodeAdapter = (): Adapter => { + if (typeof globalThis.navigator === 'undefined') { + // @ts-expect-error not typed well + globalThis.navigator = { + userAgent: 'Node.js', + } + } else { + Object.defineProperty(globalThis.navigator, 'userAgent', { + value: 'Node.js', + writable: false, + }) + } + return { + env: process.env + } +} + +export default nodeAdapter; \ No newline at end of file