@@ -38,9 +38,8 @@ export async function copyTracedFiles(
3838 const standaloneNextDir = path . join ( standaloneDir , packagePath , ".next" ) ;
3939 const outputNextDir = path . join ( outputDir , packagePath , ".next" ) ;
4040
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 ) ) ;
4443
4544 // On next 14+, we might not have to include those files
4645 // For next 13, we need to include them otherwise we get runtime error
@@ -203,25 +202,36 @@ File ${fullFilePath} does not exist
203202 }
204203 } ) ;
205204
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+ ) ;
210216
211217 // We then need to copy all the files at the root of server
212218
213219 mkdirSync ( path . join ( outputNextDir , "server" ) , { recursive : true } ) ;
214220
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 ) =>
219230 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+ ) ;
225235
226236 // Copy patch file
227237 copyPatchFile ( path . join ( outputDir , packagePath ) ) ;
@@ -285,11 +295,9 @@ File ${fullFilePath} does not exist
285295 }
286296 } ) ;
287297
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 } ` ) ) ;
293301 }
294302
295303 logger . debug ( "copyTracedFiles:" , Date . now ( ) - tsStart , "ms" ) ;
0 commit comments