-
Notifications
You must be signed in to change notification settings - Fork 95
Description
Describe the bug
When sharing react and react-dom dependencies in module federation with module-federation-vite, the shared dependencies fail to load in Safari and are causing the app to crash with errors like these, with the react dependency being undefined when it is accessed:
- Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'f$1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED')
- ReferenceError: Cannot access 'default' before initialization.
(anonymous function) — virtualExposes-Di8U-Ssu.js:8
Tested with
react / react-dom: 18.3.0 / 18.3.1
Safari: 26.2 on macOS
The issue can't be reproduced with rspack so it seems to be specific to module-federation-vite.
We found that adding vite-plugin-top-level-await (https://www.npmjs.com/package/vite-plugin-top-level-await) fixes the issue, so it seems to be related to async initialization of the shared dependencies.
I created a minimal repo to reproduce the issue
repo: https://github.com/crijke/module-federation-vite-example
branch: demo/safari-shared-dependencies-mfe-bridge
Version
6.2.1
Reproduction
https://github.com/crijke/module-federation-vite-example
Relevant log output
- Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'f$1.\_\_SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED')
- ReferenceError: Cannot access 'default' before initialization.
(anonymous function) — virtualExposes-Di8U-Ssu.js:8Validations
- Read the docs.
- Read the common issues list.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- The provided reproduction is a minimal reproducible example of the bug.