11import type { CliPlugin , AppTools } from '@modern-js/app-tools' ;
2- import {
3- ModuleFederationPlugin as WebpackModuleFederationPlugin ,
4- AsyncBoundaryPlugin ,
5- } from '@module-federation/enhanced' ;
62import { ModuleFederationPlugin as RspackModuleFederationPlugin } from '@module-federation/enhanced/rspack' ;
73import type { moduleFederationPlugin as MFPluginOptions } from '@module-federation/sdk' ;
84import type { PluginOptions , InternalModernPluginOptions } from '../types' ;
@@ -29,18 +25,11 @@ export const moduleFederationPlugin = (
2925 return {
3026 name : '@modern-js/plugin-module-federation' ,
3127 setup : async ( api ) => {
32- const modernjsConfig = api . getConfig ( ) ;
33-
3428 api . modifyBundlerChain ( ( chain ) => {
35- const bundlerType =
36- api . getAppContext ( ) . bundlerType === 'rspack' ? 'rspack' : 'webpack' ;
3729 const browserPluginOptions =
3830 internalModernPluginOptions . csrConfig as MFPluginOptions . ModuleFederationPluginOptions ;
3931
40- const MFPlugin =
41- bundlerType === 'webpack'
42- ? WebpackModuleFederationPlugin
43- : RspackModuleFederationPlugin ;
32+ const MFPlugin = RspackModuleFederationPlugin ;
4433 if ( isWebTarget ( chain . get ( 'target' ) ) ) {
4534 chain
4635 . plugin ( 'plugin-module-federation' )
@@ -50,24 +39,6 @@ export const moduleFederationPlugin = (
5039 return internalModernPluginOptions . browserPlugin ;
5140 } ) ;
5241 }
53-
54- if ( bundlerType === 'webpack' ) {
55- const enableAsyncEntry = modernjsConfig . source ?. enableAsyncEntry ;
56- if ( ! enableAsyncEntry && browserPluginOptions . async !== false ) {
57- const asyncBoundaryPluginOptions =
58- typeof browserPluginOptions . async === 'object'
59- ? browserPluginOptions . async
60- : {
61- eager : ( module ) =>
62- module && / \. f e d e r a t i o n / . test ( module ?. request || '' ) ,
63- excludeChunk : ( chunk ) =>
64- chunk . name === browserPluginOptions . name ,
65- } ;
66- chain
67- . plugin ( 'async-boundary-plugin' )
68- . use ( AsyncBoundaryPlugin , [ asyncBoundaryPluginOptions ] ) ;
69- }
70- }
7142 } ) ;
7243
7344 api . _internalServerPlugins ( ( { plugins } ) => {
0 commit comments