@@ -156,15 +156,43 @@ export function createCacheAssets(options: buildHelper.BuildOptions) {
156
156
fs . writeFileSync ( cacheFilePath , JSON . stringify ( cacheFileContent ) ) ;
157
157
} ) ;
158
158
159
- if ( ! options . config . dangerous ?. disableTagCache ) {
160
- // Generate dynamodb data
161
- // We need to traverse the cache to find every .meta file
162
- const metaFiles : {
163
- tag : { S : string } ;
164
- path : { S : string } ;
165
- revalidatedAt : { N : string } ;
166
- } [ ] = [ ] ;
159
+ // We need to traverse the cache to find every .meta file
160
+ const metaFiles : {
161
+ tag : { S : string } ;
162
+ path : { S : string } ;
163
+ revalidatedAt : { N : string } ;
164
+ } [ ] = [ ] ;
165
+
166
+ // Copy fetch-cache to cache folder
167
+ const fetchCachePath = path . join (
168
+ appBuildOutputPath ,
169
+ ".next/cache/fetch-cache" ,
170
+ ) ;
171
+ if ( fs . existsSync ( fetchCachePath ) ) {
172
+ const fetchOutputPath = path . join ( outputDir , "cache" , "__fetch" , buildId ) ;
173
+ fs . mkdirSync ( fetchOutputPath , { recursive : true } ) ;
174
+ fs . cpSync ( fetchCachePath , fetchOutputPath , { recursive : true } ) ;
167
175
176
+ buildHelper . traverseFiles (
177
+ fetchCachePath ,
178
+ ( ) => true ,
179
+ ( { absolutePath, relativePath } ) => {
180
+ const fileContent = fs . readFileSync ( absolutePath , "utf8" ) ;
181
+ const fileData = JSON . parse ( fileContent ) ;
182
+ fileData ?. tags ?. forEach ( ( tag : string ) => {
183
+ metaFiles . push ( {
184
+ tag : { S : path . posix . join ( buildId , tag ) } ,
185
+ path : {
186
+ S : path . posix . join ( buildId , relativePath ) ,
187
+ } ,
188
+ revalidatedAt : { N : "1" } ,
189
+ } ) ;
190
+ } ) ;
191
+ } ,
192
+ ) ;
193
+ }
194
+
195
+ if ( ! options . config . dangerous ?. disableTagCache ) {
168
196
// Compute dynamodb cache data
169
197
// Traverse files inside cache to find all meta files and cache tags associated with them
170
198
buildHelper . traverseFiles (
@@ -194,35 +222,6 @@ export function createCacheAssets(options: buildHelper.BuildOptions) {
194
222
} ,
195
223
) ;
196
224
197
- // Copy fetch-cache to cache folder
198
- const fetchCachePath = path . join (
199
- appBuildOutputPath ,
200
- ".next/cache/fetch-cache" ,
201
- ) ;
202
- if ( fs . existsSync ( fetchCachePath ) ) {
203
- const fetchOutputPath = path . join ( outputDir , "cache" , "__fetch" , buildId ) ;
204
- fs . mkdirSync ( fetchOutputPath , { recursive : true } ) ;
205
- fs . cpSync ( fetchCachePath , fetchOutputPath , { recursive : true } ) ;
206
-
207
- buildHelper . traverseFiles (
208
- fetchCachePath ,
209
- ( ) => true ,
210
- ( { absolutePath, relativePath } ) => {
211
- const fileContent = fs . readFileSync ( absolutePath , "utf8" ) ;
212
- const fileData = JSON . parse ( fileContent ) ;
213
- fileData ?. tags ?. forEach ( ( tag : string ) => {
214
- metaFiles . push ( {
215
- tag : { S : path . posix . join ( buildId , tag ) } ,
216
- path : {
217
- S : path . posix . join ( buildId , relativePath ) ,
218
- } ,
219
- revalidatedAt : { N : "1" } ,
220
- } ) ;
221
- } ) ;
222
- } ,
223
- ) ;
224
- }
225
-
226
225
if ( metaFiles . length > 0 ) {
227
226
useTagCache = true ;
228
227
const providerPath = path . join ( outputDir , "dynamodb-provider" ) ;
0 commit comments