@@ -16,6 +16,7 @@ use turbo_tasks_backend::{
16
16
noop_backing_storage, BackendOptions , NoopBackingStorage , TurboTasksBackend ,
17
17
} ;
18
18
use turbo_tasks_fs:: FileSystem ;
19
+ use turbopack:: global_module_ids:: get_global_module_id_strategy;
19
20
use turbopack_browser:: BrowserChunkingContext ;
20
21
use turbopack_cli_utils:: issue:: { ConsoleUi , LogOptions } ;
21
22
use turbopack_core:: {
@@ -210,6 +211,88 @@ async fn build_internal(
210
211
NodeEnv :: Development => RuntimeType :: Development ,
211
212
NodeEnv :: Production => RuntimeType :: Production ,
212
213
} ;
214
+ let compile_time_info = get_client_compile_time_info ( browserslist_query. clone ( ) , node_env) ;
215
+ let execution_context = ExecutionContext :: new (
216
+ * root_path,
217
+ Vc :: upcast (
218
+ NodeJsChunkingContext :: builder (
219
+ project_path,
220
+ build_output_root,
221
+ ResolvedVc :: cell ( build_output_root_to_root_path. clone ( ) ) ,
222
+ build_output_root,
223
+ build_output_root,
224
+ build_output_root,
225
+ Environment :: new ( Value :: new ( ExecutionEnvironment :: NodeJsLambda (
226
+ NodeJsEnvironment :: default ( ) . resolved_cell ( ) ,
227
+ ) ) )
228
+ . to_resolved ( )
229
+ . await ?,
230
+ runtime_type,
231
+ )
232
+ . build ( ) ,
233
+ ) ,
234
+ load_env ( * root_path) ,
235
+ ) ;
236
+
237
+ let asset_context = get_client_asset_context (
238
+ * project_path,
239
+ execution_context,
240
+ compile_time_info,
241
+ node_env,
242
+ source_maps_type,
243
+ ) ;
244
+
245
+ let entry_requests = ( * entry_requests
246
+ . into_iter ( )
247
+ . map ( |r| async move {
248
+ Ok ( match r {
249
+ EntryRequest :: Relative ( p) => Request :: relative (
250
+ Value :: new ( p. clone ( ) . into ( ) ) ,
251
+ Default :: default ( ) ,
252
+ Default :: default ( ) ,
253
+ false ,
254
+ ) ,
255
+ EntryRequest :: Module ( m, p) => Request :: module (
256
+ m. clone ( ) ,
257
+ Value :: new ( p. clone ( ) . into ( ) ) ,
258
+ Default :: default ( ) ,
259
+ Default :: default ( ) ,
260
+ ) ,
261
+ } )
262
+ } )
263
+ . try_join ( )
264
+ . await ?)
265
+ . to_vec ( ) ;
266
+
267
+ let origin = PlainResolveOrigin :: new ( asset_context, project_fs. root ( ) . join ( "_" . into ( ) ) ) ;
268
+ let project_dir = & project_dir;
269
+ let entries = entry_requests
270
+ . into_iter ( )
271
+ . map ( |request_vc| async move {
272
+ let ty = Value :: new ( ReferenceType :: Entry ( EntryReferenceSubType :: Undefined ) ) ;
273
+ let request = request_vc. await ?;
274
+ origin
275
+ . resolve_asset ( request_vc, origin. resolve_options ( ty. clone ( ) ) , ty)
276
+ . await ?
277
+ . first_module ( )
278
+ . await ?
279
+ . with_context ( || {
280
+ format ! (
281
+ "Unable to resolve entry {} from directory {}." ,
282
+ request. request( ) . unwrap( ) ,
283
+ project_dir
284
+ )
285
+ } )
286
+ } )
287
+ . try_join ( )
288
+ . await ?;
289
+
290
+ let module_graph = ModuleGraph :: from_modules ( Vc :: cell ( entries. clone ( ) ) ) ;
291
+ let module_id_strategy = ResolvedVc :: upcast (
292
+ get_global_module_id_strategy ( module_graph)
293
+ . to_resolved ( )
294
+ . await ?,
295
+ ) ;
213
296
214
297
let chunking_context: Vc < Box < dyn ChunkingContext > > = match target {
215
298
Target :: Browser => {
@@ -234,6 +317,7 @@ async fn build_internal(
234
317
runtime_type,
235
318
)
236
319
. source_maps ( source_maps_type)
320
+ . module_id_strategy ( module_id_strategy)
237
321
. minify_type ( minify_type) ;
238
322
239
323
match * node_env. await ? {
@@ -264,6 +348,7 @@ async fn build_internal(
264
348
runtime_type,
265
349
)
266
350
. source_maps ( source_maps_type)
351
+ . module_id_strategy ( module_id_strategy)
267
352
. minify_type ( minify_type) ;
268
353
269
354
match * node_env. await ? {
@@ -280,64 +365,6 @@ async fn build_internal(
280
365
}
281
366
} ;
282
367
283
- let compile_time_info = get_client_compile_time_info ( browserslist_query, node_env) ;
284
- let execution_context =
285
- ExecutionContext :: new ( * root_path, chunking_context, load_env ( * root_path) ) ;
286
- let asset_context = get_client_asset_context (
287
- * project_path,
288
- execution_context,
289
- compile_time_info,
290
- node_env,
291
- source_maps_type,
292
- ) ;
293
-
294
- let entry_requests = ( * entry_requests
295
- . into_iter ( )
296
- . map ( |r| async move {
297
- Ok ( match r {
298
- EntryRequest :: Relative ( p) => Request :: relative (
299
- Value :: new ( p. clone ( ) . into ( ) ) ,
300
- Default :: default ( ) ,
301
- Default :: default ( ) ,
302
- false ,
303
- ) ,
304
- EntryRequest :: Module ( m, p) => Request :: module (
305
- m. clone ( ) ,
306
- Value :: new ( p. clone ( ) . into ( ) ) ,
307
- Default :: default ( ) ,
308
- Default :: default ( ) ,
309
- ) ,
310
- } )
311
- } )
312
- . try_join ( )
313
- . await ?)
314
- . to_vec ( ) ;
315
-
316
- let origin = PlainResolveOrigin :: new ( asset_context, project_fs. root ( ) . join ( "_" . into ( ) ) ) ;
317
- let project_dir = & project_dir;
318
- let entries = entry_requests
319
- . into_iter ( )
320
- . map ( |request_vc| async move {
321
- let ty = Value :: new ( ReferenceType :: Entry ( EntryReferenceSubType :: Undefined ) ) ;
322
- let request = request_vc. await ?;
323
- origin
324
- . resolve_asset ( request_vc, origin. resolve_options ( ty. clone ( ) ) , ty)
325
- . await ?
326
- . first_module ( )
327
- . await ?
328
- . with_context ( || {
329
- format ! (
330
- "Unable to resolve entry {} from directory {}." ,
331
- request. request( ) . unwrap( ) ,
332
- project_dir
333
- )
334
- } )
335
- } )
336
- . try_join ( )
337
- . await ?;
338
-
339
- let module_graph = ModuleGraph :: from_modules ( Vc :: cell ( entries. clone ( ) ) ) ;
340
-
341
368
let entry_chunk_groups = entries
342
369
. into_iter ( )
343
370
. map ( |entry_module| async move {
0 commit comments