[Bug]: When there are multiple entrances, there is a hot update error #10075
-
System InfoSystem: DetailsReproduce linkhttps://github.com/lzxb/rspack-hot-error Reproduce StepsRspack projectSetupInstall the dependencies: pnpm install Get startedStart the dev server: pnpm run dev Build the app for production: pnpm run build |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 8 replies
-
Hello, is there a plan to handle this issue? Or is there any temporary patching method? |
Beta Was this translation helpful? Give feedback.
-
@lzxb it is not a bug, it is how multiple entries work, your configuration is wrong and no need to patch something The answer is here - webpack/webpack-dev-server#5443 (comment) @chenjiahan I think you can close this issue |
Beta Was this translation helpful? Give feedback.
-
@alexander-akait I'm using Rspack's entry and externals to build an importmap-based application. Each entry compiles into an ESM module, and the externals configuration links different exported modules together. This serves as the foundation for building large-scale micro-frontend applications based on ESM. |
Beta Was this translation helpful? Give feedback.
-
This is the simplest example of building an ESM micro-frontend application. |
Beta Was this translation helpful? Give feedback.
-
I created a project at https://github.com/esmnext/esmx and planned to implement it, but got stuck on hot updates for multiple entry points. |
Beta Was this translation helpful? Give feedback.
-
@lzxb Did you read my comments how multiple entries work? You can't use multiple runtimes on the same page |
Beta Was this translation helpful? Give feedback.
-
You mix libraries and applications,
|
Beta Was this translation helpful? Give feedback.
-
Multiple Entry Hot Update Issue in RspackBackgroundTraditionally, Rspack is used to build a single application: // Traditional way: one entry per application
entry: {
main: './src/main.ts'
} However, in our scenario, we need to use Rspack's multiple entry capability to build one application: // Our approach: multiple entries in one application
entry: {
header: './src/header.ts',
content: './src/content.ts',
sidebar: './src/sidebar.ts',
// Shared modules for other micro-frontend projects
components: './src/components/index.ts',
utils: './src/utils/index.ts'
} This multi-entry approach serves two purposes:
For example: <!-- Current application -->
<script type="module" src="/header.js"></script>
<script type="module" src="/content.ts"></script>
<script type="module" src="/sidebar.ts"></script>
<!-- Other micro-frontend projects can import our shared modules -->
<script type="module">
import { Button, Input } from 'app1/components'
import { formatDate } from 'app1/utils'
</script> Issue DescriptionCurrent Rspack hot update mechanism has a limitation: This means within the same application:
SolutionWe need to add entry-level isolation on top of application-level isolation: // Before: application-level isolation
window["webpackHotUpdateApp"]
// After: application + entry dual isolation
window["webpackHotUpdateApp_header"]
window["webpackHotUpdateApp_content"]
window["webpackHotUpdateApp_sidebar"]
window["webpackHotUpdateApp_components"]
window["webpackHotUpdateApp_utils"] This way each entry can:
This improvement is particularly important when:
While this change is small, it's crucial for projects utilizing Rspack's multiple entry capability, especially in a micro-frontend architecture where module sharing is essential. |
Beta Was this translation helpful? Give feedback.
-
This issue has been confirmed and the Rspack team will support runtimeChunk: 'single' + ESM and ESM HMR in future releases. |
Beta Was this translation helpful? Give feedback.
-
I will record the problems encountered by Rspack in building large-scale ESM applications in esmnext/esmx#80 |
Beta Was this translation helpful? Give feedback.
-
@lzxb Please provide your configuration and structure where you have problems, because I really can't understand which problems do you have and trying to solve |
Beta Was this translation helpful? Give feedback.
@lzxb it is not a bug, it is how multiple entries work, your configuration is wrong and no need to patch something
The answer is here - webpack/webpack-dev-server#5443 (comment)
@chenjiahan I think you can close this issue