Skip to content

Static watch is turned on by default - may cause slowdown #3725

@natocTo

Description

@natocTo
  • This is a bug (maybe?)
  • This is a modification request

After upgrading to Webpack 5 and webpack-dev-server, my yarn start script take 3 times longer then with Webpack 4. I always returned back to old Webpack. But now I probably found a error which cause such a slowdown.

Probably problematics code:
https://github.com/webpack/webpack-dev-server/blob/master/lib/Server.js#L1017

Expected Behavior

No code is watched (I think same as in Webpack 4 by default)

Actual Behavior

staticOption.watch is actualy an empty object (https://github.com/webpack/webpack-dev-server/blob/master/lib/Server.js#L182) so the condition passes, then webpack-dev-server try to watch the whole project (if you have static directory set to root - even your node-modules are watched). It takes so much time in a larger project.

Workaround Code

devServer: { static: { watch: false } }

If you set watch to false, no empty object will be used and your bundle will be much faster (280s -> 80s for me, Webpack v4 120s).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions