Skip to content

Commit 991b092

Browse files
authored
Use production React version for bundled overlay (#3267)
* Use production React version * We cannot strip our own checks if production * Keep the sourcemap during minify * Prevent devtools pollution * Add some comments * sigh
1 parent 9ce144e commit 991b092

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

packages/react-error-overlay/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
],
2828
"author": "Joe Haddad <[email protected]>",
2929
"files": [
30-
"lib/",
31-
"middleware.js"
30+
"lib/index.js"
3231
],
3332
"devDependencies": {
3433
"anser": "1.4.1",

packages/react-error-overlay/webpack.config.iframe.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
'use strict';
88

99
const path = require('path');
10+
const webpack = require('webpack');
1011

1112
module.exports = {
12-
devtool: 'cheap-module-source-map',
1313
entry: './src/iframeScript.js',
1414
output: {
1515
path: path.join(__dirname, './lib'),
@@ -24,4 +24,26 @@ module.exports = {
2424
},
2525
],
2626
},
27+
plugins: [
28+
new webpack.DefinePlugin({
29+
// We set process.env.NODE_ENV to 'production' so that React is built
30+
// in production mode.
31+
'process.env': { NODE_ENV: '"production"' },
32+
// This prevents our bundled React from accidentally hijacking devtools.
33+
__REACT_DEVTOOLS_GLOBAL_HOOK__:
34+
'__REACT_ERROR_OVERLAY_GLOBAL_HOOK_NOOP__',
35+
}),
36+
// This code is embedded as a string, so it would never be optimized
37+
// elsewhere.
38+
new webpack.optimize.UglifyJsPlugin({
39+
compress: {
40+
warnings: false,
41+
comparisons: false,
42+
},
43+
output: {
44+
comments: false,
45+
ascii_only: false,
46+
},
47+
}),
48+
],
2749
};

packages/react-error-overlay/webpack.config.js

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
const path = require('path');
1010

1111
module.exports = {
12-
devtool: 'cheap-module-source-map',
1312
entry: './src/index.js',
1413
output: {
1514
path: path.join(__dirname, './lib'),

0 commit comments

Comments
 (0)