@@ -291,6 +291,8 @@ async function patchNextModules(
291
291
export const copyNextDependencies = async ( ctx : PluginContext ) : Promise < void > => {
292
292
await tracer . withActiveSpan ( 'copyNextDependencies' , async ( ) => {
293
293
const entries = await readdir ( ctx . standaloneDir )
294
+ const filter = ctx . constants . IS_LOCAL ? undefined : nodeModulesFilter
295
+
294
296
const promises : Promise < void > [ ] = entries . map ( async ( entry ) => {
295
297
// copy all except the distDir (.next) folder as this is handled in a separate function
296
298
// this will include the node_modules folder as well
@@ -299,7 +301,6 @@ export const copyNextDependencies = async (ctx: PluginContext): Promise<void> =>
299
301
}
300
302
const src = join ( ctx . standaloneDir , entry )
301
303
const dest = join ( ctx . serverHandlerDir , entry )
302
- const filter = ctx . constants . IS_LOCAL ? undefined : nodeModulesFilter
303
304
await cp ( src , dest , {
304
305
recursive : true ,
305
306
verbatimSymlinks : true ,
@@ -321,7 +322,7 @@ export const copyNextDependencies = async (ctx: PluginContext): Promise<void> =>
321
322
// see: https://github.com/vercel/next.js/issues/50072
322
323
if ( existsSync ( rootSrcDir ) && ctx . standaloneRootDir !== ctx . standaloneDir ) {
323
324
promises . push (
324
- cp ( rootSrcDir , rootDestDir , { recursive : true , verbatimSymlinks : true } ) . then ( ( ) =>
325
+ cp ( rootSrcDir , rootDestDir , { recursive : true , verbatimSymlinks : true , filter } ) . then ( ( ) =>
325
326
recreateNodeModuleSymlinks ( resolve ( 'node_modules' ) , rootDestDir ) ,
326
327
) ,
327
328
)
0 commit comments