Skip to content

Commit

Permalink
Remove module field in production webpack config
Browse files Browse the repository at this point in the history
This crops up in the form of uglify errors during a production build, e.g. facebook#2236, facebook#2433, facebook#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.
  • Loading branch information
tlvince authored Jun 6, 2017
1 parent dc4ce60 commit dcac337
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/react-scripts/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit dcac337

Please sign in to comment.