@@ -132,6 +132,10 @@ pub async fn get_next_client_import_map(
132
132
) ;
133
133
import_map. insert_wildcard_alias (
134
134
"react-server-dom-webpack/" ,
135
+ request_to_import_mapping ( app_dir, "react-server-dom-turbopack/*" ) ,
136
+ ) ;
137
+ import_map. insert_wildcard_alias (
138
+ "react-server-dom-turbopack/" ,
135
139
request_to_import_mapping (
136
140
app_dir,
137
141
& format ! ( "next/dist/compiled/react-server-dom-turbopack{react_flavor}/*" ) ,
@@ -247,15 +251,6 @@ pub async fn get_next_server_import_map(
247
251
248
252
let ty = ty. into_value ( ) ;
249
253
250
- insert_next_server_special_aliases (
251
- & mut import_map,
252
- project_path,
253
- ty,
254
- mode,
255
- NextRuntime :: NodeJs ,
256
- next_config,
257
- )
258
- . await ?;
259
254
let external: Vc < ImportMapping > = ImportMapping :: External ( None ) . cell ( ) ;
260
255
261
256
import_map. insert_exact_alias ( "next/dist/server/require-hook" , external) ;
@@ -273,6 +268,12 @@ pub async fn get_next_server_import_map(
273
268
ServerContextType :: AppSSR { .. }
274
269
| ServerContextType :: AppRSC { .. }
275
270
| ServerContextType :: AppRoute { .. } => {
271
+ let react_flavor = if * next_config. enable_server_actions ( ) . await ? {
272
+ "-experimental"
273
+ } else {
274
+ ""
275
+ } ;
276
+
276
277
import_map. insert_exact_alias (
277
278
"private-next-rsc-action-proxy" ,
278
279
request_to_import_mapping (
@@ -302,14 +303,48 @@ pub async fn get_next_server_import_map(
302
303
"next/dynamic" ,
303
304
request_to_import_mapping ( project_path, "next/dist/shared/lib/app-dynamic" ) ,
304
305
) ;
305
- import_map. insert_exact_alias (
306
- "react-server-dom-webpack/" ,
307
- ImportMapping :: External ( Some ( "react-server-dom-turbopack" . into ( ) ) ) . cell ( ) ,
306
+
307
+ let mapping = request_to_import_mapping (
308
+ project_path,
309
+ & format ! ( "next/dist/compiled/react-server-dom-turbopack{react_flavor}/client" ) ,
310
+ ) ;
311
+ import_map. insert_exact_alias ( "react-server-dom-webpack/client" , mapping) ;
312
+ import_map. insert_exact_alias ( "react-server-dom-turbopack/client" , mapping) ;
313
+
314
+ let mapping = request_to_import_mapping (
315
+ project_path,
316
+ & format ! ( "next/dist/compiled/react-server-dom-turbopack{react_flavor}/client.edge" ) ,
317
+ ) ;
318
+ import_map. insert_exact_alias ( "react-server-dom-webpack/client.edge" , mapping) ;
319
+ import_map. insert_exact_alias ( "react-server-dom-turbopack/client.edge" , mapping) ;
320
+
321
+ let mapping = request_to_import_mapping (
322
+ project_path,
323
+ & format ! ( "next/dist/compiled/react-server-dom-turbopack{react_flavor}/server.edge" ) ,
308
324
) ;
325
+ import_map. insert_exact_alias ( "react-server-dom-webpack/server.edge" , mapping) ;
326
+ import_map. insert_exact_alias ( "react-server-dom-turbopack/server.edge" , mapping) ;
327
+
328
+ let mapping = request_to_import_mapping (
329
+ project_path,
330
+ & format ! ( "next/dist/compiled/react-server-dom-turbopack{react_flavor}/server.node" ) ,
331
+ ) ;
332
+ import_map. insert_exact_alias ( "react-server-dom-webpack/server.node" , mapping) ;
333
+ import_map. insert_exact_alias ( "react-server-dom-turbopack/server.node" , mapping) ;
309
334
}
310
335
ServerContextType :: Middleware => { }
311
336
}
312
337
338
+ insert_next_server_special_aliases (
339
+ & mut import_map,
340
+ project_path,
341
+ ty,
342
+ mode,
343
+ NextRuntime :: NodeJs ,
344
+ next_config,
345
+ )
346
+ . await ?;
347
+
313
348
Ok ( import_map. cell ( ) )
314
349
}
315
350
@@ -342,22 +377,17 @@ pub async fn get_next_edge_import_map(
342
377
. await ?;
343
378
344
379
let ty = ty. into_value ( ) ;
345
-
346
- insert_next_server_special_aliases (
347
- & mut import_map,
348
- project_path,
349
- ty,
350
- mode,
351
- NextRuntime :: Edge ,
352
- next_config,
353
- )
354
- . await ?;
355
-
356
380
match ty {
357
381
ServerContextType :: Pages { .. } | ServerContextType :: PagesData { .. } => { }
358
382
ServerContextType :: AppSSR { .. }
359
383
| ServerContextType :: AppRSC { .. }
360
384
| ServerContextType :: AppRoute { .. } => {
385
+ let react_flavor = if * next_config. enable_server_actions ( ) . await ? {
386
+ "-experimental"
387
+ } else {
388
+ ""
389
+ } ;
390
+
361
391
import_map. insert_exact_alias (
362
392
"next/head" ,
363
393
request_to_import_mapping ( project_path, "next/dist/client/components/noop-head" ) ,
@@ -366,10 +396,48 @@ pub async fn get_next_edge_import_map(
366
396
"next/dynamic" ,
367
397
request_to_import_mapping ( project_path, "next/dist/shared/lib/app-dynamic" ) ,
368
398
) ;
399
+
400
+ let mapping = request_to_import_mapping (
401
+ project_path,
402
+ & format ! ( "next/dist/compiled/react-server-dom-turbopack{react_flavor}/client" ) ,
403
+ ) ;
404
+ import_map. insert_exact_alias ( "react-server-dom-webpack/client" , mapping) ;
405
+ import_map. insert_exact_alias ( "react-server-dom-turbopack/client" , mapping) ;
406
+
407
+ let mapping = request_to_import_mapping (
408
+ project_path,
409
+ & format ! ( "next/dist/compiled/react-server-dom-turbopack{react_flavor}/client.edge" ) ,
410
+ ) ;
411
+ import_map. insert_exact_alias ( "react-server-dom-webpack/client.edge" , mapping) ;
412
+ import_map. insert_exact_alias ( "react-server-dom-turbopack/client.edge" , mapping) ;
413
+
414
+ let mapping = request_to_import_mapping (
415
+ project_path,
416
+ & format ! ( "next/dist/compiled/react-server-dom-turbopack{react_flavor}/server.edge" ) ,
417
+ ) ;
418
+ import_map. insert_exact_alias ( "react-server-dom-webpack/server.edge" , mapping) ;
419
+ import_map. insert_exact_alias ( "react-server-dom-turbopack/server.edge" , mapping) ;
420
+
421
+ let mapping = request_to_import_mapping (
422
+ project_path,
423
+ & format ! ( "next/dist/compiled/react-server-dom-turbopack{react_flavor}/server.node" ) ,
424
+ ) ;
425
+ import_map. insert_exact_alias ( "react-server-dom-webpack/server.node" , mapping) ;
426
+ import_map. insert_exact_alias ( "react-server-dom-turbopack/server.node" , mapping) ;
369
427
}
370
428
ServerContextType :: Middleware => { }
371
429
}
372
430
431
+ insert_next_server_special_aliases (
432
+ & mut import_map,
433
+ project_path,
434
+ ty,
435
+ mode,
436
+ NextRuntime :: Edge ,
437
+ next_config,
438
+ )
439
+ . await ?;
440
+
373
441
Ok ( import_map. cell ( ) )
374
442
}
375
443
@@ -552,49 +620,28 @@ async fn insert_next_server_special_aliases(
552
620
} ,
553
621
) ,
554
622
) ;
555
- import_map. insert_exact_alias (
556
- "react-server-dom-webpack/client.edge" ,
557
- request_to_import_mapping (
558
- app_dir,
559
- match ( runtime, server_actions) {
560
- ( NextRuntime :: Edge , true ) => {
561
- "next/dist/compiled/react-server-dom-turbopack-experimental/client.edge"
562
- }
563
- ( NextRuntime :: Edge , false ) => {
564
- "next/dist/compiled/react-server-dom-turbopack/client.edge"
565
- }
566
- // When we access the runtime we still use the webpack name. The runtime
567
- // itself will substitute in the turbopack variant
568
- ( NextRuntime :: NodeJs , _) => {
569
- "next/dist/server/future/route-modules/app-page/vendored/ssr/\
570
- react-server-dom-turbopack-client-edge"
571
- }
572
- } ,
573
- ) ,
574
- ) ;
575
- // some code also imports react-server-dom-webpack/client on the server
576
- // it should never run so it's fine to just point it to the same place as
577
- // react-server-dom-webpack/client.edge
578
- import_map. insert_exact_alias (
579
- "react-server-dom-webpack/client" ,
580
- request_to_import_mapping (
581
- app_dir,
582
- match ( runtime, server_actions) {
583
- ( NextRuntime :: Edge , true ) => {
584
- "next/dist/compiled/react-server-dom-turbopack-experimental/client.edge"
585
- }
586
- ( NextRuntime :: Edge , false ) => {
587
- "next/dist/compiled/react-server-dom-turbopack/client.edge"
588
- }
589
- // When we access the runtime we still use the webpack name. The runtime
590
- // itself will substitute in the turbopack variant
591
- ( NextRuntime :: NodeJs , _) => {
592
- "next/dist/server/future/route-modules/app-page/vendored/ssr/\
593
- react-server-dom-turbopack-client-edge"
594
- }
595
- } ,
596
- ) ,
623
+
624
+ let mapping = request_to_import_mapping (
625
+ app_dir,
626
+ match ( runtime, server_actions) {
627
+ ( NextRuntime :: Edge , true ) => {
628
+ "next/dist/compiled/react-server-dom-turbopack-experimental/client.edge"
629
+ }
630
+ ( NextRuntime :: Edge , false ) => {
631
+ "next/dist/compiled/react-server-dom-turbopack/client.edge"
632
+ }
633
+ // When we access the runtime we still use the webpack name. The runtime
634
+ // itself will substitute in the turbopack variant
635
+ ( NextRuntime :: NodeJs , _) => {
636
+ "next/dist/server/future/route-modules/app-page/vendored/ssr/\
637
+ react-server-dom-turbopack-client-edge"
638
+ }
639
+ } ,
597
640
) ;
641
+ import_map. insert_exact_alias ( "react-server-dom-webpack/client.edge" , mapping) ;
642
+ import_map. insert_exact_alias ( "react-server-dom-turbopack/client.edge" , mapping) ;
643
+
644
+ // import_map.insert_exact_alias("react-server-dom-turbopack/client", mapping);
598
645
// not essential but we're providing this alias for people who might use it.
599
646
// A note here is that this will point toward the ReactDOMServer on the SSR
600
647
// layer TODO: add the rests
@@ -614,6 +661,7 @@ async fn insert_next_server_special_aliases(
614
661
} ,
615
662
) ,
616
663
) ;
664
+
617
665
import_map. insert_exact_alias (
618
666
"react-dom/server.edge" ,
619
667
request_to_import_mapping (
@@ -717,46 +765,47 @@ async fn insert_next_server_special_aliases(
717
765
} ,
718
766
) ,
719
767
) ;
720
- import_map. insert_exact_alias (
721
- "react-server-dom-webpack/server.edge" ,
722
- request_to_import_mapping (
723
- app_dir,
724
- match ( runtime, server_actions) {
725
- ( NextRuntime :: Edge , true ) => {
726
- "next/dist/compiled/react-server-dom-turbopack-experimental/server.edge"
727
- }
728
- ( NextRuntime :: Edge , false ) => {
729
- "next/dist/compiled/react-server-dom-turbopack/server.edge"
730
- }
731
- // When we access the runtime we still use the webpack name. The runtime
732
- // itself will substitute in the turbopack variant
733
- ( NextRuntime :: NodeJs , _) => {
734
- "next/dist/server/future/route-modules/app-page/vendored/rsc/\
735
- react-server-dom-turbopack-server-edge"
736
- }
737
- } ,
738
- ) ,
768
+
769
+ let mapping = request_to_import_mapping (
770
+ app_dir,
771
+ match ( runtime, server_actions) {
772
+ ( NextRuntime :: Edge , true ) => {
773
+ "next/dist/compiled/react-server-dom-turbopack-experimental/server.edge"
774
+ }
775
+ ( NextRuntime :: Edge , false ) => {
776
+ "next/dist/compiled/react-server-dom-turbopack/server.edge"
777
+ }
778
+ // When we access the runtime we still use the webpack name. The runtime
779
+ // itself will substitute in the turbopack variant
780
+ ( NextRuntime :: NodeJs , _) => {
781
+ "next/dist/server/future/route-modules/app-page/vendored/rsc/\
782
+ react-server-dom-turbopack-server-edge"
783
+ }
784
+ } ,
739
785
) ;
740
- import_map. insert_exact_alias (
741
- "react-server-dom-webpack /server.node" ,
742
- request_to_import_mapping (
743
- app_dir ,
744
- match ( runtime , server_actions ) {
745
- ( NextRuntime :: Edge , true ) => {
746
- "next/dist/compiled/react-server-dom-turbopack-experimental/server.node"
747
- }
748
- ( NextRuntime :: Edge , false ) => {
749
- "next/dist/compiled/react-server-dom-turbopack/server.node"
750
- }
751
- // When we access the runtime we still use the webpack name. The runtime
752
- // itself will substitute in the turbopack variant
753
- ( NextRuntime :: NodeJs , _ ) => {
754
- "next/dist/server/future/route-modules/app-page/vendored/rsc/ \
755
- react- server-dom-turbopack-server-node"
756
- }
757
- } ,
758
- ) ,
786
+ import_map. insert_exact_alias ( "react-server-dom-webpack/server.edge" , mapping ) ;
787
+ import_map . insert_exact_alias ( "react-server-dom-turbopack /server.edge" , mapping ) ;
788
+
789
+ let mapping = request_to_import_mapping (
790
+ app_dir ,
791
+ match ( runtime , server_actions ) {
792
+ ( NextRuntime :: Edge , true ) => {
793
+ "next/dist/compiled/react-server-dom-turbopack-experimental/server.node"
794
+ }
795
+ ( NextRuntime :: Edge , false ) => {
796
+ "next/dist/compiled/react-server-dom-turbopack/server.node"
797
+ }
798
+ // When we access the runtime we still use the webpack name. The runtime
799
+ // itself will substitute in the turbopack variant
800
+ ( NextRuntime :: NodeJs , _ ) => {
801
+ "next/dist/ server/future/route-modules/app-page/vendored/rsc/ \
802
+ react-server-dom-turbopack-server-node"
803
+ }
804
+ } ,
759
805
) ;
806
+ import_map. insert_exact_alias ( "react-server-dom-webpack/server.node" , mapping) ;
807
+ import_map. insert_exact_alias ( "react-server-dom-turbopack/server.node" , mapping) ;
808
+
760
809
// not essential but we're providing this alias for people who might use it.
761
810
// A note here is that this will point toward the ReactDOMServer on the SSR
762
811
// layer TODO: add the rests
0 commit comments