-
-
Notifications
You must be signed in to change notification settings - Fork 602
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
Improve React compability with NPM Aliases #2925
Comments
@gaetan-puleo Thank you for the request! @usualoma I'll check it later, but I want you to take a look. It would be super cool if we could do it. |
On my side I created a POC to test the idea. https://www.npmjs.com/package/hono-jsx-dom-compat I get the Vite Starter page working with Hono To test the POC, you can create a new vite project with react and do I will describe the steps I used to make it works |
First I cloned https://github.com/honojs/middleware I duplicated the hello middleware. I created three files in the src folder. Here the content of the files. client.ts export * from 'hono/jsx/dom/client';
import {hydrateRoot, createRoot} from 'hono/jsx/dom/client'
export default {hydrateRoot, createRoot} index.ts export * from 'hono/jsx/dom';
export * as default from 'hono/jsx/dom' and jsx-dev-runtime.ts export * from 'hono/jsx/dom/jsx-dev-runtime'; After I updated the package.json {
"name": "hono-jsx-dom-compat",
"version": "0.1.8",
"description": "hono react compatibility layer",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"test": "vitest --run",
"build": "tsup ./src/index.ts src/client.ts src/jsx-dev-runtime.ts --format esm,cjs --dts",
"publint": "publint",
"release": "yarn build && yarn test && yarn publint && yarn publish"
},
"exports": {
".": {
"types": "./dist/index.d.mts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
"./client": {
"types": "./dist/client.d.mts",
"import": "./dist/client.mjs",
"require": "./dist/client.js"
},
"./jsx-dev-runtime": {
"types": "./dist/jsx-dev-runtime.d.mts",
"import": "./dist/jsx-dev-runtime.mjs",
"require": "./dist/jsx-dev-runtime.js"
}
},
"license": "MIT",
"publishConfig": {
"registry": "https://registry.npmjs.org",
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/honojs/middleware.git"
},
"homepage": "https://github.com/honojs/middleware",
"peerDependencies": {
"hono": "*"
},
"devDependencies": {
"tsup": "^8.0.1",
"vitest": "^1.0.4"
}
} I updated the exports part and the build script. After that I published everything on npm |
The package is not perfect, The types are not managed, I only ran |
Hi @gaetan-puleo This is super cool. I would love to add it to "hono/middleware". I think the type issue can be solved by adjusting the build process and package.json. I think one point is which aliases should be used.
|
Hi @usualoma I just want to add, you can export |
I created a pull request in "honojs/middleware". There is no third-party dependency, so it should be in "honojs/hono", but the current directory structure makes it a bit difficult to do, so I created it in "honojs/middleware". "honojs/middleware" also contains tools such as "eslint-config", which is used internally, so I think this is fine for the time being. |
Thanks @usualoma
No problem. This will be the best place and name. I'll check it. |
Hi @gaetan-puleo ! I've released
This works well. Thank you for your awesome idea! |
Thank you @yusukebe !! |
What is the feature you are proposing?
We could create a package to alias hono/jsx/dom.
This package will only reexport everything coming from hono/jsx/dom.
Inspiration : https://www.npmjs.com/package/@preact/compat
It will be possible to do something like this
yarn add react@npm:@hono/jsx-dom-compat
,bun add react@npm:@hono/jsx-dom-compat
to create a React alias without Vite.It's native and use npm aliases https://bun.sh/guides/install/npm-alias
The text was updated successfully, but these errors were encountered: