Skip to content

First HMR update includes file that did not change #10174

@yyx990803

Description

@yyx990803

Bug report

What is the current behavior?

First HMR update after dev server start includes files that did not change, when the following conditions are met:

  • File A is imported in the entry file;
  • File A contains a wildcard export from file B;
  • File B in turn contains a wildcard export from file C, and also has additional named exports of its own.

If the current behavior is a bug, please provide the steps to reproduce.

Repro link

With the following dependency graph:

// deps/a.js
export * from './b'

// deps/b.js
export * from './c'
export function b() {} // <-- this extra export is needed to reproduce

// deps/c.js
export function c() {}

And in index.js:

import { c } from './deps/a'

// other parts of the codebase, unrelated to deps
import { hot } from './hot'
hot()
module.hot.accept('./hot', () => {
  hot()
})

After starting WDS and edit ./hot.js, the first HMR update somehow includes ./deps/a (although it never changed), and causes the page to do a full reload. However, this only happens for the first update. After the first HMR-caused page reload, HRM starts to function properly.

Directly importing from ./dps/b or ./dpes/c both work as expected. Removing the named export in ./deps/b also works as expected.

What is the expected behavior?

First HMR update should not include deps/a.js (which is not hot-accepted, thus causing the entire page to reload)

Other relevant information:
webpack version: v4.41.4 & v5.0.0-beta.10
Node.js version: v12.13.1
Operating System: macOS 10.14.6
Additional tools: N/A

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