@@ -299,7 +299,12 @@ export const copyNextDependencies = async (ctx: PluginContext): Promise<void> =>
299299 }
300300 const src = join ( ctx . standaloneDir , entry )
301301 const dest = join ( ctx . serverHandlerDir , entry )
302- await cp ( src , dest , { recursive : true , verbatimSymlinks : true , force : true } )
302+ await cp ( src , dest , {
303+ recursive : true ,
304+ verbatimSymlinks : true ,
305+ force : true ,
306+ filter : nodeModulesFilter ,
307+ } )
303308
304309 if ( entry === 'node_modules' ) {
305310 await recreateNodeModuleSymlinks ( ctx . resolveFromSiteDir ( 'node_modules' ) , dest )
@@ -438,3 +443,21 @@ export const verifyHandlerDirStructure = async (ctx: PluginContext) => {
438443 )
439444 }
440445}
446+
447+ // This is a workaround for Next.js installations in a pnpm+glibc context
448+ // Patch required due to an intermittent upstream issue in the npm/pnpm ecosystem
449+ // https://github.com/pnpm/pnpm/issues/9654
450+ // https://github.com/pnpm/pnpm/issues/5928
451+ // https://github.com/pnpm/pnpm/issues/7362 (persisting even though ticket is closed)
452+ const nodeModulesFilter = async ( sourcePath : string ) => {
453+ // Filtering rule for the following packages:
454+ // - @rspack+binding-linux-x64-musl
455+ // - @swc+core-linux-x64-musl
456+ // - @img+sharp-linuxmusl-x64
457+ // - @img+sharp-libvips-linuxmusl-x64
458+ if ( sourcePath . includes ( 'linuxmusl-x64' ) || sourcePath . includes ( 'linux-x64-musl' ) ) {
459+ return false
460+ }
461+
462+ return true
463+ }
0 commit comments