From 9f36dd480c8e15de0158b1f2b2c9d1935a37c0f6 Mon Sep 17 00:00:00 2001 From: arisris Date: Mon, 26 Aug 2024 08:53:05 +0700 Subject: [PATCH 1/7] 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 2d290804c10083238a25808af3e2d2e03735ab9e Mon Sep 17 00:00:00 2001 From: arisris Date: Wed, 28 Aug 2024 15:34:42 +0700 Subject: [PATCH 2/7] Update readme --- packages/dev-server/README.md | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/packages/dev-server/README.md b/packages/dev-server/README.md index 19a7a82..1089089 100644 --- a/packages/dev-server/README.md +++ b/packages/dev-server/README.md @@ -9,8 +9,7 @@ You can develop your application with Vite. It's fast. - Hono applications run on. - Fast by Vite. - HMR (Only for the client side). -- Adapters are available, e.g., Cloudflare. -- Also runs on Bun. +- Adapters are available, e.g., Cloudflare, Node.js, And Bun ## Demo @@ -167,6 +166,12 @@ You can pass the `env` value of a specified environment to the application. You can pass the Bindings specified in `wrangler.toml` to your application by using "Cloudflare Adapter". +Install miniflare and wrangler to develop and deploy your cf project. + +```text +npm i -D wrangler miniflare +``` + ```ts import devServer from '@hono/vite-dev-server' import cloudflareAdapter from '@hono/vite-dev-server/cloudflare' @@ -183,6 +188,32 @@ export default defineConfig(async () => { }) ``` +### Node.js & Bun +No additional dependencies needed. + +```ts +import devServer from '@hono/vite-dev-server' +import nodeAdapter from '@hono/vite-dev-server/node' +// OR +// import bunAdapter from '@hono/vite-dev-server/bun' +import { defineConfig } from 'vite' + +export default defineConfig(async () => { + return { + plugins: [ + devServer({ + adapter: nodeAdapter, + // OR + // adapter: bunAdapter, + }), + ], + } +}) +``` + +Using selected adapter, In hono app you can access environtment variable like ```ctx.env``` or ```env(ctx)```. + + ## Client-side You can write client-side scripts and import them into your application using Vite's features. From 44edfdd0e8fb501a30af12e6410d2722eeb36bb8 Mon Sep 17 00:00:00 2001 From: arisris Date: Wed, 28 Aug 2024 15:40:28 +0700 Subject: [PATCH 3/7] Update changeset --- .changeset/spotty-gifts-complain.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/spotty-gifts-complain.md diff --git a/.changeset/spotty-gifts-complain.md b/.changeset/spotty-gifts-complain.md new file mode 100644 index 0000000..b875dc1 --- /dev/null +++ b/.changeset/spotty-gifts-complain.md @@ -0,0 +1,5 @@ +--- +'@hono/vite-dev-server': major +--- + +Remove miniflare from deps, and add it to peer optional, add initial bun & node adapter. From b9e169db66b4e28af801c316085aa543d1bde4f0 Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Wed, 28 Aug 2024 21:55:49 +0900 Subject: [PATCH 4/7] update changeset --- .changeset/spotty-gifts-complain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/spotty-gifts-complain.md b/.changeset/spotty-gifts-complain.md index b875dc1..db1b2e1 100644 --- a/.changeset/spotty-gifts-complain.md +++ b/.changeset/spotty-gifts-complain.md @@ -1,5 +1,5 @@ --- -'@hono/vite-dev-server': major +'@hono/vite-dev-server': patch --- Remove miniflare from deps, and add it to peer optional, add initial bun & node adapter. From df1689dd03903cafce366a86a5111991034d36c4 Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Wed, 28 Aug 2024 21:56:04 +0900 Subject: [PATCH 5/7] update lockfile --- yarn.lock | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/yarn.lock b/yarn.lock index f6cfb3f..0bf1054 100644 --- a/yarn.lock +++ b/yarn.lock @@ -942,6 +942,15 @@ __metadata: wrangler: ^3.63.1 peerDependencies: hono: "*" + miniflare: "*" + wrangler: "*" + peerDependenciesMeta: + hono: + optional: false + miniflare: + optional: true + wrangler: + optional: true languageName: unknown linkType: soft From eb98e41e6959663f433e7dde513e61278d6b2eeb Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Wed, 28 Aug 2024 21:57:53 +0900 Subject: [PATCH 6/7] remove description not related to this PR --- packages/dev-server/README.md | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/packages/dev-server/README.md b/packages/dev-server/README.md index 1089089..1bc8659 100644 --- a/packages/dev-server/README.md +++ b/packages/dev-server/README.md @@ -188,32 +188,6 @@ export default defineConfig(async () => { }) ``` -### Node.js & Bun -No additional dependencies needed. - -```ts -import devServer from '@hono/vite-dev-server' -import nodeAdapter from '@hono/vite-dev-server/node' -// OR -// import bunAdapter from '@hono/vite-dev-server/bun' -import { defineConfig } from 'vite' - -export default defineConfig(async () => { - return { - plugins: [ - devServer({ - adapter: nodeAdapter, - // OR - // adapter: bunAdapter, - }), - ], - } -}) -``` - -Using selected adapter, In hono app you can access environtment variable like ```ctx.env``` or ```env(ctx)```. - - ## Client-side You can write client-side scripts and import them into your application using Vite's features. From c48d3f4dd6a2a5fdd35a812e863cff4ba40cea79 Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Wed, 28 Aug 2024 21:59:50 +0900 Subject: [PATCH 7/7] remove the description not related to the PR --- .changeset/spotty-gifts-complain.md | 2 +- packages/dev-server/README.md | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.changeset/spotty-gifts-complain.md b/.changeset/spotty-gifts-complain.md index db1b2e1..761313c 100644 --- a/.changeset/spotty-gifts-complain.md +++ b/.changeset/spotty-gifts-complain.md @@ -2,4 +2,4 @@ '@hono/vite-dev-server': patch --- -Remove miniflare from deps, and add it to peer optional, add initial bun & node adapter. +Remove miniflare from deps, and add it to peer optional. diff --git a/packages/dev-server/README.md b/packages/dev-server/README.md index 1bc8659..38463b0 100644 --- a/packages/dev-server/README.md +++ b/packages/dev-server/README.md @@ -9,7 +9,8 @@ You can develop your application with Vite. It's fast. - Hono applications run on. - Fast by Vite. - HMR (Only for the client side). -- Adapters are available, e.g., Cloudflare, Node.js, And Bun +- Adapters are available, e.g., Cloudflare. +- Also runs on Bun. ## Demo