@@ -19,11 +19,10 @@ const rootParamsLoader: webpack.LoaderDefinitionFunction<RootParamsLoaderOpts> =
19
19
const allRootParams = await collectRootParamsFromFileSystem ( {
20
20
appDir,
21
21
pageExtensions,
22
- // Track every directory we traverse in case a layout gets added to it
23
- // (which would make it the new root layout for that subtree).
24
- // This is relevant both in dev (for file watching) and in prod (for caching).
25
- trackDirectory : ( directory ) => this . addContextDependency ( directory ) ,
26
22
} )
23
+ // invalidate the result whenever a file/directory is added/removed inside the app dir or its subdirectories,
24
+ // because that might mean that a root layout has been moved.
25
+ this . addContextDependency ( appDir )
27
26
28
27
// If there's no root params, there's nothing to generate.
29
28
if ( allRootParams . size === 0 ) {
@@ -78,11 +77,9 @@ function collectRootParams({
78
77
async function findRootLayouts ( {
79
78
appDir,
80
79
pageExtensions,
81
- trackDirectory,
82
80
} : {
83
81
appDir : string
84
82
pageExtensions : string [ ]
85
- trackDirectory : ( ( dirPath : string ) => void ) | undefined
86
83
} ) {
87
84
const layoutFilenameRegex = new RegExp (
88
85
`^layout\\.(?:${ pageExtensions . join ( '|' ) } )$`
@@ -106,8 +103,6 @@ async function findRootLayouts({
106
103
throw err
107
104
}
108
105
109
- trackDirectory ?.( directory )
110
-
111
106
const subdirectories : string [ ] = [ ]
112
107
for ( const entry of dir ) {
113
108
if ( entry . isDirectory ( ) ) {
0 commit comments