-
-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(runtime): use wrapper global instead of using globalThis directly #3179
Conversation
🦋 Changeset detectedLatest commit: 492324d The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
This pull request addresses an issue with the module federation runtime, ensuring that it can be used in legacy browsers that do not support the globalThis
feature. The changes introduce a new CurrentGlobal
variable that is used to access the global object, which is either globalThis
or window
depending on the environment. This change allows the runtime to work as expected in a wider range of browser environments.
The key changes include:
- Updating the
global.ts
file to introduce theCurrentGlobal
variable and modifying various functions that interact with the global object to use this variable instead ofglobalThis
directly. - Updating the
remote/index.ts
file to use theCurrentGlobal
utility instead of directly accessingglobalThis
, further improving compatibility and support for legacy browsers. - Adding tests to cover the changes and ensure that all new and existing tests pass.
- Updating the documentation to reflect the changes.
Overall, this pull request enhances the module federation runtime's compatibility and support for a wider range of browser environments, making it more accessible and usable for developers.
File Summaries
File | Summary |
---|---|
packages/runtime/src/global.ts | The code changes introduce a new CurrentGlobal variable that is used to access the global object, which is either globalThis or window depending on the environment. This change ensures that the runtime can be used in legacy browsers that do not support globalThis . The changes also include updates to various functions that interact with the global object, such as definePropertyGlobalVal , includeOwnProperty , and setGlobalDefaultVal , to use the CurrentGlobal variable instead of globalThis directly. |
packages/runtime/src/remote/index.ts | The code changes introduce a modification to use the CurrentGlobal utility instead of directly accessing globalThis to ensure legacy browsers can use the module federation runtime as expected. This change aims to provide better compatibility and support for a wider range of browser environments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incremental Review
Comments posted: 8
Configuration
Squadron Mode: essential
Commits Reviewed
849ef9c32fe97ff45b7dceba68903fce5c5326cd...bd86a06c3f318c988449516bc7e94876f9550cb1
Files Reviewed
- packages/runtime/src/global.ts
- packages/runtime/src/remote/index.ts
Files Ignored
These files were ignored due to the filter in the squadron.yaml file.
- .changeset/dry-bats-design.md
9a82587
to
492324d
Compare
Description
use wrapper global instead of using globalThis directly to ensure legacy browser can use mf runtime as expected
Related Issue
web-infra-dev/rsbuild#3593
Types of changes
Checklist