@@ -9,7 +9,7 @@ import { updateStatsAndManifest } from './manifest';
99import { isDev } from './constant' ;
1010import { MODERN_JS_SERVER_DIR } from '../constant' ;
1111import logger from './logger' ;
12- import { isWebTarget } from './utils' ;
12+ import { isWebTarget , skipByTarget } from './utils' ;
1313
1414export function setEnv ( ) {
1515 process . env [ 'MF_DISABLE_EMIT_STATS' ] = 'true' ;
@@ -48,15 +48,19 @@ export const moduleFederationSSRPlugin = (
4848 } ) ;
4949 return { entrypoint, plugins } ;
5050 } ) ;
51- api . modifyBundlerChain ( ( chain , { isServer } ) => {
51+ api . modifyBundlerChain ( ( chain ) => {
52+ const target = chain . get ( 'target' ) ;
53+ if ( skipByTarget ( target ) ) {
54+ return ;
55+ }
5256 const bundlerType =
5357 api . getAppContext ( ) . bundlerType === 'rspack' ? 'rspack' : 'webpack' ;
5458 const MFPlugin =
5559 bundlerType === 'webpack'
5660 ? ModuleFederationPlugin
5761 : RspackModuleFederationPlugin ;
5862
59- const isWeb = isWebTarget ( chain . get ( ' target' ) ) ;
63+ const isWeb = isWebTarget ( target ) ;
6064
6165 if ( ! isWeb ) {
6266 if ( ! chain . plugins . has ( CHAIN_MF_PLUGIN_ID ) ) {
@@ -79,13 +83,13 @@ export const moduleFederationSSRPlugin = (
7983 }
8084 }
8185
82- if ( isDev && ! isServer ) {
86+ if ( isDev && isWeb ) {
8387 chain . externals ( {
8488 '@module-federation/node/utils' : 'NOT_USED_IN_BROWSER' ,
8589 } ) ;
8690 }
8791
88- if ( isServer ) {
92+ if ( ! isWeb ) {
8993 ssrOutputPath =
9094 chain . output . get ( 'path' ) ||
9195 path . resolve ( process . cwd ( ) , `dist/${ MODERN_JS_SERVER_DIR } ` ) ;
0 commit comments