Coder Social home page Coder Social logo

Comments (4)

see365 avatar see365 commented on July 22, 2024

the same issue

from friendly-errors-webpack-plugin.

christophehurpeau avatar christophehurpeau commented on July 22, 2024

Can you check if it is still the case with 2.0.0-beta.1 ?

from friendly-errors-webpack-plugin.

Lyrkan avatar Lyrkan commented on July 22, 2024

Hi @christophehurpeau,

We had a similar issue opened on the Webpack Encore repository (symfony/webpack-encore#593) that I can also reproduce using our master branch (that targets 2.0.0-beta.1).

When that happens stats.hasWarning() returns true so it goes into the following if:

if (hasWarnings) {
this.displayErrors(extractErrorsFromStats(stats, 'warnings'), 'warning');
}

But stats.compilation.warnings returns an empty array here:

return stats.compilation[type];

Here is a repro provided by @uturnr if you want to take a look: https://github.com/uturnr/webpack-encore-repro-issue-593

from friendly-errors-webpack-plugin.

Lyrkan avatar Lyrkan commented on July 22, 2024

After looking at that issue a bit more I think it happens because the extractErrorsFromStats() function stops at the first compilation object instead of also looking in its children.

I tried with the following code and now get WARNING Compiled with 1 warnings, but still no warning message for some reason (it may be another issue though)...

Edit: Nevermind, it works fine, I had a small issue in my code!
I'll open a PR if I get the time to update the tests :)

function extractErrorsFromStats(stats, type) {
  if (isMultiStats(stats)) {
    const errors = stats.stats
      .reduce((errors, stats) => errors.concat(extractErrorsFromStats(stats, type)), []);
    // Dedupe to avoid showing the same error many times when multiple
    // compilers depend on the same module.
    return uniqueBy(errors, error => error.message);
  }

  const findErrorsRecursive = (compilation) => {
    const errors = compilation[type];
    if (compilation.children) {
      for (const child of compilation.children) {
        errors.push(...findErrorsRecursive(child));
      }
    }

    return uniqueBy(errors, error => error.message);
  };

  return findErrorsRecursive(stats.compilation);
}

image

from friendly-errors-webpack-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.