@@ -38,9 +38,8 @@ export async function copyTracedFiles(
38
38
const standaloneNextDir = path . join ( standaloneDir , packagePath , ".next" ) ;
39
39
const outputNextDir = path . join ( outputDir , packagePath , ".next" ) ;
40
40
41
- const extractFiles = ( files : string [ ] , from = standaloneNextDir ) => {
42
- return files . map ( ( f ) => path . resolve ( from , f ) ) ;
43
- } ;
41
+ const extractFiles = ( files : string [ ] , from = standaloneNextDir ) =>
42
+ files . map ( ( f ) => path . resolve ( from , f ) ) ;
44
43
45
44
// On next 14+, we might not have to include those files
46
45
// For next 13, we need to include them otherwise we get runtime error
@@ -203,25 +202,36 @@ File ${fullFilePath} does not exist
203
202
}
204
203
} ) ;
205
204
206
- readdirSync ( standaloneNextDir ) . forEach ( ( f ) => {
207
- if ( statSync ( path . join ( standaloneNextDir , f ) ) . isDirectory ( ) ) return ;
208
- copyFileSync ( path . join ( standaloneNextDir , f ) , path . join ( outputNextDir , f ) ) ;
209
- } ) ;
205
+ readdirSync ( standaloneNextDir )
206
+ . filter (
207
+ ( fileOrDir ) =>
208
+ ! statSync ( path . join ( standaloneNextDir , fileOrDir ) ) . isDirectory ( ) ,
209
+ )
210
+ . forEach ( ( file ) =>
211
+ copyFileSync (
212
+ path . join ( standaloneNextDir , file ) ,
213
+ path . join ( outputNextDir , file ) ,
214
+ ) ,
215
+ ) ;
210
216
211
217
// We then need to copy all the files at the root of server
212
218
213
219
mkdirSync ( path . join ( outputNextDir , "server" ) , { recursive : true } ) ;
214
220
215
- readdirSync ( path . join ( standaloneNextDir , "server" ) ) . forEach ( ( f ) => {
216
- if ( statSync ( path . join ( standaloneNextDir , "server" , f ) ) . isDirectory ( ) )
217
- return ;
218
- if ( f !== "server.js" ) {
221
+ readdirSync ( path . join ( standaloneNextDir , "server" ) )
222
+ . filter (
223
+ ( fileOrDir ) =>
224
+ ! statSync (
225
+ path . join ( standaloneNextDir , "server" , fileOrDir ) ,
226
+ ) . isDirectory ( ) ,
227
+ )
228
+ . filter ( ( file ) => file !== "server.js" )
229
+ . forEach ( ( file ) =>
219
230
copyFileSync (
220
- path . join ( standaloneNextDir , "server" , f ) ,
221
- path . join ( path . join ( outputNextDir , "server" ) , f ) ,
222
- ) ;
223
- }
224
- } ) ;
231
+ path . join ( standaloneNextDir , "server" , file ) ,
232
+ path . join ( path . join ( outputNextDir , "server" ) , file ) ,
233
+ ) ,
234
+ ) ;
225
235
226
236
// Copy patch file
227
237
copyPatchFile ( path . join ( outputDir , packagePath ) ) ;
@@ -285,11 +295,9 @@ File ${fullFilePath} does not exist
285
295
}
286
296
} ) ;
287
297
288
- staticFiles . forEach ( ( f : string ) => {
289
- if ( f . endsWith ( ".html" ) ) {
290
- copyStaticFile ( `server/${ f } ` ) ;
291
- }
292
- } ) ;
298
+ staticFiles
299
+ . filter ( ( file ) => file . endsWith ( ".html" ) )
300
+ . forEach ( ( file ) => copyStaticFile ( `server/${ file } ` ) ) ;
293
301
}
294
302
295
303
logger . debug ( "copyTracedFiles:" , Date . now ( ) - tsStart , "ms" ) ;
0 commit comments