Skip to content

Warn about duplicate dependencies #1866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/react-scripts/config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var HtmlWebpackPlugin = require('html-webpack-plugin');
var CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
var InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
var WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
var DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin');
var getClientEnvironment = require('./env');
var paths = require('./paths');

Expand Down Expand Up @@ -228,6 +229,9 @@ module.exports = {
// a plugin that prints an error when you attempt to do this.
// See https://github.com/facebookincubator/create-react-app/issues/240
new CaseSensitivePathsPlugin(),
// Warn about duplicate dependencies.
// See https://github.com/facebookincubator/create-react-app/issues/1844
new DuplicatePackageCheckerPlugin(),
// If you require a missing module and then `npm install` it, you still have
// to restart the development server for Webpack to discover it. This plugin
// makes the discovery automatic so you don't have to restart.
Expand Down
4 changes: 4 additions & 0 deletions packages/react-scripts/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var ManifestPlugin = require('webpack-manifest-plugin');
var InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
var DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin');
var paths = require('./paths');
var getClientEnvironment = require('./env');

Expand Down Expand Up @@ -263,6 +264,9 @@ module.exports = {
screw_ie8: true
}
}),
// Warn about duplicate dependencies.
// See https://github.com/facebookincubator/create-react-app/issues/1844
new DuplicatePackageCheckerPlugin(),
// Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
new ExtractTextPlugin(cssFilename),
// Generate a manifest file which contains a mapping of all asset filenames
Expand Down
1 change: 1 addition & 0 deletions packages/react-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"css-loader": "0.26.1",
"detect-port": "1.1.1",
"dotenv": "2.0.0",
"duplicate-package-checker-webpack-plugin": "^1.2.4",
"eslint": "3.16.1",
"eslint-config-react-app": "^0.6.2",
"eslint-loader": "1.6.0",
Expand Down
24 changes: 19 additions & 5 deletions packages/react-scripts/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ function printErrors(summary, errors) {
});
}

function printWarnings(summary, warnings) {
console.log(chalk.yellow(summary));
console.log();
warnings.forEach(err => {
console.log(err.message || err);
console.log();
});
}

// Create the production build and print the deployment instructions.
function build(previousFileSizes) {
console.log('Creating an optimized production build...');
Expand All @@ -77,12 +86,17 @@ function build(previousFileSizes) {
}

if (process.env.CI && stats.compilation.warnings.length) {
printErrors('Failed to compile. When process.env.CI = true, warnings are treated as failures. Most CI servers set this automatically.', stats.compilation.warnings);
process.exit(1);
}
printErrors('Failed to compile. When process.env.CI = true, warnings are treated as failures. Most CI servers set this automatically.', stats.compilation.warnings);
process.exit(1);
}

console.log(chalk.green('Compiled successfully.'));
console.log();
if (stats.compilation.warnings.length) {
console.log();
printWarnings('Compiled with warnings.', stats.compilation.warnings);
} else {
console.log(chalk.green('Compiled successfully.'));
console.log();
}

console.log('File sizes after gzip:');
console.log();
Expand Down