core icon indicating copy to clipboard operation
core copied to clipboard

Hot update fails after connecting to the webpack version of the module federation plugin

Open codewizardTM opened this issue 9 months ago • 5 comments

Describe the bug

After using the @module-federation/enhanced plugin, I found that hot update failed.

Image

I checked issuse and found that someone mentioned this problem before, but it was for rspack. I also found someone raised this issue in the issue of webpack-dev-server

https://github.com/webpack/webpack/issues/11182

Reproduction

https://codesandbox.io/p/devbox/zai-xian-dai-ma-bian-ji-qi-forked-hr4kpz?migrateFrom=jhptvx

Used Package Manager

pnpm

System Info

macos:Sequoia 15.3.1
chrome:133.0.6943.143

Validations

codewizardTM avatar Mar 06 '25 10:03 codewizardTM

ensure html plugin excludes its own remote entry chunk from being added to the html scripts otherwise 2 runtimes will collide and the hot update is injected into the wrong runtime.

ScriptedAlchemy avatar Mar 11 '25 17:03 ScriptedAlchemy

ensure html plugin excludes its own remote entry chunk from being added to the html scripts otherwise 2 runtimes will collide and the hot update is injected into the wrong runtime.

I used the excludeChunks option in html-webpack-plugin to exclude remoteEntry, but hot updates still don't work. Moreover, my project is a remote (a producer) and does not consume resources from other projects.

codewizardTM avatar Mar 25 '25 06:03 codewizardTM

Can you provide a repo

ScriptedAlchemy avatar Mar 25 '25 20:03 ScriptedAlchemy

Can you provide a repo

Of course, I'd be happy to. I will give you a compressed package of the project. I originally wanted to provide an online link, but CodeSandbox is not working well. Please kindly download this project compressed package. Don't worry, it's absolutely safe. Run the pnpm dev command, modify the file contents, and you will notice that the console prints logs indicating that hot updates have failed.

sandbox.zip

codewizardTM avatar Mar 26 '25 03:03 codewizardTM

You need to add the chunk’s file name to excludeChunks.

new HtmlWebpackPlugin({
  excludeChunks: ["webpack_app"],
});

WillowRyu avatar Mar 27 '25 16:03 WillowRyu

You need to add the chunk’s file name to excludeChunks.

new HtmlWebpackPlugin({
  excludeChunks: ["webpack_app"],
});

I've already tried it, but it doesn't work.

codewizardTM avatar Mar 28 '25 01:03 codewizardTM

Stale issue message

github-actions[bot] avatar May 27 '25 15:05 github-actions[bot]

@ScriptedAlchemy Is there any progress, or did I miss some configuration?

codewizardTM avatar May 28 '25 02:05 codewizardTM

Stale issue message

github-actions[bot] avatar Jul 28 '25 15:07 github-actions[bot]

does host use its own remote somewhere (2 runtimes from same build on page)

ScriptedAlchemy avatar Aug 03 '25 01:08 ScriptedAlchemy