diff --git a/.changeset/thirty-games-remain.md b/.changeset/thirty-games-remain.md new file mode 100644 index 00000000..cd9d59b5 --- /dev/null +++ b/.changeset/thirty-games-remain.md @@ -0,0 +1,5 @@ +--- +'@hono/react-compat': patch +--- + +Initial release diff --git a/package.json b/package.json index e59f98c8..5ea5f0ab 100644 --- a/package.json +++ b/package.json @@ -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}'", @@ -62,4 +63,4 @@ "typescript": "^5.2.2" }, "packageManager": "yarn@4.0.2" -} +} \ No newline at end of file diff --git a/packages/react-compat/README.md b/packages/react-compat/README.md new file mode 100644 index 00000000..750b2334 --- /dev/null +++ b/packages/react-compat/README.md @@ -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 + +## License + +MIT diff --git a/packages/react-compat/package.json b/packages/react-compat/package.json new file mode 100644 index 00000000..b6f1aa63 --- /dev/null +++ b/packages/react-compat/package.json @@ -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" + } +} \ No newline at end of file diff --git a/packages/react-compat/src/client.ts b/packages/react-compat/src/client.ts new file mode 100644 index 00000000..e228b4af --- /dev/null +++ b/packages/react-compat/src/client.ts @@ -0,0 +1,3 @@ +export * from 'hono/jsx/dom/client' +import * as honoJSXDomClient from 'hono/jsx/dom/client' +export { honoJSXDomClient as default } diff --git a/packages/react-compat/src/index.ts b/packages/react-compat/src/index.ts new file mode 100644 index 00000000..b93c1361 --- /dev/null +++ b/packages/react-compat/src/index.ts @@ -0,0 +1,3 @@ +export * from 'hono/jsx' +import * as honoJSX from 'hono/jsx' +export { honoJSX as default } diff --git a/packages/react-compat/src/jsx-dev-runtime.ts b/packages/react-compat/src/jsx-dev-runtime.ts new file mode 100644 index 00000000..dd9b7aa7 --- /dev/null +++ b/packages/react-compat/src/jsx-dev-runtime.ts @@ -0,0 +1 @@ +export * from 'hono/jsx/jsx-dev-runtime' diff --git a/packages/react-compat/src/jsx-runtime.ts b/packages/react-compat/src/jsx-runtime.ts new file mode 100644 index 00000000..d50577b7 --- /dev/null +++ b/packages/react-compat/src/jsx-runtime.ts @@ -0,0 +1 @@ +export * from 'hono/jsx/jsx-runtime' diff --git a/packages/react-compat/src/server.ts b/packages/react-compat/src/server.ts new file mode 100644 index 00000000..6010b5ad --- /dev/null +++ b/packages/react-compat/src/server.ts @@ -0,0 +1,3 @@ +export * from 'hono/jsx/dom/server' +import * as honoJSXDomServer from 'hono/jsx/dom/server' +export { honoJSXDomServer as default } diff --git a/packages/react-compat/tsconfig.json b/packages/react-compat/tsconfig.json new file mode 100644 index 00000000..acfcd843 --- /dev/null +++ b/packages/react-compat/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "rootDir": "./src", + "outDir": "./dist", + }, + "include": [ + "src/**/*.ts" + ], +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 11ecc34b..d3b7ee92 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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"