You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using usedExports: true with multiple entrypoints it's possible for the generated conditional imports to be incorrect, causing the application to crash.
In my example, I have a Webpack / rspack application that has multiple entrypoints. Each entrypoint is its own React application, and the root entrypoint is responsible for selecting which one to load at runtime.
Cache groups are configured, so that chunks can be shared between the applications. When using rspack, I've encounter a problem where the bundler is incorrectly identifying an export as being used only by "Application A", but in reality it should be used by both "Application A" and "Application B"
When bundling with Webpack, the code runs both applications without crashing, so I believe this is a bug in rspack.
System Info
System:
OS: macOS 14.6.1
CPU: (10) arm64 Apple M1 Max
Memory: 11.60 GB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.5.0
Yarn: 1.22.21
npm: 9.8.0
pnpm: 9.4.0
Browsers:
Chrome: 131.0.6778.109
Safari: 17.6
npmPackages:
@rspack/cli: ^1.1.5 => 1.1.5
@rspack/core: ^1.1.5 => 1.1.5
Details
When using
usedExports: true
with multiple entrypoints it's possible for the generated conditional imports to be incorrect, causing the application to crash.In my example, I have a Webpack /
rspack
application that has multiple entrypoints. Each entrypoint is its own React application, and the root entrypoint is responsible for selecting which one to load at runtime.Cache groups are configured, so that chunks can be shared between the applications. When using
rspack
, I've encounter a problem where the bundler is incorrectly identifying an export as being used only by "Application A", but in reality it should be used by both "Application A" and "Application B"When bundling with Webpack, the code runs both applications without crashing, so I believe this is a bug in
rspack
.Reproduce link
https://github.com/JohnDaly/rspack-used-exports-repro
Reproduce Steps
pnpm run build
rspack
output withnpx serve ./rspack-dist
Uncaught TypeError: Cannot read properties of undefined (reading 'X')
errorIn the
rspack
output, we see that "Application A" has a runtime ID of "705" and "Application B" has a runtime ID of "525".We can also see that the
Subscription
variable is only initialized for runtime "705" (Application A):https://github.com/JohnDaly/rspack-used-exports-repro/blob/d6b06696de558b67b2c2e7428d650b45e8d93c7d/rspack-dist/redux.js#L413-L416
When trying to run "Application B", the application will crash because it needs access to the
Subscription
variable, but it is not present.The text was updated successfully, but these errors were encountered: