From dcac337095edd8dfa6d39a60ee687dc2ac07c0f2 Mon Sep 17 00:00:00 2001 From: Tom Vincent Date: Tue, 6 Jun 2017 20:06:06 +0100 Subject: [PATCH] Remove module field in production webpack config This crops up in the form of uglify errors during a production build, e.g. #2236, #2433, #2475. The suggestion there is to transpile deps down to ES5 and/or remove `module`. However, `module` is there specifically to indicate ES module support, which uglify doesn't support, so ask webpack not to resolve it. --- packages/react-scripts/config/webpack.config.prod.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 5943c14502c..93595635ad7 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -115,6 +115,12 @@ module.exports = { // Make sure your source files are compiled, as they will not be processed in any way. new ModuleScopePlugin(paths.appSrc), ], + // webpack includes 'module' by default. However, this corresponds to ES6+ modules, + // which are unsupported by uglify. Should be reverted if/when ES6+ is targeted and/or + // uglify-es used, see: + // https://webpack.js.org/configuration/resolve/#resolve-mainfields + // https://github.com/facebookincubator/create-react-app/issues/2108 + mainFields: ['browser', 'main'], }, module: { strictExportPresence: true,