feat(dev-server): add `getConnInfo` helper function
Fix #251
🦋 Changeset detected
Latest commit: 1621e9fa2af408e922c9c3566e8e31155ce86a26
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| @hono/vite-dev-server | Minor |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Hi @Hill-98
Thank you for the PR. Ideally, the Node.js Adapter is better to inject incoming and outgoing, though I don't imagine a good implementation now.
Hi @yusukebe
What do you think about this? It adds a helper function so that developers don't have to worry about platform differences.
We can write code like this:
const getConnInfo = import.meta.env.DEV
? (await import('@hono/vite-dev-server/conninfo')).getConnInfo
: (await import('xxxxxx/conninfo')).getConnInfo
test is updated
Hi @Hill-98
I'm sorry I'm late.
I want to know how you use getConnInfo for production. This getConnInfo imported from @hono/vite-dev-server/conninfo is unavailable in production.
@yusukebe We can use the import.meta.env.DEV provided by vite to implement dynamic importing and tree shaking.
like this:
const getConnInfo = import.meta.env.DEV
? (await import('@hono/vite-dev-server/conninfo')).getConnInfo
: (await import('xxxxxx/conninfo')).getConnInfo
only vite serve will import @hono/vite-dev-server, vite build will import production packages.
@Hill-98
I got it, so this PR is meaningful. One thing. Can you add the description for this feature in README.md? Thanks.
@yusukebe I added a simple description to README.md, what do you think?
@Hill-98
Thanks! Looks good to me. I'll merge and release a new version.