Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrangler & miniflare dependencies as optional peerDependencies #164

Closed
wants to merge 3 commits into from
Closed
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
19 changes: 16 additions & 3 deletions packages/dev-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}
}
20 changes: 20 additions & 0 deletions packages/dev-server/src/adapter/bun.ts
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions packages/dev-server/src/adapter/node.ts
Original file line number Diff line number Diff line change
@@ -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;