-
-
Notifications
You must be signed in to change notification settings - Fork 272
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: handle circular init shared #2876
Conversation
🦋 Changeset detectedLatest commit: a714fc8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 36 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 focuses on fixing a bug related to the handling of circular initialization of shared dependencies in the federation runtime. The key changes include:
- Introduction of a new
InitTokens
type and aCallFrom
type to better manage the initialization process of shared modules. - Modifications to the
initializeSharing
method of theFederationHost
class to accept additional options, including aninitScope
and afrom
parameter, to handle circular dependencies. - Updates to the
loadRemote
method to accept an optionalfrom
parameter of typeCallFrom
to specify the origin of the remote module loading request. - Enhancements to the
SharedHandler
class to introduce new propertiesinitTokens
andinitScope
to track and manage the initialization process of shared modules, and modifications to theinit
function of remote modules to pass theinitScope
parameter.
These changes aim to improve the robustness and reliability of the federation runtime's handling of shared dependencies, especially in scenarios where circular dependencies may arise.
File Summaries
File | Summary |
---|---|
packages/runtime/src/core.ts | The code changes introduce a new InitTokens type and a CallFrom type, and update the initializeSharing method of the FederationHost class to accept additional options, including an initScope and a from parameter. These changes appear to be part of a fix for handling circular initialization of shared dependencies. |
packages/runtime/src/remote/index.ts | The code changes introduce a new type called CallFrom to handle the source of the remote module loading, whether it's from the build or runtime. Additionally, the loadRemote method now accepts an optional from parameter of type CallFrom to specify the origin of the remote module loading request. |
packages/runtime/src/shared/index.ts | The code changes introduce a mechanism to handle circular dependencies in the initialization of shared modules. The key modifications are: |
- Addition of new properties
initTokens
andinitScope
to theSharedHandler
class to track and manage the initialization process of shared modules. - Modification of the
initializeSharing
method to check for circular dependencies and avoid re-initializing shared modules that are already in the process of being initialized. - The
init
function of remote modules is now called with theinitScope
parameter to provide information about the current initialization context. |
| packages/runtime/src/type/config.ts | The code changes introduce a new typeInitTokens
to represent a record of tokens with their associated data, and modify theInitScope
type to be an array ofInitTokens
. Additionally, a new typeCallFrom
is introduced to represent the context in which the remote entry is being initialized, either 'build' or 'runtime'. |
@2heal1 - don't mind me :) just testing out some changes |
@squadronai review |
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: 0
Configuration
Squadron Mode: essential
Commits Reviewed
b90fa7ded8786022d900081dd7c871f317c5e4b9...a714fc84999f44a49dbf6e31b127ed6084df825d
Files Reviewed
- packages/runtime/src/core.ts
- packages/runtime/src/remote/index.ts
- packages/runtime/src/shared/index.ts
- packages/runtime/src/type/config.ts
Files Ignored
These files were ignored due to the filter in the squadron.yaml file.
- .changeset/itchy-ducks-crash.md
- packages/webpack-bundler-runtime/src/initializeSharing.ts
Description
handle circular init shared
Related Issue
idonava/base-mf-app#2
Types of changes
Checklist