@@ -402,17 +402,6 @@ impl PagesProject {
402
402
)
403
403
}
404
404
405
- #[ turbo_tasks:: function]
406
- pub ( super ) fn ssr_data_module_context ( self : Vc < Self > ) -> Vc < ModuleAssetContext > {
407
- ModuleAssetContext :: new (
408
- self . server_transitions ( ) ,
409
- self . project ( ) . server_compile_time_info ( ) ,
410
- self . ssr_data_module_options_context ( ) ,
411
- self . ssr_resolve_options_context ( ) ,
412
- Layer :: new ( rcstr ! ( "ssr-data" ) ) ,
413
- )
414
- }
415
-
416
405
#[ turbo_tasks:: function]
417
406
pub ( super ) fn edge_ssr_module_context ( self : Vc < Self > ) -> Vc < ModuleAssetContext > {
418
407
ModuleAssetContext :: new (
@@ -435,17 +424,6 @@ impl PagesProject {
435
424
)
436
425
}
437
426
438
- #[ turbo_tasks:: function]
439
- pub ( super ) fn edge_ssr_data_module_context ( self : Vc < Self > ) -> Vc < ModuleAssetContext > {
440
- ModuleAssetContext :: new (
441
- Default :: default ( ) ,
442
- self . project ( ) . edge_compile_time_info ( ) ,
443
- self . edge_ssr_data_module_options_context ( ) ,
444
- self . edge_ssr_resolve_options_context ( ) ,
445
- Layer :: new ( rcstr ! ( "edge-ssr-data" ) ) ,
446
- )
447
- }
448
-
449
427
#[ turbo_tasks:: function]
450
428
async fn ssr_module_options_context ( self : Vc < Self > ) -> Result < Vc < ModuleOptionsContext > > {
451
429
Ok ( get_server_module_options_context (
@@ -514,42 +492,6 @@ impl PagesProject {
514
492
) )
515
493
}
516
494
517
- #[ turbo_tasks:: function]
518
- async fn ssr_data_module_options_context ( self : Vc < Self > ) -> Result < Vc < ModuleOptionsContext > > {
519
- Ok ( get_server_module_options_context (
520
- self . project ( ) . project_path ( ) . owned ( ) . await ?,
521
- self . project ( ) . execution_context ( ) ,
522
- ServerContextType :: PagesData {
523
- pages_dir : self . pages_dir ( ) . owned ( ) . await ?,
524
- } ,
525
- self . project ( ) . next_mode ( ) ,
526
- self . project ( ) . next_config ( ) ,
527
- NextRuntime :: NodeJs ,
528
- self . project ( ) . encryption_key ( ) ,
529
- self . project ( ) . server_compile_time_info ( ) . environment ( ) ,
530
- self . project ( ) . client_compile_time_info ( ) . environment ( ) ,
531
- ) )
532
- }
533
-
534
- #[ turbo_tasks:: function]
535
- async fn edge_ssr_data_module_options_context (
536
- self : Vc < Self > ,
537
- ) -> Result < Vc < ModuleOptionsContext > > {
538
- Ok ( get_server_module_options_context (
539
- self . project ( ) . project_path ( ) . owned ( ) . await ?,
540
- self . project ( ) . execution_context ( ) ,
541
- ServerContextType :: PagesData {
542
- pages_dir : self . pages_dir ( ) . owned ( ) . await ?,
543
- } ,
544
- self . project ( ) . next_mode ( ) ,
545
- self . project ( ) . next_config ( ) ,
546
- NextRuntime :: Edge ,
547
- self . project ( ) . encryption_key ( ) ,
548
- self . project ( ) . edge_compile_time_info ( ) . environment ( ) ,
549
- self . project ( ) . client_compile_time_info ( ) . environment ( ) ,
550
- ) )
551
- }
552
-
553
495
#[ turbo_tasks:: function]
554
496
async fn ssr_resolve_options_context ( self : Vc < Self > ) -> Result < Vc < ResolveOptionsContext > > {
555
497
Ok ( get_server_resolve_options_context (
@@ -652,7 +594,10 @@ struct PageEndpoint {
652
594
enum PageEndpointType {
653
595
Api ,
654
596
Html ,
597
+ // A development only type that is used in pages router so we can differentiate between
598
+ // components changing and server props changing.
655
599
Data ,
600
+ // for _document.js
656
601
SsrOnly ,
657
602
}
658
603
@@ -701,8 +646,15 @@ impl PageEndpoint {
701
646
702
647
#[ turbo_tasks:: function]
703
648
async fn source ( & self ) -> Result < Vc < Box < dyn Source > > > {
704
- Ok ( Vc :: upcast ( FileSource :: new (
649
+ Ok ( Vc :: upcast ( FileSource :: new_with_query (
705
650
self . page . file_path ( ) . owned ( ) . await ?,
651
+ // When creating a data endpoint we also create an Html endpoint for the same source
652
+ // So add a query parameter to differentiate between the two.
653
+ if self . ty == PageEndpointType :: Data {
654
+ rcstr ! ( "?server-data" )
655
+ } else {
656
+ RcStr :: default ( )
657
+ } ,
706
658
) ) )
707
659
}
708
660
@@ -873,10 +825,10 @@ impl PageEndpoint {
873
825
this. pages_project . edge_ssr_module_context ( ) ,
874
826
) ,
875
827
PageEndpointType :: Data => (
876
- ReferenceType :: Entry ( EntryReferenceSubType :: Page ) ,
828
+ ReferenceType :: Entry ( EntryReferenceSubType :: PageData ) ,
877
829
this. pages_project . project ( ) . project_path ( ) . owned ( ) . await ?,
878
- this. pages_project . ssr_data_module_context ( ) ,
879
- this. pages_project . edge_ssr_data_module_context ( ) ,
830
+ this. pages_project . ssr_module_context ( ) ,
831
+ this. pages_project . edge_ssr_module_context ( ) ,
880
832
) ,
881
833
PageEndpointType :: Api => (
882
834
ReferenceType :: Entry ( EntryReferenceSubType :: PagesApi ) ,
@@ -886,10 +838,6 @@ impl PageEndpoint {
886
838
) ,
887
839
} ;
888
840
889
- let ssr_module = module_context
890
- . process ( self . source ( ) , reference_type. clone ( ) )
891
- . module ( ) ;
892
-
893
841
let config =
894
842
parse_segment_config_from_source ( self . source ( ) , ParseSegmentMode :: Base ) . await ?;
895
843
@@ -900,6 +848,9 @@ impl PageEndpoint {
900
848
// wrapped in the route module, and don't need to be handled as edge runtime as the
901
849
// rendering for edge is part of the page bundle.
902
850
if this. pathname == "/_app" || this. pathname == "/_document" {
851
+ let ssr_module = module_context
852
+ . process ( self . source ( ) , reference_type)
853
+ . module ( ) ;
903
854
InternalSsrChunkModule {
904
855
ssr_module : ssr_module. to_resolved ( ) . await ?,
905
856
app_module : None ,
0 commit comments