-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
feat(bridge-plugin): support disable default alias setting in bridge #3130
Changes from 1 commit
a685998
c881aa9
0694c44
b004579
9c95487
ce35f42
6342df4
4c72112
aa7e3ae
2172e1c
0396853
918c636
a2573c6
76427c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -49,7 +49,10 @@ export default class ModuleFederationPlugin implements WebpackPluginInstance { | |||||||||||||||||||||||||
'@module-federation/bridge-react', | ||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||
// Check whether react exists | ||||||||||||||||||||||||||
if (fs.existsSync(reactPath)) { | ||||||||||||||||||||||||||
if ( | ||||||||||||||||||||||||||
(fs.existsSync(reactPath) && !this._options?.bridge) || | ||||||||||||||||||||||||||
!this._options.bridge?.disableAlias | ||||||||||||||||||||||||||
) { | ||||||||||||||||||||||||||
danpeen marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
new ReactBridgePlugin({ | ||||||||||||||||||||||||||
moduleFederationOptions: this._options, | ||||||||||||||||||||||||||
}).apply(compiler); | ||||||||||||||||||||||||||
danpeen marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
56
to
58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ReactBridgePlugin configuration is hardcoded without any validation of the moduleFederationOptions. Consider validating the options before passing them to ensure they meet the expected format:
Suggested change
This adds a basic validation layer to prevent potential runtime issues from invalid configurations. |
||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -127,7 +127,10 @@ export class ModuleFederationPlugin implements RspackPluginInstance { | |||||||||||||||
); | ||||||||||||||||
|
||||||||||||||||
// Check whether react exists | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment "Check whether react exists" is not fully accurate as it's checking for both React existence and bridge configuration. A more descriptive comment would be:
Suggested change
|
||||||||||||||||
if (fs.existsSync(reactPath)) { | ||||||||||||||||
if ( | ||||||||||||||||
(fs.existsSync(reactPath) && !options?.bridge) || | ||||||||||||||||
!options.bridge?.disableAlias | ||||||||||||||||
) { | ||||||||||||||||
danpeen marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||
new ReactBridgePlugin({ | ||||||||||||||||
moduleFederationOptions: this._options, | ||||||||||||||||
}).apply(compiler); | ||||||||||||||||
danpeen marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
134
to
136
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ReactBridgePlugin instantiation is done directly without storing the instance. For better plugin lifecycle management and potential cleanup, consider storing the plugin instance:
Suggested change
This approach provides better control over the plugin instance and makes it easier to manage its lifecycle if needed in the future. |
||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -237,6 +237,9 @@ export interface ModuleFederationPluginOptions { | |||||||||||||||||||||||||||
experiments?: { | ||||||||||||||||||||||||||||
federationRuntime?: false | 'hoisted'; | ||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||
Comment on lines
237
to
239
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||||||||||||||||||||
bridge?: { | ||||||||||||||||||||||||||||
disableAlias?: boolean; | ||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||
danpeen marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||
* Modules that should be exposed by this container. Property names are used as public paths. | ||||||||||||||||||||||||||||
|
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.
Consider adding a comment explaining what the '@module-federation/bridge-react' path represents and why it's being checked. This would improve code maintainability and make the purpose clearer: