diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d5625da8..7fa20d91 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1162,6 +1162,34 @@ importers: specifier: ^5.9.3 version: 5.9.3 + rslib/react-compiler: + dependencies: + react-dom: + specifier: '>=19.0.0' + version: 19.2.5(react@19.2.5) + devDependencies: + '@rsbuild/plugin-babel': + specifier: ^1.1.2 + version: 1.1.2(@rsbuild/core@2.0.5) + '@rsbuild/plugin-react': + specifier: ^2.0.0 + version: 2.0.0(@rsbuild/core@2.0.5)(@rspack/core@2.0.2) + '@rslib/core': + specifier: ^0.21.3 + version: 0.21.3(@module-federation/runtime-tools@2.4.0)(core-js@3.49.0)(typescript@5.9.3) + '@types/react': + specifier: ^19.2.14 + version: 19.2.14 + babel-plugin-react-compiler: + specifier: ^1.0.0 + version: 1.0.0 + react: + specifier: ^19.2.5 + version: 19.2.5 + typescript: + specifier: ^5.9.3 + version: 5.9.3 + rslib/react-css-module: dependencies: react-dom: diff --git a/rslib/react-compiler/.gitignore b/rslib/react-compiler/.gitignore new file mode 100644 index 00000000..498d61d5 --- /dev/null +++ b/rslib/react-compiler/.gitignore @@ -0,0 +1,13 @@ +.DS_Store +*.local +*.log* + +# Dist +node_modules +dist/ +storybook-static + +# IDE +.vscode/* +!.vscode/extensions.json +.idea diff --git a/rslib/react-compiler/README.md b/rslib/react-compiler/README.md new file mode 100644 index 00000000..ae4f5bbe --- /dev/null +++ b/rslib/react-compiler/README.md @@ -0,0 +1,23 @@ +# Rslib project + +## Setup + +Install the dependencies: + +```bash +pnpm install +``` + +## Get started + +Build the library: + +```bash +pnpm build +``` + +Build the library in watch mode: + +```bash +pnpm dev +``` diff --git a/rslib/react-compiler/package.json b/rslib/react-compiler/package.json new file mode 100644 index 00000000..8c59a524 --- /dev/null +++ b/rslib/react-compiler/package.json @@ -0,0 +1,32 @@ +{ + "name": "@rslib-example/react-compiler", + "version": "0.0.0", + "type": "module", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js" + } + }, + "types": "./dist/index.d.ts", + "files": [ + "dist" + ], + "scripts": { + "build": "rslib", + "dev": "rslib -w" + }, + "devDependencies": { + "@rsbuild/plugin-babel": "^1.1.2", + "@rsbuild/plugin-react": "^2.0.0", + "@rslib/core": "^0.21.3", + "@types/react": "^19.2.14", + "babel-plugin-react-compiler": "^1.0.0", + "react": "^19.2.5", + "typescript": "^5.9.3" + }, + "peerDependencies": { + "react": ">=19.0.0", + "react-dom": ">=19.0.0" + } +} diff --git a/rslib/react-compiler/rslib.config.ts b/rslib/react-compiler/rslib.config.ts new file mode 100644 index 00000000..36586a65 --- /dev/null +++ b/rslib/react-compiler/rslib.config.ts @@ -0,0 +1,25 @@ +import { pluginBabel } from '@rsbuild/plugin-babel'; +import { pluginReact } from '@rsbuild/plugin-react'; +import { defineConfig } from '@rslib/core'; + +export default defineConfig({ + lib: [ + { + bundle: false, + dts: true, + format: 'esm', + }, + ], + output: { + target: 'web', + }, + plugins: [ + pluginReact(), + pluginBabel({ + include: /\.(?:jsx|tsx)$/, + babelLoaderOptions(opts) { + opts.plugins?.unshift('babel-plugin-react-compiler'); + }, + }), + ], +}); diff --git a/rslib/react-compiler/src/Button.tsx b/rslib/react-compiler/src/Button.tsx new file mode 100644 index 00000000..b8a56bd7 --- /dev/null +++ b/rslib/react-compiler/src/Button.tsx @@ -0,0 +1,14 @@ +import './button.css'; + +interface ButtonProps { + label: string; + primary?: boolean; +} + +export const Button = ({ label, primary = false }: ButtonProps) => { + return ( + + ); +}; diff --git a/rslib/react-compiler/src/button.css b/rslib/react-compiler/src/button.css new file mode 100644 index 00000000..186cc812 --- /dev/null +++ b/rslib/react-compiler/src/button.css @@ -0,0 +1,15 @@ +.demo-button { + font-family: inherit; + font-weight: 700; + border: 0; + border-radius: 999px; + cursor: pointer; + display: inline-block; + line-height: 1; + padding: 12px 24px; +} + +.demo-button--primary { + color: white; + background-color: #1ea7fd; +} diff --git a/rslib/react-compiler/src/index.tsx b/rslib/react-compiler/src/index.tsx new file mode 100644 index 00000000..fe9c53c5 --- /dev/null +++ b/rslib/react-compiler/src/index.tsx @@ -0,0 +1 @@ +export { Button } from './Button'; diff --git a/rslib/react-compiler/tsconfig.json b/rslib/react-compiler/tsconfig.json new file mode 100644 index 00000000..510ab68d --- /dev/null +++ b/rslib/react-compiler/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "lib": ["DOM", "ES2022"], + "module": "ESNext", + "jsx": "react-jsx", + "strict": true, + "skipLibCheck": true, + "isolatedModules": true, + "resolveJsonModule": true, + "moduleResolution": "bundler", + "useDefineForClassFields": true + }, + "include": ["src"] +}