Search code examples
webpackwebpack-cliwebpack-5

Why do Webpack 5 return a non-zero error code for performance hints?


Background

I've just upgraded a project from Webpack 4 to Webpack 5. With the new version, it seems as if any performance hints (warnings) will make Webpack CLI to return a non-zero error code 1 when exiting the process.

This breaks my production builds, where I use npm run --silent to execute the webpack script.

Workaround

If I remove performance hints in config file, no error code will be returned.

performance: {
   hints: false, //"warning",
},

Question

In Webpack 4, these hints did not return any error code.

How can I enable the performance hints as warnings in Webpack 5 - without getting a non-zero exit code?


Solution

  • This seems to have been due to a bug in the beta builds of Webpack 5. With the final 5.0 version a non-zero exit code will be produced for warnings.