@@ -33,7 +33,6 @@ import {
33
33
COMPILER_NAMES ,
34
34
RSC_MODULE_TYPES ,
35
35
} from '../../shared/lib/constants'
36
- import { RouteMatch } from '../future/route-matches/route-match'
37
36
import { HMR_ACTIONS_SENT_TO_BROWSER } from './hot-reloader-types'
38
37
import HotReloader from './hot-reloader-webpack'
39
38
import { isAppPageRouteDefinition } from '../future/route-definitions/app-page-route-definition'
@@ -677,13 +676,13 @@ export function onDemandEntryHandler({
677
676
page,
678
677
clientOnly,
679
678
appPaths,
680
- match ,
679
+ definition ,
681
680
isApp,
682
681
} : {
683
682
page : string
684
683
clientOnly : boolean
685
684
appPaths : ReadonlyArray < string > | null
686
- match : Pick < RouteMatch , 'definition' > | undefined
685
+ definition : RouteDefinition | undefined
687
686
isApp : boolean | undefined
688
687
} ) : Promise < void > {
689
688
const stalledTime = 60
@@ -694,11 +693,11 @@ export function onDemandEntryHandler({
694
693
} , stalledTime * 1000 )
695
694
696
695
try {
697
- let definition : Pick < RouteDefinition , 'filename' | 'bundlePath' | 'page' >
698
- if ( match ?. definition ) {
699
- definition = match . definition
696
+ let route : Pick < RouteDefinition , 'filename' | 'bundlePath' | 'page' >
697
+ if ( definition ) {
698
+ route = definition
700
699
} else {
701
- definition = await findPagePathData (
700
+ route = await findPagePathData (
702
701
rootDir ,
703
702
page ,
704
703
nextConfig . pageExtensions ,
@@ -707,30 +706,26 @@ export function onDemandEntryHandler({
707
706
)
708
707
}
709
708
710
- const isInsideAppDir = ! ! appDir && definition . filename . startsWith ( appDir )
709
+ const isInsideAppDir = ! ! appDir && route . filename . startsWith ( appDir )
711
710
712
711
if ( typeof isApp === 'boolean' && isApp !== isInsideAppDir ) {
713
712
Error . stackTraceLimit = 15
714
713
throw new Error (
715
714
`Ensure bailed, found path "${
716
- definition . page
715
+ route . page
717
716
} " does not match ensure type (${ isApp ? 'app' : 'pages' } )`
718
717
)
719
718
}
720
719
721
- const pageBundleType = getPageBundleType ( definition . bundlePath )
720
+ const pageBundleType = getPageBundleType ( route . bundlePath )
722
721
const addEntry = (
723
722
compilerType : CompilerNameValues
724
723
) : {
725
724
entryKey : string
726
725
newEntry : boolean
727
726
shouldInvalidate : boolean
728
727
} => {
729
- const entryKey = getEntryKey (
730
- compilerType ,
731
- pageBundleType ,
732
- definition . page
733
- )
728
+ const entryKey = getEntryKey ( compilerType , pageBundleType , route . page )
734
729
if (
735
730
curEntries [ entryKey ] &&
736
731
// there can be an overlap in the entryKey for the instrumentation hook file and a page named the same
@@ -758,9 +753,9 @@ export function onDemandEntryHandler({
758
753
curEntries [ entryKey ] = {
759
754
type : EntryTypes . ENTRY ,
760
755
appPaths,
761
- absolutePagePath : definition . filename ,
762
- request : definition . filename ,
763
- bundlePath : definition . bundlePath ,
756
+ absolutePagePath : route . filename ,
757
+ request : route . filename ,
758
+ bundlePath : route . bundlePath ,
764
759
dispose : false ,
765
760
lastActiveTime : Date . now ( ) ,
766
761
status : ADDED ,
@@ -774,7 +769,7 @@ export function onDemandEntryHandler({
774
769
775
770
const staticInfo = await getStaticInfoIncludingLayouts ( {
776
771
page,
777
- pageFilePath : definition . filename ,
772
+ pageFilePath : route . filename ,
778
773
isInsideAppDir,
779
774
pageExtensions : nextConfig . pageExtensions ,
780
775
isDev : true ,
@@ -787,7 +782,7 @@ export function onDemandEntryHandler({
787
782
isInsideAppDir && staticInfo . rsc !== RSC_MODULE_TYPES . client
788
783
789
784
runDependingOnPageType ( {
790
- page : definition . page ,
785
+ page : route . page ,
791
786
pageRuntime : staticInfo . runtime ,
792
787
pageType : pageBundleType ,
793
788
onClient : ( ) => {
@@ -802,11 +797,11 @@ export function onDemandEntryHandler({
802
797
const edgeServerEntry = getEntryKey (
803
798
COMPILER_NAMES . edgeServer ,
804
799
pageBundleType ,
805
- definition . page
800
+ route . page
806
801
)
807
802
if (
808
803
curEntries [ edgeServerEntry ] &&
809
- ! isInstrumentationHookFile ( definition . page )
804
+ ! isInstrumentationHookFile ( route . page )
810
805
) {
811
806
// Runtime switched from edge to server
812
807
delete curEntries [ edgeServerEntry ]
@@ -820,11 +815,11 @@ export function onDemandEntryHandler({
820
815
const serverEntry = getEntryKey (
821
816
COMPILER_NAMES . server ,
822
817
pageBundleType ,
823
- definition . page
818
+ route . page
824
819
)
825
820
if (
826
821
curEntries [ serverEntry ] &&
827
- ! isInstrumentationHookFile ( definition . page )
822
+ ! isInstrumentationHookFile ( route . page )
828
823
) {
829
824
// Runtime switched from server to edge
830
825
delete curEntries [ serverEntry ]
@@ -839,9 +834,7 @@ export function onDemandEntryHandler({
839
834
const hasNewEntry = addedValues . some ( ( entry ) => entry . newEntry )
840
835
841
836
if ( hasNewEntry ) {
842
- reportTrigger (
843
- ! clientOnly && hasNewEntry ? `${ definition . page } ` : definition . page
844
- )
837
+ reportTrigger ( ! clientOnly && hasNewEntry ? `${ route . page } ` : route . page )
845
838
}
846
839
847
840
if ( entriesThatShouldBeInvalidated . length > 0 ) {
@@ -883,7 +876,7 @@ export function onDemandEntryHandler({
883
876
page : string
884
877
clientOnly : boolean
885
878
appPaths ?: ReadonlyArray < string > | null
886
- match ?: RouteMatch
879
+ definition ?: RouteDefinition
887
880
isApp ?: boolean
888
881
}
889
882
@@ -907,26 +900,28 @@ export function onDemandEntryHandler({
907
900
page,
908
901
clientOnly,
909
902
appPaths = null ,
910
- match ,
903
+ definition ,
911
904
isApp,
912
905
} : EnsurePageOptions ) {
913
906
// If the route is actually an app page route, then we should have access
914
- // to the app route match, and therefore, the appPaths from it.
915
- if (
916
- ! appPaths &&
917
- match ?. definition &&
918
- isAppPageRouteDefinition ( match . definition )
919
- ) {
920
- appPaths = match . definition . appPaths
907
+ // to the app route definition, and therefore, the appPaths from it.
908
+ if ( ! appPaths && definition && isAppPageRouteDefinition ( definition ) ) {
909
+ appPaths = definition . appPaths
921
910
}
922
911
923
912
// Wrap the invocation of the ensurePageImpl function in the pending
924
913
// wrapper, which will ensure that we don't have multiple compilations
925
914
// for the same page happening concurrently.
926
915
return batcher . batch (
927
- { page, clientOnly, appPaths, match , isApp } ,
916
+ { page, clientOnly, appPaths, definition , isApp } ,
928
917
async ( ) => {
929
- await ensurePageImpl ( { page, clientOnly, appPaths, match, isApp } )
918
+ await ensurePageImpl ( {
919
+ page,
920
+ clientOnly,
921
+ appPaths,
922
+ definition,
923
+ isApp,
924
+ } )
930
925
}
931
926
)
932
927
} ,
0 commit comments