mirror of
https://github.com/zebrajr/react.git
synced 2025-12-07 00:20:28 +01:00
Before: <img width="844" alt="Screenshot 2024-07-04 at 3 20 34 PM" src="https://github.com/facebook/react/assets/63648/0fd8a53f-538a-4429-a4cf-c22f85a09aa8"> After: <img width="845" alt="Screenshot 2024-07-05 at 6 08 28 PM" src="https://github.com/facebook/react/assets/63648/7b9da13a-fa97-4581-9899-06de6fface65"> Firefox: <img width="1338" alt="Screenshot 2024-07-05 at 6 09 50 PM" src="https://github.com/facebook/react/assets/63648/f2eb9f2a-2251-408f-86d0-b081279ba378"> The first log doesn't get a stack because it's logged before DevTools boots up and connects which is unfortunate. The second log already has a stack printed by React (this is on stable) it gets replaced by our object now. The third and following logs don't have a stack and get one appended. I only turn the stack into an error object if it matches what we would emit from DevTools anyway. Otherwise we assume it's not React. Since I had to change the format slightly to make this work, I first normalize the stack slightly before doing a comparison since it won't be 1:1.
99 lines
2.4 KiB
JavaScript
99 lines
2.4 KiB
JavaScript
const {resolve} = require('path');
|
|
const Webpack = require('webpack');
|
|
const {
|
|
GITHUB_URL,
|
|
getVersionString,
|
|
} = require('react-devtools-extensions/utils');
|
|
const {resolveFeatureFlags} = require('react-devtools-shared/buildUtils');
|
|
|
|
const NODE_ENV = process.env.NODE_ENV;
|
|
if (!NODE_ENV) {
|
|
console.error('NODE_ENV not set');
|
|
process.exit(1);
|
|
}
|
|
|
|
const builtModulesDir = resolve(
|
|
__dirname,
|
|
'..',
|
|
'..',
|
|
'build',
|
|
'oss-experimental',
|
|
);
|
|
|
|
const __DEV__ = NODE_ENV === 'development';
|
|
|
|
const DEVTOOLS_VERSION = getVersionString();
|
|
|
|
const featureFlagTarget = process.env.FEATURE_FLAG_TARGET || 'core/backend-oss';
|
|
|
|
// This targets RN/Hermes.
|
|
process.env.BABEL_CONFIG_ADDITIONAL_TARGETS = JSON.stringify({
|
|
ie: '11',
|
|
});
|
|
|
|
module.exports = {
|
|
mode: __DEV__ ? 'development' : 'production',
|
|
devtool: __DEV__ ? 'eval-cheap-module-source-map' : 'source-map',
|
|
entry: {
|
|
backend: './src/backend.js',
|
|
},
|
|
output: {
|
|
path: __dirname + '/dist',
|
|
filename: '[name].js',
|
|
|
|
// This name is important; standalone references it in order to connect.
|
|
library: 'ReactDevToolsBackend',
|
|
libraryTarget: 'umd',
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
react: resolve(builtModulesDir, 'react'),
|
|
'react-debug-tools': resolve(builtModulesDir, 'react-debug-tools'),
|
|
'react-devtools-feature-flags': resolveFeatureFlags(featureFlagTarget),
|
|
'react-dom': resolve(builtModulesDir, 'react-dom'),
|
|
'react-is': resolve(builtModulesDir, 'react-is'),
|
|
scheduler: resolve(builtModulesDir, 'scheduler'),
|
|
},
|
|
},
|
|
node: {
|
|
global: false,
|
|
},
|
|
plugins: [
|
|
new Webpack.ProvidePlugin({
|
|
process: 'process/browser',
|
|
}),
|
|
new Webpack.DefinePlugin({
|
|
__DEV__,
|
|
__EXPERIMENTAL__: true,
|
|
__EXTENSION__: false,
|
|
__PROFILE__: false,
|
|
__TEST__: NODE_ENV === 'test',
|
|
__IS_FIREFOX__: false,
|
|
__IS_CHROME__: false,
|
|
__IS_EDGE__: false,
|
|
'process.env.DEVTOOLS_PACKAGE': `"react-devtools-core"`,
|
|
'process.env.DEVTOOLS_VERSION': `"${DEVTOOLS_VERSION}"`,
|
|
'process.env.GITHUB_URL': `"${GITHUB_URL}"`,
|
|
}),
|
|
],
|
|
optimization: {
|
|
minimize: false,
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.js$/,
|
|
loader: 'babel-loader',
|
|
options: {
|
|
configFile: resolve(
|
|
__dirname,
|
|
'..',
|
|
'react-devtools-shared',
|
|
'babel.config.js',
|
|
),
|
|
},
|
|
},
|
|
],
|
|
},
|
|
};
|