Webpack-dev-server: v4.0.0-head: No Overlay on error

Created on 2 Dec 2020  路  12Comments  路  Source: webpack/webpack-dev-server

Code

Regarding this commit https://github.com/webpack/webpack-dev-server/commit/763cde106056f342dcc30b607308b378c479cdaa

npm install github:webpack/webpack-dev-server#763cde106056f342dcc30b607308b378c479cdaa --save-dev

This in source

  console.logz('i am wrong');

will lead to this in browser console

index.js:13 Uncaught TypeError: console.logz is not a function
    at Module../src/index.js (index.js:13)
    at __webpack_require__ (bootstrap:21)
    at startup:8
    at startup:8

but no visible overlay.

// ----------------
// BASE CONFIG
let config = {
  // ...

  infrastructureLogging: {
    level: 'info'
  },
  stats: 'normal',

  // ...
};

// ----------------
// WEBPACK DEVSERVER CONFIG
config.devServer = {

  // ...
  client: {

    // ...

    overlay: {
      warnings: false,
      errors: true
    }
  },

  // ...

};

module.exports = config;

Expected Behavior

Overlay visible in HTML

Actual Behavior

No overlay in HTML.

For Bugs; How can we reproduce the behavior?

Just add console.logz('i am wrong');

For Features; What is the motivation and/or use-case for the feature?

4 (nice to have) minor 4 (inconvenient) feature

Most helpful comment

Let's keep open, I think we can implement this as feature under flag, i don't see many problems with this

All 12 comments

Sorry, it was never supported, it is feature, I am felling it is unnecessary, overlay for webpack bundling problems, not for runtime problems, you have dev tools with more abilities for this

Hmm.

is not a function errors do not produce overlay.

array.findz();
console.logz();
thisFunctionDoesNotExist();

However stuff like this will

  // do expression test with too many oooos
  let doValue = doooo {
    const one = 1;
    one + 1;
  };
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: hidden/webpacktest-07-lint/src/index.js: Unexpected token, expected ";" (26:22)

  24 | const myArrowFunction = () => {
  25 |   // do expression test
> 26 |   let doValue = doooo {
     |                       ^
  27 |     const one = 1;
  28 |     one + 1;
  29 |   };

note that is not a function errors do not produce overlay even when babel-loader is disabled.

Sorry, it was never supported, it is feature, I am felling it is unnecessary, overlay for webpack bundling problems, not for runtime problems, you have dev tools with more abilities for this

given that a specific pull was done for it, wanted to try to help to test it :)

Maybe remove the feature altogether. Or if it is used in config by the coder, produce a warning of "depreciated" or smth.

It is very useful when you write something like CSS, or when you use babel, you will see original code instead of generated

It is very useful when you write something like CSS, or when you use babel, you will see original code instead of generated

Damn, my bad, as docs say

Shows a full-screen overlay in the browser when there are compiler errors or warnings.

Sorry.

Suggesting addition for the docs

Shows a full-screen overlay in the browser when there are COMPILER errors or warnings.

馃槃

Closing.

Let's keep open, I think we can implement this as feature under flag, i don't see many problems with this

Reopening.

Hi @alexander-akait, @kroko
Seems like the issue still there.
Initially I have wait for fix #2786 and it is fixed. I see the fix is merged into v4 that's why I decided to update dev server.
Currently I using:
"webpack": "^5.9.0",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "4.0.0-beta.0"

I can see error like this:
image

and this case triggered "overlay" for webpack-dev-server:v3.11 but not for v4.beta

I have investigated a bit, and may say that it is simply ignore option from configuration file.
If I manually modify file "node_moduleswebpack-dev-serverclientdefaultindex.js"
change:
useWarningOverlay: false,
useErrorOverlay: false,
to be
useWarningOverlay: true,
useErrorOverlay: true,

then everything worked as expected.
Seems like onSocketMessage->overlay method is not executed at all some-why.

@Xrumet it was marked to be looked in future as feature by @alexander-akait.

Wantend to suggest you to not use 4.0.0-beta.0 but some newer commit as things are getting fixed. Just beware that as of https://github.com/webpack/webpack-dev-server/commit/763cde106056f342dcc30b607308b378c479cdaa overlay key has to be under client.

// ----------------
// WEBPACK DEVSERVER CONFIG
config.devServer = {

  // ...
  client: {

    // ...

    overlay: {
      warnings: false,
      errors: true
    }
  },

  // ...

};

module.exports = config;

Ohh, OK, Thanks! Got it... @kroko, I have checked commit you provided - works well for me. Also checked latest master - there is another issue, will try to report it or prepare pull request.
Seems like - all I need to do is wait for next beta or release. Btw, do we know release date? I didn't found it... (

I just tried the latest master and the overlay is working great for me. I'm glad this feature was added, I've previously used it on another site using webpack middleware and it's much easier to read than the console.
Is there a way to customize the overlay settings/colors? I'd like to change the font face and size.

client: {
overlay: {
warnings: false,
errors: true
}
},

Thanks a lot for this @kroko, this fixed it for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jack-Works picture Jack-Works  路  3Comments

gimmi picture gimmi  路  3Comments

nikirossi picture nikirossi  路  3Comments

uMaxmaxmaximus picture uMaxmaxmaximus  路  3Comments

adiachenko picture adiachenko  路  3Comments