@@ -81,16 +81,27 @@ async function recreateNodeModuleSymlinks(src: string, dest: string, org?: strin
8181}
8282
8383export const copyNextDependencies = async ( ctx : PluginContext ) : Promise < void > => {
84- const srcDir = join ( ctx . publishDir , 'standalone/node_modules' )
85- const destDir = join ( ctx . serverHandlerDir , 'node_modules' )
84+ const entries = await readdir ( join ( ctx . publishDir , 'standalone' ) )
8685
87- await cp ( srcDir , destDir , { recursive : true } )
86+ await Promise . all (
87+ entries . map ( async ( entry ) => {
88+ if ( entry === 'package.json' || entry === '.next' ) {
89+ return
90+ }
91+ const src = join ( ctx . publishDir , 'standalone' , entry )
92+ const dest = join ( ctx . serverHandlerDir , entry )
93+ await cp ( src , dest , { recursive : true } )
94+ } ) ,
95+ )
8896
8997 // TODO: @Lukas Holzer test this in monorepos
9098 // use the node_modules tree from the process.cwd() and not the one from the standalone output
9199 // as the standalone node_modules are already wrongly assembled by Next.js.
92100 // see: https://github.com/vercel/next.js/issues/50072
93- await recreateNodeModuleSymlinks ( ctx . resolve ( 'node_modules' ) , destDir )
101+ await recreateNodeModuleSymlinks (
102+ ctx . resolve ( 'node_modules' ) ,
103+ join ( ctx . serverHandlerDir , 'node_modules' ) ,
104+ )
94105}
95106
96107export const writeTagsManifest = async ( ctx : PluginContext ) : Promise < void > => {
0 commit comments