chenjf5 / note

1 stars 0 forks source link

react调试配置 #16

Open chenjf5 opened 4 years ago

chenjf5 commented 4 years ago

https://ksh7.com/2020/05/13/react-source/

chenjf5 commented 4 years ago

配置 React 源码的本地调试环境 creat-react-app <项目名称> yarn run eject clone 官方源码(目前是 master latest)小版本可能会有些许异同,可以根据命令行的报错信息再去搜索(镜像 react 仓库,clone 慢的可以使用这个) 根目录中执行 Shell git clone --depth=1 https://github.com.cnpmjs.org/facebook/react.git src/react 修改相关配置 链接本地源码 react/config/webpack.config.js Diff resolve: { alias: { 'react-native': 'react-native-web',

react/config/env.js

Diff const stringified = { ....,

Json { "extends": "react-app", "globals": { "SharedArrayBuffer": true,

"spyOnDev": true,
"spyOnDevAndProd": true,
"spyOnProd": true,
"__PROFILE__": true,
"__UMD__": true,
"__EXPERIMENTAL__": true,
"__VARIANT__": true,
"gate": true,
"trustedTypes": true

} } 忽略 flow webstrom 中可自动识别 flow,其他编辑器可能需要下载插件

Shell yarn add @babel/plugin-transform-flow-strip-types -D 3.1 添加配置

react/config/webpack.config.js[babel-loader]

Diff plugins: [

Diff

Diff

export default ReactSharedInternals; 4.2 关闭 eslint 扩展

/react/.eslingrc.js[module.exports]

Diff extends: [

Diff

export default function invariant(condition, format, a, b, c, d, e, f) {