From 2fb1e8143b0522a2e9f59a4bfc5f7faf8544566a Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Fri, 29 Aug 2025 13:41:51 -0400 Subject: [PATCH] feat(react-compiler): add React Compiler examples This PR adds examples for Vite + React Compiler (JS & TS). These example repos will be used as templates for a new variant I'm proposing to add to create-vite, that allows new Vite apps to be initialized with the compiler ready to go. --- eslint.config.js | 1 + .../examples/compiler-ts/README.md | 14 ++++ .../examples/compiler-ts/_gitignore | 24 +++++++ .../examples/compiler-ts/eslint.config.js | 23 +++++++ .../examples/compiler-ts/index.html | 13 ++++ .../examples/compiler-ts/package.json | 30 ++++++++ .../examples/compiler-ts/public/vite.svg | 1 + .../examples/compiler-ts/src/App.css | 42 ++++++++++++ .../examples/compiler-ts/src/App.tsx | 35 ++++++++++ .../examples/compiler-ts/src/assets/react.svg | 1 + .../examples/compiler-ts/src/index.css | 68 +++++++++++++++++++ .../examples/compiler-ts/src/main.tsx | 10 +++ .../examples/compiler-ts/src/vite-env.d.ts | 1 + .../examples/compiler-ts/tsconfig.app.json | 27 ++++++++ .../examples/compiler-ts/tsconfig.json | 7 ++ .../examples/compiler-ts/tsconfig.node.json | 25 +++++++ .../examples/compiler-ts/vite.config.ts | 13 ++++ .../plugin-react/examples/compiler/README.md | 14 ++++ .../plugin-react/examples/compiler/_gitignore | 24 +++++++ .../examples/compiler/eslint.config.js | 29 ++++++++ .../plugin-react/examples/compiler/index.html | 13 ++++ .../examples/compiler/package.json | 28 ++++++++ .../examples/compiler/public/vite.svg | 1 + .../examples/compiler/src/App.css | 42 ++++++++++++ .../examples/compiler/src/App.jsx | 35 ++++++++++ .../examples/compiler/src/assets/react.svg | 1 + .../examples/compiler/src/index.css | 68 +++++++++++++++++++ .../examples/compiler/src/main.jsx | 10 +++ .../examples/compiler/vite.config.js | 13 ++++ 29 files changed, 613 insertions(+) create mode 100644 packages/plugin-react/examples/compiler-ts/README.md create mode 100644 packages/plugin-react/examples/compiler-ts/_gitignore create mode 100644 packages/plugin-react/examples/compiler-ts/eslint.config.js create mode 100644 packages/plugin-react/examples/compiler-ts/index.html create mode 100644 packages/plugin-react/examples/compiler-ts/package.json create mode 100644 packages/plugin-react/examples/compiler-ts/public/vite.svg create mode 100644 packages/plugin-react/examples/compiler-ts/src/App.css create mode 100644 packages/plugin-react/examples/compiler-ts/src/App.tsx create mode 100644 packages/plugin-react/examples/compiler-ts/src/assets/react.svg create mode 100644 packages/plugin-react/examples/compiler-ts/src/index.css create mode 100644 packages/plugin-react/examples/compiler-ts/src/main.tsx create mode 100644 packages/plugin-react/examples/compiler-ts/src/vite-env.d.ts create mode 100644 packages/plugin-react/examples/compiler-ts/tsconfig.app.json create mode 100644 packages/plugin-react/examples/compiler-ts/tsconfig.json create mode 100644 packages/plugin-react/examples/compiler-ts/tsconfig.node.json create mode 100644 packages/plugin-react/examples/compiler-ts/vite.config.ts create mode 100644 packages/plugin-react/examples/compiler/README.md create mode 100644 packages/plugin-react/examples/compiler/_gitignore create mode 100644 packages/plugin-react/examples/compiler/eslint.config.js create mode 100644 packages/plugin-react/examples/compiler/index.html create mode 100644 packages/plugin-react/examples/compiler/package.json create mode 100644 packages/plugin-react/examples/compiler/public/vite.svg create mode 100644 packages/plugin-react/examples/compiler/src/App.css create mode 100644 packages/plugin-react/examples/compiler/src/App.jsx create mode 100644 packages/plugin-react/examples/compiler/src/assets/react.svg create mode 100644 packages/plugin-react/examples/compiler/src/index.css create mode 100644 packages/plugin-react/examples/compiler/src/main.jsx create mode 100644 packages/plugin-react/examples/compiler/vite.config.js diff --git a/eslint.config.js b/eslint.config.js index 1b2ff21dc..50bb87fad 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -14,6 +14,7 @@ export default tseslint.config( '**/playground-temp/**', '**/temp/**', 'packages/plugin-rsc/**', + 'packages/plugin-react/examples/**', ], }, eslint.configs.recommended, diff --git a/packages/plugin-react/examples/compiler-ts/README.md b/packages/plugin-react/examples/compiler-ts/README.md new file mode 100644 index 000000000..4b7072549 --- /dev/null +++ b/packages/plugin-react/examples/compiler-ts/README.md @@ -0,0 +1,14 @@ +# Vite + React Compiler (TS) + +This example shows how to setup a React application with [React Compiler](https://react.dev/learn/react-compiler) on Vite using [`@vitejs/plugin-react`](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react). + +[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/vitejs/vite-plugin-react/tree/main/packages/plugin-react/examples/compiler-ts) + +```sh +# run dev server +npm run dev + +# build for production and preview +npm run build +npm run preview +``` diff --git a/packages/plugin-react/examples/compiler-ts/_gitignore b/packages/plugin-react/examples/compiler-ts/_gitignore new file mode 100644 index 000000000..a547bf36d --- /dev/null +++ b/packages/plugin-react/examples/compiler-ts/_gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/packages/plugin-react/examples/compiler-ts/eslint.config.js b/packages/plugin-react/examples/compiler-ts/eslint.config.js new file mode 100644 index 000000000..474b67128 --- /dev/null +++ b/packages/plugin-react/examples/compiler-ts/eslint.config.js @@ -0,0 +1,23 @@ +import js from '@eslint/js' +import globals from 'globals' +import reactHooks from 'eslint-plugin-react-hooks' +import reactRefresh from 'eslint-plugin-react-refresh' +import tseslint from 'typescript-eslint' +import { globalIgnores } from 'eslint/config' + +export default tseslint.config([ + globalIgnores(['dist']), + { + files: ['**/*.{ts,tsx}'], + extends: [ + js.configs.recommended, + tseslint.configs.recommended, + reactHooks.configs['recommended'], + reactRefresh.configs.vite, + ], + languageOptions: { + ecmaVersion: 2020, + globals: globals.browser, + }, + }, +]) diff --git a/packages/plugin-react/examples/compiler-ts/index.html b/packages/plugin-react/examples/compiler-ts/index.html new file mode 100644 index 000000000..e4b78eae1 --- /dev/null +++ b/packages/plugin-react/examples/compiler-ts/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite + React + TS + + +
+ + + diff --git a/packages/plugin-react/examples/compiler-ts/package.json b/packages/plugin-react/examples/compiler-ts/package.json new file mode 100644 index 000000000..4da948884 --- /dev/null +++ b/packages/plugin-react/examples/compiler-ts/package.json @@ -0,0 +1,30 @@ +{ + "name": "@vitejs/plugin-react-examples-compiler-ts", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc -b && vite build", + "lint": "eslint .", + "preview": "vite preview" + }, + "dependencies": { + "react": "^19.1.1", + "react-dom": "^19.1.1" + }, + "devDependencies": { + "@eslint/js": "^9.34.0", + "@types/react": "^19.1.11", + "@types/react-dom": "^19.1.7", + "@vitejs/plugin-react": "^5.0.1", + "babel-plugin-react-compiler": "19.1.0-rc.3", + "eslint": "^9.34.0", + "eslint-plugin-react-hooks": "^6.0.0-rc.2", + "eslint-plugin-react-refresh": "^0.4.20", + "globals": "^16.3.0", + "typescript": "~5.8.3", + "typescript-eslint": "^8.40.0", + "vite": "^7.1.3" + } +} diff --git a/packages/plugin-react/examples/compiler-ts/public/vite.svg b/packages/plugin-react/examples/compiler-ts/public/vite.svg new file mode 100644 index 000000000..e7b8dfb1b --- /dev/null +++ b/packages/plugin-react/examples/compiler-ts/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/plugin-react/examples/compiler-ts/src/App.css b/packages/plugin-react/examples/compiler-ts/src/App.css new file mode 100644 index 000000000..b9d355df2 --- /dev/null +++ b/packages/plugin-react/examples/compiler-ts/src/App.css @@ -0,0 +1,42 @@ +#root { + max-width: 1280px; + margin: 0 auto; + padding: 2rem; + text-align: center; +} + +.logo { + height: 6em; + padding: 1.5em; + will-change: filter; + transition: filter 300ms; +} +.logo:hover { + filter: drop-shadow(0 0 2em #646cffaa); +} +.logo.react:hover { + filter: drop-shadow(0 0 2em #61dafbaa); +} + +@keyframes logo-spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} + +@media (prefers-reduced-motion: no-preference) { + a:nth-of-type(2) .logo { + animation: logo-spin infinite 20s linear; + } +} + +.card { + padding: 2em; +} + +.read-the-docs { + color: #888; +} diff --git a/packages/plugin-react/examples/compiler-ts/src/App.tsx b/packages/plugin-react/examples/compiler-ts/src/App.tsx new file mode 100644 index 000000000..3d7ded3ff --- /dev/null +++ b/packages/plugin-react/examples/compiler-ts/src/App.tsx @@ -0,0 +1,35 @@ +import { useState } from 'react' +import reactLogo from './assets/react.svg' +import viteLogo from '/vite.svg' +import './App.css' + +function App() { + const [count, setCount] = useState(0) + + return ( + <> +
+ + Vite logo + + + React logo + +
+

Vite + React

+
+ +

+ Edit src/App.tsx and save to test HMR +

+
+

+ Click on the Vite and React logos to learn more +

+ + ) +} + +export default App diff --git a/packages/plugin-react/examples/compiler-ts/src/assets/react.svg b/packages/plugin-react/examples/compiler-ts/src/assets/react.svg new file mode 100644 index 000000000..6c87de9bb --- /dev/null +++ b/packages/plugin-react/examples/compiler-ts/src/assets/react.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/plugin-react/examples/compiler-ts/src/index.css b/packages/plugin-react/examples/compiler-ts/src/index.css new file mode 100644 index 000000000..08a3ac9e1 --- /dev/null +++ b/packages/plugin-react/examples/compiler-ts/src/index.css @@ -0,0 +1,68 @@ +:root { + font-family: system-ui, Avenir, Helvetica, Arial, sans-serif; + line-height: 1.5; + font-weight: 400; + + color-scheme: light dark; + color: rgba(255, 255, 255, 0.87); + background-color: #242424; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} +a:hover { + color: #535bf2; +} + +body { + margin: 0; + display: flex; + place-items: center; + min-width: 320px; + min-height: 100vh; +} + +h1 { + font-size: 3.2em; + line-height: 1.1; +} + +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + background-color: #1a1a1a; + cursor: pointer; + transition: border-color 0.25s; +} +button:hover { + border-color: #646cff; +} +button:focus, +button:focus-visible { + outline: 4px auto -webkit-focus-ring-color; +} + +@media (prefers-color-scheme: light) { + :root { + color: #213547; + background-color: #ffffff; + } + a:hover { + color: #747bff; + } + button { + background-color: #f9f9f9; + } +} diff --git a/packages/plugin-react/examples/compiler-ts/src/main.tsx b/packages/plugin-react/examples/compiler-ts/src/main.tsx new file mode 100644 index 000000000..bef5202a3 --- /dev/null +++ b/packages/plugin-react/examples/compiler-ts/src/main.tsx @@ -0,0 +1,10 @@ +import { StrictMode } from 'react' +import { createRoot } from 'react-dom/client' +import './index.css' +import App from './App.tsx' + +createRoot(document.getElementById('root')!).render( + + + , +) diff --git a/packages/plugin-react/examples/compiler-ts/src/vite-env.d.ts b/packages/plugin-react/examples/compiler-ts/src/vite-env.d.ts new file mode 100644 index 000000000..11f02fe2a --- /dev/null +++ b/packages/plugin-react/examples/compiler-ts/src/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/packages/plugin-react/examples/compiler-ts/tsconfig.app.json b/packages/plugin-react/examples/compiler-ts/tsconfig.app.json new file mode 100644 index 000000000..227a6c672 --- /dev/null +++ b/packages/plugin-react/examples/compiler-ts/tsconfig.app.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo", + "target": "ES2022", + "useDefineForClassFields": true, + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "moduleDetection": "force", + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "erasableSyntaxOnly": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true + }, + "include": ["src"] +} diff --git a/packages/plugin-react/examples/compiler-ts/tsconfig.json b/packages/plugin-react/examples/compiler-ts/tsconfig.json new file mode 100644 index 000000000..1ffef600d --- /dev/null +++ b/packages/plugin-react/examples/compiler-ts/tsconfig.json @@ -0,0 +1,7 @@ +{ + "files": [], + "references": [ + { "path": "./tsconfig.app.json" }, + { "path": "./tsconfig.node.json" } + ] +} diff --git a/packages/plugin-react/examples/compiler-ts/tsconfig.node.json b/packages/plugin-react/examples/compiler-ts/tsconfig.node.json new file mode 100644 index 000000000..f85a39906 --- /dev/null +++ b/packages/plugin-react/examples/compiler-ts/tsconfig.node.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo", + "target": "ES2023", + "lib": ["ES2023"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "moduleDetection": "force", + "noEmit": true, + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "erasableSyntaxOnly": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/packages/plugin-react/examples/compiler-ts/vite.config.ts b/packages/plugin-react/examples/compiler-ts/vite.config.ts new file mode 100644 index 000000000..4efe189b1 --- /dev/null +++ b/packages/plugin-react/examples/compiler-ts/vite.config.ts @@ -0,0 +1,13 @@ +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react' + +// https://vite.dev/config/ +export default defineConfig({ + plugins: [ + react({ + babel: { + plugins: [['babel-plugin-react-compiler']], + }, + }), + ], +}) diff --git a/packages/plugin-react/examples/compiler/README.md b/packages/plugin-react/examples/compiler/README.md new file mode 100644 index 000000000..920768992 --- /dev/null +++ b/packages/plugin-react/examples/compiler/README.md @@ -0,0 +1,14 @@ +# Vite + React Compiler + +This example shows how to setup a React application with [React Compiler](https://react.dev/learn/react-compiler) on Vite using [`@vitejs/plugin-react`](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react). + +[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/vitejs/vite-plugin-react/tree/main/packages/plugin-react/examples/compiler) + +```sh +# run dev server +npm run dev + +# build for production and preview +npm run build +npm run preview +``` diff --git a/packages/plugin-react/examples/compiler/_gitignore b/packages/plugin-react/examples/compiler/_gitignore new file mode 100644 index 000000000..a547bf36d --- /dev/null +++ b/packages/plugin-react/examples/compiler/_gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/packages/plugin-react/examples/compiler/eslint.config.js b/packages/plugin-react/examples/compiler/eslint.config.js new file mode 100644 index 000000000..4f2531a15 --- /dev/null +++ b/packages/plugin-react/examples/compiler/eslint.config.js @@ -0,0 +1,29 @@ +import js from '@eslint/js' +import globals from 'globals' +import reactHooks from 'eslint-plugin-react-hooks' +import reactRefresh from 'eslint-plugin-react-refresh' +import { defineConfig, globalIgnores } from 'eslint/config' + +export default defineConfig([ + globalIgnores(['dist']), + { + files: ['**/*.{js,jsx}'], + extends: [ + js.configs.recommended, + reactHooks.configs['recommended'], + reactRefresh.configs.vite, + ], + languageOptions: { + ecmaVersion: 2020, + globals: globals.browser, + parserOptions: { + ecmaVersion: 'latest', + ecmaFeatures: { jsx: true }, + sourceType: 'module', + }, + }, + rules: { + 'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }], + }, + }, +]) diff --git a/packages/plugin-react/examples/compiler/index.html b/packages/plugin-react/examples/compiler/index.html new file mode 100644 index 000000000..0c589eccd --- /dev/null +++ b/packages/plugin-react/examples/compiler/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite + React + + +
+ + + diff --git a/packages/plugin-react/examples/compiler/package.json b/packages/plugin-react/examples/compiler/package.json new file mode 100644 index 000000000..db65662ff --- /dev/null +++ b/packages/plugin-react/examples/compiler/package.json @@ -0,0 +1,28 @@ +{ + "name": "@vitejs/plugin-react-examples-compiler", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "lint": "eslint .", + "preview": "vite preview" + }, + "dependencies": { + "react": "^19.1.1", + "react-dom": "^19.1.1" + }, + "devDependencies": { + "@eslint/js": "^9.34.0", + "@types/react": "^19.1.11", + "@types/react-dom": "^19.1.7", + "@vitejs/plugin-react": "^5.0.1", + "babel-plugin-react-compiler": "19.1.0-rc.3", + "eslint": "^9.34.0", + "eslint-plugin-react-hooks": "^6.0.0-rc.2", + "eslint-plugin-react-refresh": "^0.4.20", + "globals": "^16.3.0", + "vite": "^7.1.3" + } +} diff --git a/packages/plugin-react/examples/compiler/public/vite.svg b/packages/plugin-react/examples/compiler/public/vite.svg new file mode 100644 index 000000000..e7b8dfb1b --- /dev/null +++ b/packages/plugin-react/examples/compiler/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/plugin-react/examples/compiler/src/App.css b/packages/plugin-react/examples/compiler/src/App.css new file mode 100644 index 000000000..b9d355df2 --- /dev/null +++ b/packages/plugin-react/examples/compiler/src/App.css @@ -0,0 +1,42 @@ +#root { + max-width: 1280px; + margin: 0 auto; + padding: 2rem; + text-align: center; +} + +.logo { + height: 6em; + padding: 1.5em; + will-change: filter; + transition: filter 300ms; +} +.logo:hover { + filter: drop-shadow(0 0 2em #646cffaa); +} +.logo.react:hover { + filter: drop-shadow(0 0 2em #61dafbaa); +} + +@keyframes logo-spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} + +@media (prefers-reduced-motion: no-preference) { + a:nth-of-type(2) .logo { + animation: logo-spin infinite 20s linear; + } +} + +.card { + padding: 2em; +} + +.read-the-docs { + color: #888; +} diff --git a/packages/plugin-react/examples/compiler/src/App.jsx b/packages/plugin-react/examples/compiler/src/App.jsx new file mode 100644 index 000000000..f67355ae0 --- /dev/null +++ b/packages/plugin-react/examples/compiler/src/App.jsx @@ -0,0 +1,35 @@ +import { useState } from 'react' +import reactLogo from './assets/react.svg' +import viteLogo from '/vite.svg' +import './App.css' + +function App() { + const [count, setCount] = useState(0) + + return ( + <> +
+ + Vite logo + + + React logo + +
+

Vite + React

+
+ +

+ Edit src/App.jsx and save to test HMR +

+
+

+ Click on the Vite and React logos to learn more +

+ + ) +} + +export default App diff --git a/packages/plugin-react/examples/compiler/src/assets/react.svg b/packages/plugin-react/examples/compiler/src/assets/react.svg new file mode 100644 index 000000000..6c87de9bb --- /dev/null +++ b/packages/plugin-react/examples/compiler/src/assets/react.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/plugin-react/examples/compiler/src/index.css b/packages/plugin-react/examples/compiler/src/index.css new file mode 100644 index 000000000..08a3ac9e1 --- /dev/null +++ b/packages/plugin-react/examples/compiler/src/index.css @@ -0,0 +1,68 @@ +:root { + font-family: system-ui, Avenir, Helvetica, Arial, sans-serif; + line-height: 1.5; + font-weight: 400; + + color-scheme: light dark; + color: rgba(255, 255, 255, 0.87); + background-color: #242424; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +a { + font-weight: 500; + color: #646cff; + text-decoration: inherit; +} +a:hover { + color: #535bf2; +} + +body { + margin: 0; + display: flex; + place-items: center; + min-width: 320px; + min-height: 100vh; +} + +h1 { + font-size: 3.2em; + line-height: 1.1; +} + +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + background-color: #1a1a1a; + cursor: pointer; + transition: border-color 0.25s; +} +button:hover { + border-color: #646cff; +} +button:focus, +button:focus-visible { + outline: 4px auto -webkit-focus-ring-color; +} + +@media (prefers-color-scheme: light) { + :root { + color: #213547; + background-color: #ffffff; + } + a:hover { + color: #747bff; + } + button { + background-color: #f9f9f9; + } +} diff --git a/packages/plugin-react/examples/compiler/src/main.jsx b/packages/plugin-react/examples/compiler/src/main.jsx new file mode 100644 index 000000000..b9a1a6dea --- /dev/null +++ b/packages/plugin-react/examples/compiler/src/main.jsx @@ -0,0 +1,10 @@ +import { StrictMode } from 'react' +import { createRoot } from 'react-dom/client' +import './index.css' +import App from './App.jsx' + +createRoot(document.getElementById('root')).render( + + + , +) diff --git a/packages/plugin-react/examples/compiler/vite.config.js b/packages/plugin-react/examples/compiler/vite.config.js new file mode 100644 index 000000000..4efe189b1 --- /dev/null +++ b/packages/plugin-react/examples/compiler/vite.config.js @@ -0,0 +1,13 @@ +import { defineConfig } from 'vite' +import react from '@vitejs/plugin-react' + +// https://vite.dev/config/ +export default defineConfig({ + plugins: [ + react({ + babel: { + plugins: [['babel-plugin-react-compiler']], + }, + }), + ], +})