React源码学习进阶(一)新版React如何调试源码?
使用create-react-app创建项目
create-react-app创建项目npx create-react-app react-debug

下载React源码


支持sourceMap
sourceMap


Last updated
create-react-app创建项目npx create-react-app react-debug



sourceMap


Last updated
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:3001",
"webRoot": "${workspaceFolder}"
}
]
}git clone https://github.com/facebook/react.gityarn
yarn buildnpm run ejectalias: {
'react-dom$': path.resolve(__dirname, '../react/build/node_modules/react-dom/umd/react-dom.development.js'),
'react$': path.resolve(__dirname, '../react/build/node_modules/react/umd/react.development.js'),
}"sourceMaps": truefunction getRollupOutputOptions(
outputPath,
format,
globals,
globalName,
bundleType
) {
const isProduction = isProductionBundleType(bundleType);
return {
file: outputPath,
format,
globals,
freeze: !isProduction,
interop: false,
name: globalName,
sourcemap: true,
esModule: false,
};
} // {
// transform(source) {
// return source.replace(/['"]use strict["']/g, '');
// },
// }
// isProduction &&
// closure(
// Object.assign({}, closureOptions, {
// // Don't let it create global variables in the browser.
// // https://github.com/facebook/react/issues/10909
// assume_function_wrapper: !isUMDBundle,
// renaming: !shouldStayReadable,
// })
// )
// shouldStayReadable &&
// prettier({
// parser: 'babel',
// singleQuote: false,
// trailingComma: 'none',
// bracketSpacing: true,
// })
// {
// renderChunk(source) {
// return Wrappers.wrapBundle(
// source,
// bundleType,
// globalName,
// filename,
// moduleType
// );
// },
// },