@@ -581,7 +581,6 @@ const composeFormatConfig = ({
581
581
output : {
582
582
uniqueName : pkgJson . name as string ,
583
583
} ,
584
- // TODO when we provide dev mode for rslib mf format, this should be modified to as the same with config.mode
585
584
// can not set nodeEnv to false, because mf format should build shared module.
586
585
// If nodeEnv is false, the process.env.NODE_ENV in third-party packages's will not be replaced
587
586
// now we have not provide dev mode for users, so we can always set nodeEnv as 'production'
@@ -590,6 +589,9 @@ const composeFormatConfig = ({
590
589
} ,
591
590
} ,
592
591
} ,
592
+ output : {
593
+ target : 'web' ,
594
+ } ,
593
595
} ;
594
596
default :
595
597
throw new Error ( `Unsupported format: ${ format } ` ) ;
@@ -941,12 +943,17 @@ const composeDtsConfig = async (
941
943
} ;
942
944
943
945
const composeTargetConfig = (
944
- target : RsbuildConfigOutputTarget = 'node' ,
946
+ target : RsbuildConfigOutputTarget ,
947
+ format : Format ,
945
948
) : {
946
949
config : RsbuildConfig ;
947
950
target : RsbuildConfigOutputTarget ;
948
951
} => {
949
- switch ( target ) {
952
+ let defaultTarget = target ;
953
+ if ( ! defaultTarget ) {
954
+ defaultTarget = format === 'mf' ? 'web' : 'node' ;
955
+ }
956
+ switch ( defaultTarget ) {
950
957
case 'web' :
951
958
return {
952
959
config : {
@@ -986,7 +993,7 @@ const composeTargetConfig = (
986
993
// },
987
994
// };
988
995
default :
989
- throw new Error ( `Unsupported platform: ${ target } ` ) ;
996
+ throw new Error ( `Unsupported platform: ${ defaultTarget } ` ) ;
990
997
}
991
998
} ;
992
999
@@ -1078,6 +1085,7 @@ async function composeLibRsbuildConfig(config: LibConfig, configPath: string) {
1078
1085
) ;
1079
1086
const { config : targetConfig , target } = composeTargetConfig (
1080
1087
config . output ?. target ,
1088
+ format ! ,
1081
1089
) ;
1082
1090
const syntaxConfig = composeSyntaxConfig ( target , config ?. syntax ) ;
1083
1091
const autoExternalConfig = composeAutoExternalConfig ( {
0 commit comments