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