Skip to content

Commit

Permalink
try react compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
pengx17 committed May 18, 2024
1 parent 4156b3a commit a2c2e05
Show file tree
Hide file tree
Showing 9 changed files with 247 additions and 91 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"devDependencies": {
"@affine-test/kit": "workspace:*",
"@affine/cli": "workspace:*",
"@babel/core": "^7.24.5",
"@commitlint/cli": "^19.2.1",
"@commitlint/config-conventional": "^19.1.0",
"@faker-js/faker": "^8.4.1",
Expand All @@ -65,6 +66,7 @@
"@testing-library/react": "^15.0.0",
"@toeverything/infra": "workspace:*",
"@types/affine__env": "workspace:*",
"@types/babel__core": "^7",
"@types/eslint": "^8.56.7",
"@types/node": "^20.12.7",
"@typescript-eslint/eslint-plugin": "^7.6.0",
Expand All @@ -74,6 +76,8 @@
"@vitejs/plugin-react-swc": "^3.6.0",
"@vitest/coverage-istanbul": "1.6.0",
"@vitest/ui": "1.6.0",
"babel-loader": "^9.1.3",
"babel-plugin-react-compiler": "0.0.0-experimental-c23de8d-20240515",
"cross-env": "^7.0.3",
"electron": "^30.0.0",
"eslint": "^8.57.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/common/env/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"devDependencies": {
"@blocksuite/global": "0.15.0-canary-202405161332-f0fb4ad",
"@blocksuite/store": "0.15.0-canary-202405161332-f0fb4ad",
"react": "18.3.1",
"react-dom": "18.3.1",
"react": "19.0.0-beta-26f2496093-20240514",
"react-dom": "19.0.0-beta-26f2496093-20240514",
"vitest": "1.6.0"
},
"exports": {
Expand Down
4 changes: 2 additions & 2 deletions packages/common/infra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"jotai-effect": "^1.0.0",
"lodash-es": "^4.17.21",
"nanoid": "^5.0.7",
"react": "18.3.1",
"react": "19.0.0-beta-26f2496093-20240514",
"tinykeys": "patch:tinykeys@npm%3A2.1.0#~/.yarn/patches/tinykeys-npm-2.1.0-819feeaed0.patch",
"yjs": "^13.6.14",
"zod": "^3.22.4"
Expand All @@ -34,7 +34,7 @@
"@blocksuite/presets": "0.15.0-canary-202405161332-f0fb4ad",
"@testing-library/react": "^15.0.0",
"async-call-rpc": "^6.4.0",
"react": "^18.2.0",
"react": "19.0.0-beta-26f2496093-20240514",
"rxjs": "^7.8.1",
"vite": "^5.2.8",
"vite-plugin-dts": "3.9.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/component/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
"lottie-web": "^5.12.2",
"nanoid": "^5.0.7",
"next-themes": "^0.3.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"react": "19.0.0-beta-26f2496093-20240514",
"react-dom": "19.0.0-beta-26f2496093-20240514",
"react-error-boundary": "^4.0.13",
"react-is": "^18.2.0",
"react-paginate": "^8.2.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@
"mixpanel-browser": "^2.49.0",
"nanoid": "^5.0.7",
"next-themes": "^0.3.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"react": "19.0.0-beta-26f2496093-20240514",
"react-dom": "19.0.0-beta-26f2496093-20240514",
"react-error-boundary": "^4.0.13",
"react-is": "18.3.1",
"react-is": "19.0.0-beta-26f2496093-20240514",
"react-router-dom": "^6.22.3",
"react-transition-state": "^2.1.1",
"react-virtuoso": "^4.7.8",
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
"jotai-devtools": "^0.9.0",
"lodash-es": "^4.17.21",
"nanoid": "^5.0.7",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react": "19.0.0-beta-26f2496093-20240514",
"react-dom": "19.0.0-beta-26f2496093-20240514",
"react-router-dom": "^6.22.3",
"rxjs": "^7.8.1",
"semver": "^7.6.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"core-js": "^3.36.1",
"intl-segmenter-polyfill-rs": "^0.1.7",
"jotai": "^2.8.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react": "19.0.0-beta-26f2496093-20240514",
"react-dom": "19.0.0-beta-26f2496093-20240514"
},
"devDependencies": {
"@affine/cli": "workspace:*",
Expand Down
59 changes: 35 additions & 24 deletions tools/cli/src/webpack/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,35 +249,46 @@ export const createConfiguration: (
{
test: /\.tsx?$/,
exclude: /node_modules/,
loader: 'swc-loader',
options: {
// https://swc.rs/docs/configuring-swc/
jsc: {
preserveAllComments: true,
parser: {
syntax: 'typescript',
dynamicImport: true,
topLevelAwait: false,
tsx: true,
decorators: true,
use: [
{
loader: 'babel-loader',
options: {
plugins: ['babel-plugin-react-compiler'],
},
target: 'es2022',
externalHelpers: false,
transform: {
react: {
runtime: 'automatic',
refresh: buildFlags.mode === 'development' && {
refreshReg: '$RefreshReg$',
refreshSig: '$RefreshSig$',
emitFullSignatures: true,
},
{
loader: 'swc-loader',
options: {
parseMap: true,
// https://swc.rs/docs/configuring-swc/
jsc: {
preserveAllComments: true,
parser: {
syntax: 'typescript',
dynamicImport: true,
topLevelAwait: false,
tsx: true,
decorators: true,
},
target: 'es2022',
externalHelpers: false,
transform: {
react: {
runtime: 'automatic',
refresh: buildFlags.mode === 'development' && {
refreshReg: '$RefreshReg$',
refreshSig: '$RefreshSig$',
emitFullSignatures: true,
},
},
useDefineForClassFields: false,
},
},
useDefineForClassFields: false,
sourceMaps: true,
inlineSourcesContent: true,
},
},
sourceMaps: true,
inlineSourcesContent: true,
},
],
},
{
test: /\.(png|jpg|gif|svg|webp|mp4|zip)$/,
Expand Down
Loading

0 comments on commit a2c2e05

Please sign in to comment.