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

Add runtime conditions into package.json #852

Closed
yusukebe opened this issue Jan 30, 2023 · 4 comments
Closed

Add runtime conditions into package.json #852

yusukebe opened this issue Jan 30, 2023 · 4 comments

Comments

@yusukebe
Copy link
Member

yusukebe commented Jan 30, 2023

Hono supports JavaScript multi-runtime, and WinterCG defines the standard keys for that (c.runtime already returns the runtime key on which the app runtime running). Then I know we can include the keys in package.json for specifiying conditions like Wrangler doing:

I don't know yet what effect it will have on Hono, but I think it is good we will challenge it.

@yusukebe
Copy link
Member Author

Hi @yujong-lee !

If you are interested, check it out.

@yusukebe
Copy link
Member Author

The new version of Wrangler supports the conditional exports field.

And Bun also looks up the exports field if it has bun or not:

@yusukebe
Copy link
Member Author

yusukebe commented Feb 8, 2023

According the project:

https://github.com/cloudflare/workers-sdk/blob/main/fixtures/isomorphic-random-example/package.json

we can write the package.json like this:

{
  "name": "isomorphic-random-example",
  "version": "0.0.1",
  "private": true,
  "exports": {
    "node": "./src/node.js",
    "workerd": "./src/workerd.mjs"
  }
}

This is a very interesting way to have references to, for example, workerd.js for workerd, deno.js for deno, and bun.js for bun. But, in the case of Hono, all runtimes only need to refer to one index.js, so it doesn't make much sense:)

@yusukebe
Copy link
Member Author

It does not seem necessary to go this far.

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

No branches or pull requests

1 participant