Skip to content

Commit

Permalink
support react compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
MrWangJustToDo committed Nov 14, 2024
1 parent a278dcd commit beee5db
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 58 deletions.
20 changes: 19 additions & 1 deletion packages/myreact/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,25 @@ const version = enableMockReact.current ? "18.2.0" : __VERSION__;
const __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
ReactCurrentActQueue: {},
ReactCurrentBatchConfig: {},
ReactCurrentDispatcher: { current: {} },
ReactCurrentDispatcher: {
current: {
useCallback,
useContext,
useDebugValue,
useDeferredValue,
useEffect,
useId,
useImperativeHandle,
useInsertionEffect,
useLayoutEffect,
useMemo,
useReducer,
useRef,
useState,
useSyncExternalStore,
useTransition,
},
},
ReactCurrentOwner: { current: null },
ReactDebugCurrentFrame: {},
};
Expand Down
125 changes: 74 additions & 51 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions ui/next-example/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import withNext from "@my-react/react-refresh-tools/withNext";

/** @type {import('next').NextConfig} */
const nextConfig = withNext({
const config = {
reactStrictMode: true,
});
experimental: {
reactCompiler: {
target: '18',
}, // or React Compiler options
},
}

export default nextConfig;
const nextConfig = withNext(config);

// export default config;

// module.exports = nextConfig;
export default nextConfig;
6 changes: 4 additions & 2 deletions ui/next-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@types/react-dom": "^18.2.19",
"autoprefixer": "^10.4.20",
"eslint": "^8.57.0",
"next": "^15.0.2",
"next": "^15.0.3",
"postcss": "^8.4.47",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -35,7 +35,9 @@
"react-dom": "node_modules/@my-react/react-dom/index.js"
},
"devDependencies": {
"babel-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
"esm-module-alias": "^2.2.0",
"module-alias": "^2.2.3"
"module-alias": "^2.2.3",
"react-compiler-runtime": "19.0.0-beta-a7bf2bd-20241110"
}
}

0 comments on commit beee5db

Please sign in to comment.