From 1055214fbb767e53c0d11a0e8b87c44f3f5f46d9 Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Wed, 12 Sep 2018 22:47:33 -0500 Subject: [PATCH] fix: prioritize main over module in webpack config --- packages/react-scripts/config/webpack.config.dev.js | 3 +++ packages/react-scripts/config/webpack.config.prod.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index db371dda6e8..a72aa0b265f 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -137,6 +137,9 @@ module.exports = { // It is guaranteed to exist because we tweak it in `env.js` process.env.NODE_PATH.split(path.delimiter).filter(Boolean) ), + // Since create-react-app doesn't support all ES6 features in dependencies, + // prefer to load the ES5 instead of the ES6 if a package provides both. + mainFields: ['browser', 'main', 'module'], // These are the reasonable defaults supported by the Node ecosystem. // We also include JSX as a common component filename extension to support // some tools, although we do not recommend using it, see: diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 86869748c66..ac4324e05c9 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -175,6 +175,9 @@ module.exports = { // It is guaranteed to exist because we tweak it in `env.js` process.env.NODE_PATH.split(path.delimiter).filter(Boolean) ), + // Since create-react-app doesn't support all ES6 features in dependencies, + // prefer to load the ES5 over the ES6 if a package provides both. + mainFields: ['browser', 'main', 'module'], // These are the reasonable defaults supported by the Node ecosystem. // We also include JSX as a common component filename extension to support // some tools, although we do not recommend using it, see: