@@ -9,7 +9,7 @@ import { updateStatsAndManifest } from './manifest';
9
9
import { isDev } from './constant' ;
10
10
import { MODERN_JS_SERVER_DIR } from '../constant' ;
11
11
import logger from './logger' ;
12
- import { isWebTarget } from './utils' ;
12
+ import { isWebTarget , skipByTarget } from './utils' ;
13
13
14
14
export function setEnv ( ) {
15
15
process . env [ 'MF_DISABLE_EMIT_STATS' ] = 'true' ;
@@ -48,15 +48,19 @@ export const moduleFederationSSRPlugin = (
48
48
} ) ;
49
49
return { entrypoint, plugins } ;
50
50
} ) ;
51
- api . modifyBundlerChain ( ( chain , { isServer } ) => {
51
+ api . modifyBundlerChain ( ( chain ) => {
52
+ const target = chain . get ( 'target' ) ;
53
+ if ( skipByTarget ( target ) ) {
54
+ return ;
55
+ }
52
56
const bundlerType =
53
57
api . getAppContext ( ) . bundlerType === 'rspack' ? 'rspack' : 'webpack' ;
54
58
const MFPlugin =
55
59
bundlerType === 'webpack'
56
60
? ModuleFederationPlugin
57
61
: RspackModuleFederationPlugin ;
58
62
59
- const isWeb = isWebTarget ( chain . get ( ' target' ) ) ;
63
+ const isWeb = isWebTarget ( target ) ;
60
64
61
65
if ( ! isWeb ) {
62
66
if ( ! chain . plugins . has ( CHAIN_MF_PLUGIN_ID ) ) {
@@ -79,13 +83,13 @@ export const moduleFederationSSRPlugin = (
79
83
}
80
84
}
81
85
82
- if ( isDev && ! isServer ) {
86
+ if ( isDev && isWeb ) {
83
87
chain . externals ( {
84
88
'@module-federation/node/utils' : 'NOT_USED_IN_BROWSER' ,
85
89
} ) ;
86
90
}
87
91
88
- if ( isServer ) {
92
+ if ( ! isWeb ) {
89
93
ssrOutputPath =
90
94
chain . output . get ( 'path' ) ||
91
95
path . resolve ( process . cwd ( ) , `dist/${ MODERN_JS_SERVER_DIR } ` ) ;
0 commit comments