@@ -15,6 +15,7 @@ use turbo_tasks_backend::{
15
15
noop_backing_storage, BackendOptions , NoopBackingStorage , TurboTasksBackend ,
16
16
} ;
17
17
use turbo_tasks_fs:: FileSystem ;
18
+ use turbopack:: global_module_ids:: get_global_module_id_strategy;
18
19
use turbopack_browser:: BrowserChunkingContext ;
19
20
use turbopack_cli_utils:: issue:: { ConsoleUi , LogOptions } ;
20
21
use turbopack_core:: {
@@ -199,47 +200,14 @@ async fn build_internal(
199
200
NodeEnv :: Production => RuntimeType :: Production ,
200
201
} ;
201
202
202
- let chunking_context: Vc < Box < dyn ChunkingContext > > = match target {
203
- Target :: Browser => {
204
- let mut builder = BrowserChunkingContext :: builder (
203
+ let compile_time_info = get_client_compile_time_info ( browserslist_query. clone ( ) , node_env) ;
204
+ let execution_context = ExecutionContext :: new (
205
+ * root_path,
206
+ Vc :: upcast (
207
+ NodeJsChunkingContext :: builder (
205
208
project_path,
206
209
build_output_root,
207
- ResolvedVc :: cell ( build_output_root_to_root_path) ,
208
- build_output_root,
209
- build_output_root,
210
- build_output_root,
211
- Environment :: new ( Value :: new ( ExecutionEnvironment :: Browser (
212
- BrowserEnvironment {
213
- dom : true ,
214
- web_worker : false ,
215
- service_worker : false ,
216
- browserslist_query : browserslist_query. clone ( ) ,
217
- }
218
- . resolved_cell ( ) ,
219
- ) ) )
220
- . to_resolved ( )
221
- . await ?,
222
- runtime_type,
223
- )
224
- . minify_type ( minify_type) ;
225
-
226
- match * node_env. await ? {
227
- NodeEnv :: Development => { }
228
- NodeEnv :: Production => {
229
- builder = builder. ecmascript_chunking_config ( ChunkingConfig {
230
- min_chunk_size : 20000 ,
231
- ..Default :: default ( )
232
- } )
233
- }
234
- }
235
-
236
- Vc :: upcast ( builder. build ( ) )
237
- }
238
- Target :: Node => {
239
- let mut builder = NodeJsChunkingContext :: builder (
240
- project_path,
241
- build_output_root,
242
- ResolvedVc :: cell ( build_output_root_to_root_path) ,
210
+ ResolvedVc :: cell ( build_output_root_to_root_path. clone ( ) ) ,
243
211
build_output_root,
244
212
build_output_root,
245
213
build_output_root,
@@ -250,25 +218,10 @@ async fn build_internal(
250
218
. await ?,
251
219
runtime_type,
252
220
)
253
- . minify_type ( minify_type) ;
254
-
255
- match * node_env. await ? {
256
- NodeEnv :: Development => { }
257
- NodeEnv :: Production => {
258
- builder = builder. ecmascript_chunking_config ( ChunkingConfig {
259
- min_chunk_size : 20000 ,
260
- ..Default :: default ( )
261
- } )
262
- }
263
- }
264
-
265
- Vc :: upcast ( builder. build ( ) )
266
- }
267
- } ;
268
-
269
- let compile_time_info = get_client_compile_time_info ( browserslist_query, node_env) ;
270
- let execution_context =
271
- ExecutionContext :: new ( * root_path, chunking_context, load_env ( * root_path) ) ;
221
+ . build ( ) ,
222
+ ) ,
223
+ load_env ( * root_path) ,
224
+ ) ;
272
225
let asset_context = get_client_asset_context (
273
226
* project_path,
274
227
execution_context,
@@ -322,6 +275,80 @@ async fn build_internal(
322
275
. await ?;
323
276
324
277
let module_graph = ModuleGraph :: from_modules ( Vc :: cell ( entries. clone ( ) ) ) ;
278
+ let module_id_strategy = ResolvedVc :: upcast (
279
+ get_global_module_id_strategy ( module_graph)
280
+ . to_resolved ( )
281
+ . await ?,
282
+ ) ;
283
+
284
+ let chunking_context: Vc < Box < dyn ChunkingContext > > = match target {
285
+ Target :: Browser => {
286
+ let mut builder = BrowserChunkingContext :: builder (
287
+ project_path,
288
+ build_output_root,
289
+ ResolvedVc :: cell ( build_output_root_to_root_path) ,
290
+ build_output_root,
291
+ build_output_root,
292
+ build_output_root,
293
+ Environment :: new ( Value :: new ( ExecutionEnvironment :: Browser (
294
+ BrowserEnvironment {
295
+ dom : true ,
296
+ web_worker : false ,
297
+ service_worker : false ,
298
+ browserslist_query,
299
+ }
300
+ . resolved_cell ( ) ,
301
+ ) ) )
302
+ . to_resolved ( )
303
+ . await ?,
304
+ runtime_type,
305
+ )
306
+ . module_id_strategy ( module_id_strategy)
307
+ . minify_type ( minify_type) ;
308
+
309
+ match * node_env. await ? {
310
+ NodeEnv :: Development => { }
311
+ NodeEnv :: Production => {
312
+ builder = builder. ecmascript_chunking_config ( ChunkingConfig {
313
+ min_chunk_size : 20000 ,
314
+ ..Default :: default ( )
315
+ } )
316
+ }
317
+ }
318
+
319
+ Vc :: upcast ( builder. build ( ) )
320
+ }
321
+ Target :: Node => {
322
+ let mut builder = NodeJsChunkingContext :: builder (
323
+ project_path,
324
+ build_output_root,
325
+ ResolvedVc :: cell ( build_output_root_to_root_path) ,
326
+ build_output_root,
327
+ build_output_root,
328
+ build_output_root,
329
+ Environment :: new ( Value :: new ( ExecutionEnvironment :: NodeJsLambda (
330
+ NodeJsEnvironment :: default ( ) . resolved_cell ( ) ,
331
+ ) ) )
332
+ . to_resolved ( )
333
+ . await ?,
334
+ runtime_type,
335
+ )
336
+ . module_id_strategy ( module_id_strategy)
337
+ . minify_type ( minify_type) ;
338
+
339
+ match * node_env. await ? {
340
+ NodeEnv :: Development => { }
341
+ NodeEnv :: Production => {
342
+ builder = builder. ecmascript_chunking_config ( ChunkingConfig {
343
+ min_chunk_size : 20000 ,
344
+ ..Default :: default ( )
345
+ } )
346
+ }
347
+ }
348
+
349
+ Vc :: upcast ( builder. build ( ) )
350
+ }
351
+ } ;
325
352
326
353
let entry_chunk_groups = entries
327
354
. into_iter ( )
0 commit comments