Skip to content
This repository has been archived by the owner on Jul 13, 2021. It is now read-only.

warningsFilter is not honoured #94

Closed
OliverJAsh opened this issue Jul 24, 2018 · 8 comments
Closed

warningsFilter is not honoured #94

OliverJAsh opened this issue Jul 24, 2018 · 8 comments
Labels

Comments

@OliverJAsh
Copy link

OliverJAsh commented Jul 24, 2018

  • Operating System: macOS 10.13.5
  • Node Version: 9.8.0
  • NPM Version: 5.10.0
  • webpack Version: 4.12.0
  • webpack-hot-client Version: 4.1.1

Expected Behavior

webpack's stats.warningsFilter should be honoured in the log output of webpack-hot-client.

Actual Behavior

webpack's stats.warningsFilter is not honoured in the log output of webpack-hot-client.

Code

{
  stats: {
    warningsFilter: /export .* was not found in/
  }
}

image

How Do We Reproduce?

Define a stats.warningsFilter and observe the log output.

@shellscape
Copy link
Contributor

stats has no bearing on the output in the browser's development console. Use the logLevel option if you want to change that.

@OliverJAsh
Copy link
Author

I guess we need a similar option to stats.warningsFilter for browser logs? We would like a way to filter the warnings, not hide them completely.

@shellscape
Copy link
Contributor

That would be a lot of unneeded complexity for minutia around displaying logs in the browser. Just keep an eye on your terminal and you'll only see there what you want to see, as webpack-dev-middleware displays output from a compilation based on stats. Adding anything like stats for the browser console in this module is not something likely to happen unless there was a call for it by thousands of users.

@OliverJAsh
Copy link
Author

For context, we are using warningsFilter as recommended by ts-loader. I suspect there are many other users of both ts-loader and webpack-hot-client that are suffering from this. Not sure why we haven't heard from them…

@JounQin
Copy link
Contributor

JounQin commented Sep 20, 2018

It is also needed for Angular project to filter System.import warnings for now.
angular/angular#21560 (comment)

@Benno007
Copy link

@JounQin same here - just came from that ticket, thanks for linking it. We use an angular project using webpack 4 and angular 5, with webpack dev server and we are also seeing 4 of those System.import logs on each page load. Had to up our client-log-level in webpack-dev-server to error only to prevent these errors (from HMR) logging to the browser console.

@lehni
Copy link

lehni commented Oct 27, 2020

The problem with setting logLevel: 'error' is that is also silences all info. It would be nice to hav a way to only disable warnings but keep info and errors.

I thiknk I found a way to hide warnings that doesn't also silence info, by using the following:

send: {
  warnings: false
}

This omits any warnings that are sent through the socket.

@lehni
Copy link

lehni commented Oct 27, 2020

Ok while the above actually works, it turns of the call of reload(). This seems a strange unwanted side-effect of the send.warnings option?

But looking at the code, I understand why it's happening:

lib/socket-server.js:

  if (warnings.length > 0) {
    if (options.send.warnings) {
      send('warnings', { warnings });
    }
  } else {
    send('ok', { hash });
  }

And warnings() is defined as:

lib/client/index.js:

    warnings({ warnings }) {
      log.warn('Warnings while compiling.');
       
      reload();
    },

So not sending warnings also doesn't call reload().

This looks like it would need something like this to work as expected?

  if (warnings.length > 0 && options.send.warnings) {
    send('warnings', { warnings });
  } else {
    send('ok', { hash });
  }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants