@@ -16,7 +16,7 @@ use turbopack::{
16
16
} ;
17
17
use turbopack_core:: {
18
18
chunk:: {
19
- ChunkingConfig , MangleType , MinifyType , SourceMapsType ,
19
+ ChunkingConfig , ChunkingStyle , MangleType , MinifyType , SourceMapsType ,
20
20
module_id_strategies:: ModuleIdStrategy ,
21
21
} ,
22
22
compile_time_defines,
@@ -1032,6 +1032,7 @@ pub fn get_server_runtime_entries(
1032
1032
#[ derive( Clone , Debug , PartialEq , Eq , Hash , TaskInput , TraceRawVcs , Serialize , Deserialize ) ]
1033
1033
pub struct ServerChunkingContextOptions {
1034
1034
pub mode : Vc < NextMode > ,
1035
+ pub chunking_style : Vc < ChunkingStyle > ,
1035
1036
pub root_path : FileSystemPath ,
1036
1037
pub node_root : FileSystemPath ,
1037
1038
pub node_root_to_root_path : RcStr ,
@@ -1052,6 +1053,7 @@ pub async fn get_server_chunking_context_with_client_assets(
1052
1053
) -> Result < Vc < NodeJsChunkingContext > > {
1053
1054
let ServerChunkingContextOptions {
1054
1055
mode,
1056
+ chunking_style,
1055
1057
root_path,
1056
1058
node_root,
1057
1059
node_root_to_root_path,
@@ -1096,28 +1098,31 @@ pub async fn get_server_chunking_context_with_client_assets(
1096
1098
. export_usage ( * export_usage. await ?)
1097
1099
. file_tracing ( next_mode. is_production ( ) ) ;
1098
1100
1099
- if next_mode. is_development ( ) {
1100
- builder = builder. use_file_source_map_uris ( ) ;
1101
- } else {
1102
- builder = builder
1103
- . chunking_config (
1104
- Vc :: < EcmascriptChunkType > :: default ( ) . to_resolved ( ) . await ?,
1105
- ChunkingConfig {
1106
- min_chunk_size : 20_000 ,
1107
- max_chunk_count_per_group : 100 ,
1108
- max_merge_chunk_size : 100_000 ,
1109
- ..Default :: default ( )
1110
- } ,
1111
- )
1112
- . chunking_config (
1113
- Vc :: < CssChunkType > :: default ( ) . to_resolved ( ) . await ?,
1114
- ChunkingConfig {
1115
- max_merge_chunk_size : 100_000 ,
1116
- ..Default :: default ( )
1117
- } ,
1118
- )
1119
- . module_merging ( * scope_hoisting. await ?) ;
1101
+ match * chunking_style. await ? {
1102
+ ChunkingStyle :: Development => {
1103
+ builder = builder. use_file_source_map_uris ( ) ;
1104
+ }
1105
+ ChunkingStyle :: Production => {
1106
+ builder = builder
1107
+ . chunking_config (
1108
+ Vc :: < EcmascriptChunkType > :: default ( ) . to_resolved ( ) . await ?,
1109
+ ChunkingConfig {
1110
+ min_chunk_size : 20_000 ,
1111
+ max_chunk_count_per_group : 100 ,
1112
+ max_merge_chunk_size : 100_000 ,
1113
+ ..Default :: default ( )
1114
+ } ,
1115
+ )
1116
+ . chunking_config (
1117
+ Vc :: < CssChunkType > :: default ( ) . to_resolved ( ) . await ?,
1118
+ ChunkingConfig {
1119
+ max_merge_chunk_size : 100_000 ,
1120
+ ..Default :: default ( )
1121
+ } ,
1122
+ )
1123
+ }
1120
1124
}
1125
+ builder = builder. module_merging ( * scope_hoisting. await ?) ;
1121
1126
1122
1127
Ok ( builder. build ( ) )
1123
1128
}
@@ -1128,6 +1133,7 @@ pub async fn get_server_chunking_context(
1128
1133
) -> Result < Vc < NodeJsChunkingContext > > {
1129
1134
let ServerChunkingContextOptions {
1130
1135
mode,
1136
+ chunking_style,
1131
1137
root_path,
1132
1138
node_root,
1133
1139
node_root_to_root_path,
@@ -1169,28 +1175,31 @@ pub async fn get_server_chunking_context(
1169
1175
. export_usage ( * export_usage. await ?)
1170
1176
. file_tracing ( next_mode. is_production ( ) ) ;
1171
1177
1172
- if next_mode. is_development ( ) {
1173
- builder = builder. use_file_source_map_uris ( )
1174
- } else {
1175
- builder = builder
1176
- . chunking_config (
1177
- Vc :: < EcmascriptChunkType > :: default ( ) . to_resolved ( ) . await ?,
1178
- ChunkingConfig {
1179
- min_chunk_size : 20_000 ,
1180
- max_chunk_count_per_group : 100 ,
1181
- max_merge_chunk_size : 100_000 ,
1182
- ..Default :: default ( )
1183
- } ,
1184
- )
1185
- . chunking_config (
1186
- Vc :: < CssChunkType > :: default ( ) . to_resolved ( ) . await ?,
1187
- ChunkingConfig {
1188
- max_merge_chunk_size : 100_000 ,
1189
- ..Default :: default ( )
1190
- } ,
1191
- )
1192
- . module_merging ( * scope_hoisting. await ?) ;
1178
+ match * chunking_style. await ? {
1179
+ ChunkingStyle :: Development => {
1180
+ builder = builder. use_file_source_map_uris ( ) ;
1181
+ }
1182
+ ChunkingStyle :: Production => {
1183
+ builder = builder
1184
+ . chunking_config (
1185
+ Vc :: < EcmascriptChunkType > :: default ( ) . to_resolved ( ) . await ?,
1186
+ ChunkingConfig {
1187
+ min_chunk_size : 20_000 ,
1188
+ max_chunk_count_per_group : 100 ,
1189
+ max_merge_chunk_size : 100_000 ,
1190
+ ..Default :: default ( )
1191
+ } ,
1192
+ )
1193
+ . chunking_config (
1194
+ Vc :: < CssChunkType > :: default ( ) . to_resolved ( ) . await ?,
1195
+ ChunkingConfig {
1196
+ max_merge_chunk_size : 100_000 ,
1197
+ ..Default :: default ( )
1198
+ } ,
1199
+ )
1200
+ }
1193
1201
}
1202
+ builder = builder. module_merging ( * scope_hoisting. await ?) ;
1194
1203
1195
1204
Ok ( builder. build ( ) )
1196
1205
}
0 commit comments