From 0b17127da83380720b45dcf4305ec832dfdd109e Mon Sep 17 00:00:00 2001 From: arisris Date: Mon, 26 Aug 2024 08:53:45 +0700 Subject: [PATCH 1/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 From c5f6e7541c5fe36f8b41496ec182ea98651a903a Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Wed, 28 Aug 2024 22:18:03 +0900 Subject: [PATCH 2/3] format --- packages/dev-server/src/adapter/node.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/dev-server/src/adapter/node.ts b/packages/dev-server/src/adapter/node.ts index 0cec59d..7c0932b 100644 --- a/packages/dev-server/src/adapter/node.ts +++ b/packages/dev-server/src/adapter/node.ts @@ -1,4 +1,4 @@ -import type { Adapter } from "../types" +import type { Adapter } from '../types' export const nodeAdapter = (): Adapter => { if (typeof globalThis.navigator === 'undefined') { // @ts-expect-error not typed well @@ -12,8 +12,8 @@ export const nodeAdapter = (): Adapter => { }) } return { - env: process.env + env: process.env, } } -export default nodeAdapter; \ No newline at end of file +export default nodeAdapter From 21400f2fb744b967547d4422028251b2517edc19 Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Wed, 28 Aug 2024 22:18:31 +0900 Subject: [PATCH 3/3] add changeset --- .changeset/gorgeous-rings-sneeze.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/gorgeous-rings-sneeze.md diff --git a/.changeset/gorgeous-rings-sneeze.md b/.changeset/gorgeous-rings-sneeze.md new file mode 100644 index 0000000..ae61d75 --- /dev/null +++ b/.changeset/gorgeous-rings-sneeze.md @@ -0,0 +1,5 @@ +--- +'@hono/vite-dev-server': minor +--- + +Add initial nodejs adapter