Skip to content

the same import for all runtimes #4135

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

Open
huseeiin opened this issue May 11, 2025 · 3 comments
Open

the same import for all runtimes #4135

huseeiin opened this issue May 11, 2025 · 3 comments
Labels
enhancement New feature or request.

Comments

@huseeiin
Copy link

What is the feature you are proposing?

can this:

import { getConnInfo } from 'hono/cloudflare-workers'

be converted:

import { getConnInfo } from 'hono'

through the help of something like package.json export conditions?

this will make it easier to test the same hono app in different runtimes without changing any code

@huseeiin huseeiin added the enhancement New feature or request. label May 11, 2025
@yusukebe
Copy link
Member

Hi @huseeiin

This is interesting.

through the help of something like package.json export conditions?

I'm curious. My concern is that, for example, if it is a Bun-specific API, the app will fail when using it on Cloudflare Workers. But can we avoid it with export conditions?

@huseeiin
Copy link
Author

Hi @huseeiin

This is interesting.

through the help of something like package.json export conditions?

I'm curious. My concern is that, for example, if it is a Bun-specific API, the app will fail when using it on Cloudflare Workers. But can we avoid it with export conditions?

cloudflare, bun, node all have their own export conditions

@huseeiin
Copy link
Author

huseeiin commented May 14, 2025

i learned that you need to put bun before node otherwise bun will prefer node:

{
  "exports": {
    "bun": "./bun.js",
    "node": "./node.js",
    "workerd": "./cloudflare.js"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request.
Projects
None yet
Development

No branches or pull requests

2 participants