@@ -532,50 +532,48 @@ export async function handleBuildComplete({
532532 sharedNodeAssets [ path . relative ( tracingRoot , setupNodeStubPath ) ] =
533533 require . resolve ( 'next/dist/build/adapter/setup-node-env.external' )
534534
535- if ( bundler !== Bundler . Turbopack ) {
536- const moduleTypes = [ 'app-page' , 'pages' ] as const
535+ const moduleTypes = [ 'app-page' , 'pages' ] as const
537536
538- for ( const type of moduleTypes ) {
539- const currentDependencies : string [ ] = [ ]
540- const modulePath = require . resolve (
541- `next/dist/server/route-modules/${ type } /module.compiled`
542- )
543- const contextDir = path . join (
544- path . dirname ( modulePath ) ,
545- 'vendored' ,
546- 'contexts'
547- )
537+ for ( const type of moduleTypes ) {
538+ const currentDependencies : string [ ] = [ ]
539+ const modulePath = require . resolve (
540+ `next/dist/server/route-modules/${ type } /module.compiled`
541+ )
542+ currentDependencies . push ( modulePath )
548543
549- for ( const item of await fs . readdir ( contextDir ) ) {
550- if ( item . match ( / \. ( m j s | c j s | j s ) $ / ) ) {
551- currentDependencies . push ( path . join ( contextDir , item ) )
552- }
544+ const contextDir = path . join (
545+ path . dirname ( modulePath ) ,
546+ 'vendored' ,
547+ 'contexts'
548+ )
549+
550+ for ( const item of await fs . readdir ( contextDir ) ) {
551+ if ( item . match ( / \. ( m j s | c j s | j s ) $ / ) ) {
552+ currentDependencies . push ( path . join ( contextDir , item ) )
553553 }
554+ }
554555
555- const { fileList, esmFileList } = await nodeFileTrace (
556- currentDependencies ,
557- {
558- base : tracingRoot ,
559- ignore : sharedIgnoreFn ,
560- }
556+ for ( const dependencyPath of currentDependencies ) {
557+ const rootRelativeFilePath = path . relative (
558+ tracingRoot ,
559+ dependencyPath
561560 )
562- esmFileList . forEach ( ( item ) => fileList . add ( item ) )
563561
564- for ( const rootRelativeFilePath of fileList ) {
565- if ( type === 'pages' ) {
566- pagesSharedNodeAssets [ rootRelativeFilePath ] = path . join (
567- tracingRoot ,
568- rootRelativeFilePath
569- )
570- } else {
571- appPagesSharedNodeAssets [ rootRelativeFilePath ] = path . join (
572- tracingRoot ,
573- rootRelativeFilePath
574- )
575- }
562+ if ( type === 'pages' ) {
563+ pagesSharedNodeAssets [ rootRelativeFilePath ] = path . join (
564+ tracingRoot ,
565+ rootRelativeFilePath
566+ )
567+ } else {
568+ appPagesSharedNodeAssets [ rootRelativeFilePath ] = path . join (
569+ tracingRoot ,
570+ rootRelativeFilePath
571+ )
576572 }
577573 }
574+ }
578575
576+ if ( bundler !== Bundler . Turbopack ) {
579577 // These are modules that are necessary for bootstrapping node env
580578 const necessaryNodeDependencies = [
581579 require . resolve ( 'next/dist/server/node-environment' ) ,
0 commit comments