@@ -581,7 +581,6 @@ const composeFormatConfig = ({
581581 output : {
582582 uniqueName : pkgJson . name as string ,
583583 } ,
584- // TODO when we provide dev mode for rslib mf format, this should be modified to as the same with config.mode
585584 // can not set nodeEnv to false, because mf format should build shared module.
586585 // If nodeEnv is false, the process.env.NODE_ENV in third-party packages's will not be replaced
587586 // now we have not provide dev mode for users, so we can always set nodeEnv as 'production'
@@ -590,6 +589,9 @@ const composeFormatConfig = ({
590589 } ,
591590 } ,
592591 } ,
592+ output : {
593+ target : 'web' ,
594+ } ,
593595 } ;
594596 default :
595597 throw new Error ( `Unsupported format: ${ format } ` ) ;
@@ -941,12 +943,17 @@ const composeDtsConfig = async (
941943} ;
942944
943945const composeTargetConfig = (
944- target : RsbuildConfigOutputTarget = 'node' ,
946+ target : RsbuildConfigOutputTarget ,
947+ format : Format ,
945948) : {
946949 config : RsbuildConfig ;
947950 target : RsbuildConfigOutputTarget ;
948951} => {
949- switch ( target ) {
952+ let defaultTarget = target ;
953+ if ( ! defaultTarget ) {
954+ defaultTarget = format === 'mf' ? 'web' : 'node' ;
955+ }
956+ switch ( defaultTarget ) {
950957 case 'web' :
951958 return {
952959 config : {
@@ -986,7 +993,7 @@ const composeTargetConfig = (
986993 // },
987994 // };
988995 default :
989- throw new Error ( `Unsupported platform: ${ target } ` ) ;
996+ throw new Error ( `Unsupported platform: ${ defaultTarget } ` ) ;
990997 }
991998} ;
992999
@@ -1078,6 +1085,7 @@ async function composeLibRsbuildConfig(config: LibConfig, configPath: string) {
10781085 ) ;
10791086 const { config : targetConfig , target } = composeTargetConfig (
10801087 config . output ?. target ,
1088+ format ! ,
10811089 ) ;
10821090 const syntaxConfig = composeSyntaxConfig ( target , config ?. syntax ) ;
10831091 const autoExternalConfig = composeAutoExternalConfig ( {
0 commit comments