@@ -15,7 +15,7 @@ export function setEnv() {
1515}
1616
1717export const moduleFederationSSRPlugin = (
18- userConfig : Required < InternalModernPluginOptions > ,
18+ pluginOptions : Required < InternalModernPluginOptions > ,
1919) : CliPlugin < AppTools > => ( {
2020 name : '@modern-js/plugin-module-federation-ssr' ,
2121 pre : [
@@ -25,7 +25,7 @@ export const moduleFederationSSRPlugin = (
2525 setup : async ( { useConfigContext, useAppContext } ) => {
2626 const modernjsConfig = useConfigContext ( ) ;
2727 const enableSSR = Boolean ( modernjsConfig ?. server ?. ssr ) ;
28- if ( ! enableSSR ) {
28+ if ( ! enableSSR || pluginOptions . userConfig ?. ssr === false ) {
2929 return { } ;
3030 }
3131
@@ -50,32 +50,32 @@ export const moduleFederationSSRPlugin = (
5050 // throw new Error(
5151 // `${PLUGIN_IDENTIFIER} Not support rspack ssr mode yet !`,
5252 // );
53- if ( ! userConfig . nodePlugin ) {
54- userConfig . nodePlugin = new RspackModuleFederationPlugin (
55- userConfig . ssrConfig ,
53+ if ( ! pluginOptions . nodePlugin ) {
54+ pluginOptions . nodePlugin = new RspackModuleFederationPlugin (
55+ pluginOptions . ssrConfig ,
5656 ) ;
5757 // @ts -ignore
58- config . plugins ?. push ( userConfig . nodePlugin ) ;
58+ config . plugins ?. push ( pluginOptions . nodePlugin ) ;
5959 }
6060 } else {
61- userConfig . distOutputDir =
62- userConfig . distOutputDir ||
61+ pluginOptions . distOutputDir =
62+ pluginOptions . distOutputDir ||
6363 config . output ?. path ||
6464 path . resolve ( process . cwd ( ) , 'dist' ) ;
6565 }
6666 } ,
6767 webpack ( config , { isServer } ) {
6868 if ( isServer ) {
69- if ( ! userConfig . nodePlugin ) {
70- userConfig . nodePlugin = new ModuleFederationPlugin (
71- userConfig . ssrConfig ,
69+ if ( ! pluginOptions . nodePlugin ) {
70+ pluginOptions . nodePlugin = new ModuleFederationPlugin (
71+ pluginOptions . ssrConfig ,
7272 ) ;
7373 // @ts -ignore
74- config . plugins ?. push ( userConfig . nodePlugin ) ;
74+ config . plugins ?. push ( pluginOptions . nodePlugin ) ;
7575 }
7676 } else {
77- userConfig . distOutputDir =
78- userConfig . distOutputDir ||
77+ pluginOptions . distOutputDir =
78+ pluginOptions . distOutputDir ||
7979 config . output ?. path ||
8080 path . resolve ( process . cwd ( ) , 'dist' ) ;
8181 }
@@ -133,11 +133,11 @@ export const moduleFederationSSRPlugin = (
133133 } ;
134134 } ,
135135 afterBuild : ( ) => {
136- const { nodePlugin, browserPlugin, distOutputDir } = userConfig ;
136+ const { nodePlugin, browserPlugin, distOutputDir } = pluginOptions ;
137137 updateStatsAndManifest ( nodePlugin , browserPlugin , distOutputDir ) ;
138138 } ,
139139 afterDev : ( ) => {
140- const { nodePlugin, browserPlugin, distOutputDir } = userConfig ;
140+ const { nodePlugin, browserPlugin, distOutputDir } = pluginOptions ;
141141 updateStatsAndManifest ( nodePlugin , browserPlugin , distOutputDir ) ;
142142 } ,
143143 } ;
0 commit comments