@@ -142,38 +142,12 @@ File ${fullFilePath} does not exist
142142 } ;
143143
144144 if ( existsSync ( path . join ( dotNextDir , "server/middleware.js.nft.json" ) ) ) {
145- //FIXME: This is a hack to make sure we include the middleware files
146- // Next should copy everything necessary into the standalone dir
147- // Once they've done that we can replace all these shenanigans with a single computeCopyFilesForPage
148- copyFileSync (
149- path . join ( dotNextDir , "server/middleware.js" ) ,
150- path . join ( standaloneNextDir , "server/middleware.js" ) ,
151- ) ;
145+ // We still need to copy the nft.json file so that computeCopyFilesForPage doesn't throw
152146 copyFileSync (
153147 path . join ( dotNextDir , "server/middleware.js.nft.json" ) ,
154148 path . join ( standaloneNextDir , "server/middleware.js.nft.json" ) ,
155149 ) ;
156- const requiredMiddlewareFiles = JSON . parse (
157- readFileSync (
158- path . join ( dotNextDir , "server/middleware.js.nft.json" ) ,
159- "utf8" ,
160- ) ,
161- ) ;
162- extractFiles (
163- requiredMiddlewareFiles . files . map ( ( f : string ) =>
164- f . startsWith ( "../" ) ? `../${ f } ` : `server/${ f } ` ,
165- ) ,
166- ) . forEach ( ( f ) => {
167- filesToCopy . set (
168- f ,
169- f
170- . replace ( standaloneDir , outputDir )
171- . replace (
172- path . join ( buildOutputPath , "node_modules" ) ,
173- path . join ( outputDir , "node_modules" ) ,
174- ) ,
175- ) ;
176- } ) ;
150+ computeCopyFilesForPage ( "middleware" ) ;
177151 }
178152
179153 const hasPageDir = routes . some ( ( route ) => route . startsWith ( "pages/" ) ) ;
0 commit comments