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

feat: add @hono/react-compat package #563

Merged
merged 6 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/thirty-games-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hono/react-compat': patch
---

Initial release
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"build:prometheus": "yarn workspace @hono/prometheus build",
"build:oidc-auth": "yarn workspace @hono/oidc-auth build",
"build:node-ws": "yarn workspace @hono/node-ws build",
"build:react-compat": "yarn workspace @hono/react-compat build",
"build": "run-p 'build:*'",
"lint": "eslint 'packages/**/*.{ts,tsx}'",
"lint:fix": "eslint --fix 'packages/**/*.{ts,tsx}'",
Expand Down Expand Up @@ -62,4 +63,4 @@
"typescript": "^5.2.2"
},
"packageManager": "yarn@4.0.2"
}
}
19 changes: 19 additions & 0 deletions packages/react-compat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Alias of hono/jsx for replacement of React

This package is used to install the React compatibility API provided by [Hono](https://github.com/honojs/hono). This package allows you to replace the "react" and "react-dom" entities with "@hono/react-compat".

## Usage

```bash
npm install react@npm:@hono/react-compat react-dom@npm:@hono/react-compat
```

After installing in this way, "@hono/react-compat" will be loaded when "react" is specified in the `jsxImportSource` setting or in the `import` statement. See the [npm docs](https://docs.npmjs.com/cli/v7/commands/npm-install) for more information about aliased installs.

## Author

Taku Amano <https://github.com/usualoma>

## License

MIT
33 changes: 33 additions & 0 deletions packages/react-compat/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@hono/react-compat",
"type": "module",
"version": "0.0.0",
"description": "Alias of hono/jsx for replacement of React",
"license": "MIT",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsup ./src --format esm,cjs --dts",
"publint": "publint",
"release": "yarn build && yarn test && yarn publint && yarn publish"
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"./*": {
"types": "./dist/*.d.ts",
"import": "./dist/*.js",
"require": "./dist/*.cjs"
}
},
"peerDependencies": {
"hono": ">=4.5.*"
},
"devDependencies": {
"hono": "4.5.0-rc.1",
"tsup": "^8.0.1"
}
}
3 changes: 3 additions & 0 deletions packages/react-compat/src/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from 'hono/jsx/dom/client'
import * as honoJSXDomClient from 'hono/jsx/dom/client'
export { honoJSXDomClient as default }
3 changes: 3 additions & 0 deletions packages/react-compat/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from 'hono/jsx'
import * as honoJSX from 'hono/jsx'
export { honoJSX as default }
1 change: 1 addition & 0 deletions packages/react-compat/src/jsx-dev-runtime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from 'hono/jsx/jsx-dev-runtime'
1 change: 1 addition & 0 deletions packages/react-compat/src/jsx-runtime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from 'hono/jsx/jsx-runtime'
3 changes: 3 additions & 0 deletions packages/react-compat/src/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from 'hono/jsx/dom/server'
import * as honoJSXDomServer from 'hono/jsx/dom/server'
export { honoJSXDomServer as default }
10 changes: 10 additions & 0 deletions packages/react-compat/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
},
"include": [
"src/**/*.ts"
],
}
18 changes: 18 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2042,6 +2042,17 @@ __metadata:
languageName: unknown
linkType: soft

"@hono/react-compat@workspace:packages/react-compat":
version: 0.0.0-use.local
resolution: "@hono/react-compat@workspace:packages/react-compat"
dependencies:
hono: "npm:4.5.0-rc.1"
tsup: "npm:^8.0.1"
peerDependencies:
hono: ">=4.5.*"
languageName: unknown
linkType: soft

"@hono/react-renderer@workspace:packages/react-renderer":
version: 0.0.0-use.local
resolution: "@hono/react-renderer@workspace:packages/react-renderer"
Expand Down Expand Up @@ -9597,6 +9608,13 @@ __metadata:
languageName: unknown
linkType: soft

"hono@npm:4.5.0-rc.1":
version: 4.5.0-rc.1
resolution: "hono@npm:4.5.0-rc.1"
checksum: aaba4187da6dfb697b63772fd3f05466697a01eb2cc8a0c189a0bc464d49f6cedc1caa107b390488634e72544551ed8b34d906b9ef5c5780f1860a68666d56de
languageName: node
linkType: hard

"hono@npm:^3.11.7":
version: 3.11.7
resolution: "hono@npm:3.11.7"
Expand Down