Skip to content

Commit 4eb09e7

Browse files
feat(bridge-plugin): support disable default alias setting in bridge (#3130)
Co-authored-by: squadronai[bot] <170149692+squadronai[bot]@users.noreply.github.com>
1 parent e44d7fa commit 4eb09e7

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

.changeset/mean-squids-repair.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@module-federation/enhanced': patch
3+
'@module-federation/rspack': patch
4+
'@module-federation/sdk': patch
5+
---
6+
7+
feat: support disable default alias setting in bridge

apps/router-demo/router-host-2000/rsbuild.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ export default defineConfig({
3333
path.join(__dirname, './src/runtime-plugin/shared-strategy.ts'),
3434
// path.join(__dirname, './src/runtime-plugin/retry.ts'),
3535
],
36+
// bridge: {
37+
// disableAlias: true,
38+
// },
3639
}),
3740
],
3841
});

packages/enhanced/src/wrapper/ModuleFederationPlugin.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ export default class ModuleFederationPlugin implements WebpackPluginInstance {
4949
'@module-federation/bridge-react',
5050
);
5151
// Check whether react exists
52-
if (fs.existsSync(reactPath)) {
52+
if (
53+
fs.existsSync(reactPath) &&
54+
(!this._options?.bridge || !this._options.bridge.disableAlias)
55+
) {
5356
new ReactBridgePlugin({
5457
moduleFederationOptions: this._options,
5558
}).apply(compiler);

packages/rspack/src/ModuleFederationPlugin.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ export class ModuleFederationPlugin implements RspackPluginInstance {
127127
);
128128

129129
// Check whether react exists
130-
if (fs.existsSync(reactPath)) {
130+
if (
131+
fs.existsSync(reactPath) &&
132+
(!options?.bridge || !options.bridge.disableAlias)
133+
) {
131134
new ReactBridgePlugin({
132135
moduleFederationOptions: this._options,
133136
}).apply(compiler);

packages/sdk/src/types/plugins/ModuleFederationPlugin.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ export interface ModuleFederationPluginOptions {
237237
experiments?: {
238238
federationRuntime?: false | 'hoisted';
239239
};
240+
bridge?: {
241+
/**
242+
* Disables the default alias setting in the bridge.
243+
* When true, users must manually handle basename through root component props.
244+
* @default false
245+
*/
246+
disableAlias?: boolean;
247+
};
240248
}
241249
/**
242250
* Modules that should be exposed by this container. Property names are used as public paths.

0 commit comments

Comments
 (0)