friendly-errors-webpack-plugin icon indicating copy to clipboard operation
friendly-errors-webpack-plugin copied to clipboard

Blank error when only webpackError property populated

Open cjhewett opened this issue 6 years ago • 0 comments

If all the properties of the webpackError object are empty apart from webpackError property friendly-errors-webpack-plugin outputs nothing apart from the red word "Error".

I have the following webpackError outputted from the plugin: html-webpack-plugin:

{
  message: undefined,
  file: undefined,
  origin: '',
  name: undefined,
  severity: 0,
  webpackError: '  Error: Child compilation failed:\n' +
    "  Module not found: Error: Can't resolve '../foobar.html' in 'C:\\foobar':\n" +
    '  - compiler.js:79 \n' +
    '    [v1]/[html-webpack-plugin]/lib/compiler.js:79:16\n',
  originalStack: []
}

Actual Output: Error:

Expected Output: Error: Error: Child compilation failed Module not found: Error: Can't resolve '../foobar... etc.

As a userland fix I have added the following additionalTransformers to my config options:

additionalTransformers: [
  (webpackError) => {
    if (typeof webpackError.message === 'undefined') {
      webpackError.message = webpackError.webpackError;
    }
    return webpackError;
  },
],

cjhewett avatar Nov 22 '19 10:11 cjhewett