-
-
Notifications
You must be signed in to change notification settings - Fork 242
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 all commits
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@module-federation/enhanced': patch | ||
'@module-federation/rspack': patch | ||
'@module-federation/sdk': patch | ||
--- | ||
|
||
feat: support disable default alias setting in bridge |
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) | ||||||||||||||||||||||||||
) { | ||||||||||||||||||||||||||
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) | ||||||||||||||||
) { | ||||||||||||||||
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,14 @@ 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?: { | ||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||
* Disables the default alias setting in the bridge. | ||||||||||||||||||||||||||||
* When true, users must manually handle basename through root component props. | ||||||||||||||||||||||||||||
Comment on lines
+242
to
+243
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 JSDoc comment is incomplete and cut off mid-sentence. Complete the documentation to properly explain the functionality:
Suggested change
|
||||||||||||||||||||||||||||
* @default false | ||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||
disableAlias?: boolean; | ||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||
* 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: