From 9f36dd480c8e15de0158b1f2b2c9d1935a37c0f6 Mon Sep 17 00:00:00 2001 From: arisris Date: Mon, 26 Aug 2024 08:53:05 +0700 Subject: [PATCH 1/3] Move miniflare,wrangler to dev as it peer optional --- packages/dev-server/package.json | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) 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 +} From 83a5233fa5ae80991ea51ba6ba5209755229705a Mon Sep 17 00:00:00 2001 From: arisris Date: Mon, 26 Aug 2024 08:53:33 +0700 Subject: [PATCH 2/3] Initial bun adapter --- packages/dev-server/src/adapter/bun.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 packages/dev-server/src/adapter/bun.ts 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 From 8f65bafc3cef4d537941d598df370d6936bc8f5d Mon Sep 17 00:00:00 2001 From: arisris Date: Mon, 26 Aug 2024 08:53:45 +0700 Subject: [PATCH 3/3] Initial node adapter --- packages/dev-server/src/adapter/node.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 packages/dev-server/src/adapter/node.ts 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