Skip to content

Commit

Permalink
Use production React version for bundled overlay (#3267)
Browse files Browse the repository at this point in the history
* Use production React version

* We cannot strip our own checks if production

* Keep the sourcemap during minify

* Prevent devtools pollution

* Add some comments

* sigh
  • Loading branch information
Timer authored Oct 11, 2017
1 parent 9ce144e commit 991b092
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
3 changes: 1 addition & 2 deletions packages/react-error-overlay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
],
"author": "Joe Haddad <timer150@gmail.com>",
"files": [
"lib/",
"middleware.js"
"lib/index.js"
],
"devDependencies": {
"anser": "1.4.1",
Expand Down
24 changes: 23 additions & 1 deletion packages/react-error-overlay/webpack.config.iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
'use strict';

const path = require('path');
const webpack = require('webpack');

module.exports = {
devtool: 'cheap-module-source-map',
entry: './src/iframeScript.js',
output: {
path: path.join(__dirname, './lib'),
Expand All @@ -24,4 +24,26 @@ module.exports = {
},
],
},
plugins: [
new webpack.DefinePlugin({
// We set process.env.NODE_ENV to 'production' so that React is built
// in production mode.
'process.env': { NODE_ENV: '"production"' },
// This prevents our bundled React from accidentally hijacking devtools.
__REACT_DEVTOOLS_GLOBAL_HOOK__:
'__REACT_ERROR_OVERLAY_GLOBAL_HOOK_NOOP__',
}),
// This code is embedded as a string, so it would never be optimized
// elsewhere.
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
comparisons: false,
},
output: {
comments: false,
ascii_only: false,
},
}),
],
};
1 change: 0 additions & 1 deletion packages/react-error-overlay/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
const path = require('path');

module.exports = {
devtool: 'cheap-module-source-map',
entry: './src/index.js',
output: {
path: path.join(__dirname, './lib'),
Expand Down

0 comments on commit 991b092

Please sign in to comment.