Repository: vercel/next.js
Pull request: Turbopack: include fewer traced files for standalone

This removes quite a lot of files.

But some of them are simply needed because we load `build/swc/index.js`, e.g. the two following examples. Removing them would require some more refactoring.

<img width="1274" height="680" alt="Bildschirmfoto 2026-01-09 um 14 22 07" src="https://github.com/user-attachments/assets/2354b9f2-1bfd-438d-af54-e69e8934cbc4" />
<img width="1346" height="474" alt="Bildschirmfoto 2026-01-09 um 14 23 15" src="https://github.com/user-attachments/assets/8f516cd6-321e-4f9c-bade-19eed7093c88" />


Changed files:
filename: packages/next/src/build/utils.ts
patch: @@ -1263,7 +1263,10 @@ export async function copyTracedFiles(
   }
   try {
     const packageJsonPath = path.join(distDir, '../package.json')
-    const packageJsonContent = await fs.readFile(packageJsonPath, 'utf8')
+    const packageJsonContent = await fs.readFile(
+      /* turbopackIgnore: true */ packageJsonPath,
+      'utf8'
+    )
     const packageJson = JSON.parse(packageJsonContent)
     moduleType = packageJson.type === 'module'
 
@@ -1280,7 +1283,9 @@ export async function copyTracedFiles(
   const copiedFiles = new Set()
 
   async function handleTraceFiles(traceFilePath: string) {
-    const traceData = JSON.parse(await fs.readFile(traceFilePath, 'utf8')) as {
+    const traceData = JSON.parse(
+      await fs.readFile(/* turbopackIgnore: true */ traceFilePath, 'utf8')
+    ) as {
       files: string[]
     }
     const copySema = new Sema(10, { capacity: traceData.files.length })

filename: test/production/next-server-nft/next-server-nft.test.ts
patch: @@ -134,256 +134,22 @@ async function readNormalizedNFT(next, name) {
            "/node_modules/@swc/helpers/*",
            "/node_modules/client-only/*",
            "/node_modules/detect-libc/*",
-           "/node_modules/next/dist/build/adapter/build-complete.js",
-           "/node_modules/next/dist/build/after-production-compile.js",
-           "/node_modules/next/dist/build/analysis/extract-const-value.js",
-           "/node_modules/next/dist/build/analysis/get-page-static-info.js",
-           "/node_modules/next/dist/build/analysis/parse-module.js",
-           "/node_modules/next/dist/build/analyze/index.js",
-           "/node_modules/next/dist/build/babel/loader/get-config.js",
-           "/node_modules/next/dist/build/babel/loader/index.js",
-           "/node_modules/next/dist/build/babel/loader/transform.js",
-           "/node_modules/next/dist/build/babel/loader/util.js",
-           "/node_modules/next/dist/build/babel/plugins/commonjs.js",
-           "/node_modules/next/dist/build/babel/plugins/jsx-pragma.js",
-           "/node_modules/next/dist/build/babel/plugins/next-font-unsupported.js",
-           "/node_modules/next/dist/build/babel/plugins/next-page-config.js",
-           "/node_modules/next/dist/build/babel/plugins/next-page-disallow-re-export-all-exports.js",
-           "/node_modules/next/dist/build/babel/plugins/next-ssg-transform.js",
-           "/node_modules/next/dist/build/babel/plugins/optimize-hook-destructuring.js",
-           "/node_modules/next/dist/build/babel/plugins/react-loadable-plugin.js",
-           "/node_modules/next/dist/build/babel/preset.js",
-           "/node_modules/next/dist/build/build-context.js",
-           "/node_modules/next/dist/build/collect-build-traces.js",
-           "/node_modules/next/dist/build/compiler.js",
-           "/node_modules/next/dist/build/create-compiler-aliases.js",
            "/node_modules/next/dist/build/define-env.js",
            "/node_modules/next/dist/build/duration-to-string.js",
-           "/node_modules/next/dist/build/entries.js",
-           "/node_modules/next/dist/build/generate-build-id.js",
-           "/node_modules/next/dist/build/generate-routes-manifest.js",
-           "/node_modules/next/dist/build/get-babel-config-file.js",
-           "/node_modules/next/dist/build/get-babel-loader-config.js",
-           "/node_modules/next/dist/build/get-static-info-including-layouts.js",
-           "/node_modules/next/dist/build/handle-entrypoints.js",
-           "/node_modules/next/dist/build/handle-externals.js",
-           "/node_modules/next/dist/build/index.js",
-           "/node_modules/next/dist/build/is-writeable.js",
-           "/node_modules/next/dist/build/jest/__mocks__/empty.js",
-           "/node_modules/next/dist/build/jest/__mocks__/fileMock.js",
-           "/node_modules/next/dist/build/jest/__mocks__/nextFontMock.js",
-           "/node_modules/next/dist/build/jest/__mocks__/styleMock.js",
-           "/node_modules/next/dist/build/jest/jest.js",
-           "/node_modules/next/dist/build/jest/object-proxy.js",
-           "/node_modules/next/dist/build/load-entrypoint.js",
-           "/node_modules/next/dist/build/load-jsconfig.js",
-           "/node_modules/next/dist/build/lockfile.js",
-           "/node_modules/next/dist/build/manifests/formatter/format-manifest.js",
            "/node_modules/next/dist/build/next-config-ts/require-hook.js",
            "/node_modules/next/dist/build/next-config-ts/transpile-config.js",
-           "/node_modules/next/dist/build/next-dir-paths.js",
-           "/node_modules/next/dist/build/normalize-catchall-routes.js",
            "/node_modules/next/dist/build/output/format.js",
-           "/node_modules/next/dist/build/output/index.js",
            "/node_modules/next/dist/build/output/log.js",
-           "/node_modules/next/dist/build/output/store.js",
-           "/node_modules/next/dist/build/page-extensions-type.js",
-           "/node_modules/next/dist/build/polyfills/fetch/index.js",
-           "/node_modules/next/dist/build/polyfills/fetch/whatwg-fetch.js",
-           "/node_modules/next/dist/build/polyfills/object-assign.js",
-           "/node_modules/next/dist/build/polyfills/object.assign/auto.js",
-           "/node_modules/next/dist/build/polyfills/object.assign/implementation.js",
-           "/node_modules/next/dist/build/polyfills/object.assign/index.js",
-           "/node_modules/next/dist/build/polyfills/object.assign/polyfill.js",
-           "/node_modules/next/dist/build/polyfills/object.assign/shim.js",
-           "/node_modules/next/dist/build/polyfills/polyfill-module.js",
-           "/node_modules/next/dist/build/polyfills/polyfill-nomodule.js",
-           "/node_modules/next/dist/build/polyfills/process.js",
-           "/node_modules/next/dist/build/preview-key-utils.js",
-           "/node_modules/next/dist/build/progress.js",
-           "/node_modules/next/dist/build/rendering-mode.js",
            "/node_modules/next/dist/build/segment-config/app/app-segment-config.js",
            "/node_modules/next/dist/build/segment-config/app/app-segments.js",
            "/node_modules/next/dist/build/segment-config/app/collect-root-param-keys.js",
-           "/node_modules/next/dist/build/segment-config/middleware/middleware-config.js",
-           "/node_modules/next/dist/build/segment-config/pages/pages-segment-config.js",
-           "/node_modules/next/dist/build/sort-by-page-exts.js",
-           "/node_modules/next/dist/build/spinner.js",
            "/node_modules/next/dist/build/static-paths/app.js",
            "/node_modules/next/dist/build/static-paths/app/extract-pathname-route-param-segments-from-loader-tree.js",
            "/node_modules/next/dist/build/static-paths/pages.js",
-           "/node_modules/next/dist/build/static-paths/types.js",
            "/node_modules/next/dist/build/static-paths/utils.js",
-           "/node_modules/next/dist/build/swc/helpers.js",
            "/node_modules/next/dist/build/swc/index.js",
-           "/node_modules/next/dist/build/swc/install-bindings.js",
-           "/node_modules/next/dist/build/swc/jest-transformer.js",
            "/node_modules/next/dist/build/swc/options.js",
-           "/node_modules/next/dist/build/swc/types.js",
-           "/node_modules/next/dist/build/templates/app-page.js",
-           "/node_modules/next/dist/build/templates/app-route.js",
-           "/node_modules/next/dist/build/templates/edge-app-route.js",
-           "/node_modules/next/dist/build/templates/edge-ssr-app.js",
-           "/node_modules/next/dist/build/templates/edge-ssr.js",
-           "/node_modules/next/dist/build/templates/edge-wrapper.js",
-           "/node_modules/next/dist/build/templates/helpers.js",
-           "/node_modules/next/dist/build/templates/middleware.js",
-           "/node_modules/next/dist/build/templates/pages-api.js",
-           "/node_modules/next/dist/build/templates/pages-edge-api.js",
-           "/node_modules/next/dist/build/templates/pages.js",
-           "/node_modules/next/dist/build/turbopack-analyze/index.js",
-           "/node_modules/next/dist/build/turbopack-build/impl.js",
-           "/node_modules/next/dist/build/turbopack-build/index.js",
-           "/node_modules/next/dist/build/turborepo-access-trace/env.js",
-           "/node_modules/next/dist/build/turborepo-access-trace/helpers.js",
-           "/node_modules/next/dist/build/turborepo-access-trace/index.js",
-           "/node_modules/next/dist/build/turborepo-access-trace/result.js",
-           "/node_modules/next/dist/build/turborepo-access-trace/tcp.js",
-           "/node_modules/next/dist/build/turborepo-access-trace/types.js",
-           "/node_modules/next/dist/build/type-check.js",
            "/node_modules/next/dist/build/utils.js",
-           "/node_modules/next/dist/build/validate-app-paths.js",
-           "/node_modules/next/dist/build/webpack-build/impl.js",
-           "/node_modules/next/dist/build/webpack-build/index.js",
-           "/node_modules/next/dist/build/webpack-config-rules/resolve.js",
-           "/node_modules/next/dist/build/webpack-config.js",
-           "/node_modules/next/dist/build/webpack/alias/react-dom-server-experimental.js",
-           "/node_modules/next/dist/build/webpack/alias/react-dom-server.js",
-           "/node_modules/next/dist/build/webpack/cache-invalidation.js",
-           "/node_modules/next/dist/build/webpack/config/blocks/base.js",
-           "/node_modules/next/dist/build/webpack/config/blocks/css/index.js",
-           "/node_modules/next/dist/build/webpack/config/blocks/css/loaders/client.js",
-           "/node_modules/next/dist/build/webpack/config/blocks/css/loaders/file-resolve.js",
-           "/node_modules/next/dist/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.js",
-           "/node_modules/next/dist/build/webpack/config/blocks/css/loaders/global.js",
-           "/node_modules/next/dist/build/webpack/config/blocks/css/loaders/index.js",
-           "/node_modules/next/dist/build/webpack/config/blocks/css/loaders/modules.js",
-           "/node_modules/next/dist/build/webpack/config/blocks/css/loaders/next-font.js",
-           "/node_modules/next/dist/build/webpack/config/blocks/css/messages.js",
-           "/node_modules/next/dist/build/webpack/config/blocks/css/plugins.js",
-           "/node_modules/next/dist/build/webpack/config/blocks/images/index.js",
-           "/node_modules/next/dist/build/webpack/config/blocks/images/messages.js",
-           "/node_modules/next/dist/build/webpack/config/helpers.js",
-           "/node_modules/next/dist/build/webpack/config/index.js",
-           "/node_modules/next/dist/build/webpack/config/utils.js",
-           "/node_modules/next/dist/build/webpack/loaders/css-loader/src/CssSyntaxError.js",
-           "/node_modules/next/dist/build/webpack/loaders/css-loader/src/camelcase.js",
-           "/node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js",
-           "/node_modules/next/dist/build/webpack/loaders/css-loader/src/plugins/index.js",
-           "/node_modules/next/dist/build/webpack/loaders/css-loader/src/plugins/postcss-icss-parser.js",
-           "/node_modules/next/dist/build/webpack/loaders/css-loader/src/plugins/postcss-import-parser.js",
-           "/node_modules/next/dist/build/webpack/loaders/css-loader/src/plugins/postcss-url-parser.js",
-           "/node_modules/next/dist/build/webpack/loaders/css-loader/src/runtime/api.js",
-           "/node_modules/next/dist/build/webpack/loaders/css-loader/src/runtime/getUrl.js",
-           "/node_modules/next/dist/build/webpack/loaders/css-loader/src/utils.js",
-           "/node_modules/next/dist/build/webpack/loaders/devtool/devtool-style-inject.js",
-           "/node_modules/next/dist/build/webpack/loaders/empty-loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/error-loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/get-module-build-info.js",
-           "/node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/codegen.js",
-           "/node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/index.js",
-           "/node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/interface.js",
-           "/node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/minify.js",
-           "/node_modules/next/dist/build/webpack/loaders/lightningcss-loader/src/utils.js",
-           "/node_modules/next/dist/build/webpack/loaders/metadata/discover.js",
-           "/node_modules/next/dist/build/webpack/loaders/metadata/resolve-route-data.js",
-           "/node_modules/next/dist/build/webpack/loaders/metadata/types.js",
-           "/node_modules/next/dist/build/webpack/loaders/modularize-import-loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-app-loader/create-app-route-code.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-app-loader/index.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-barrel-loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-client-pages-loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-edge-app-route-loader/index.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-edge-function-loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-edge-ssr-loader/index.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-error-browser-binary-loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-flight-action-entry-loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-flight-client-entry-loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-flight-client-module-loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-flight-css-loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-flight-loader/action-client-wrapper.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-flight-loader/action-validate.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-flight-loader/cache-wrapper.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-flight-loader/index.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-flight-loader/module-proxy.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-flight-loader/server-reference.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-flight-loader/track-dynamic-import.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-flight-server-reference-proxy-loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-font-loader/index.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-font-loader/postcss-next-font.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-image-loader/blur.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-image-loader/index.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-invalid-import-error-loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-metadata-image-loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-metadata-route-loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-middleware-asset-loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-middleware-loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-middleware-wasm-loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-root-params-loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-route-loader/index.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-style-loader/index.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-style-loader/runtime/injectStylesIntoLinkTag.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-style-loader/runtime/injectStylesIntoStyleTag.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-style-loader/runtime/isEqualLocals.js",
-           "/node_modules/next/dist/build/webpack/loaders/next-swc-loader.js",
-           "/node_modules/next/dist/build/webpack/loaders/postcss-loader/src/Error.js",
-           "/node_modules/next/dist/build/webpack/loaders/postcss-loader/src/Warning.js",
-           "/node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js",
-           "/node_modules/next/dist/build/webpack/loaders/postcss-loader/src/utils.js",
-           "/node_modules/next/dist/build/webpack/loaders/resolve-url-loader/index.js",
-           "/node_modules/next/dist/build/webpack/loaders/resolve-url-loader/lib/file-protocol.js",
-           "/node_modules/next/dist/build/webpack/loaders/resolve-url-loader/lib/join-function.js",
-           "/node_modules/next/dist/build/webpack/loaders/resolve-url-loader/lib/postcss.js",
-           "/node_modules/next/dist/build/webpack/loaders/resolve-url-loader/lib/value-processor.js",
-           "/node_modules/next/dist/build/webpack/loaders/utils.js",
-           "/node_modules/next/dist/build/webpack/plugins/build-manifest-plugin-utils.js",
-           "/node_modules/next/dist/build/webpack/plugins/build-manifest-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/copy-file-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/css-chunking-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/css-minimizer-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/devtools-ignore-list-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/eval-source-map-dev-tool-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/flight-client-entry-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/flight-manifest-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/force-complete-runtime.js",
-           "/node_modules/next/dist/build/webpack/plugins/jsconfig-paths-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/memory-with-gc-cache-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/middleware-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/mini-css-extract-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/minify-webpack-plugin/src/index.js",
-           "/node_modules/next/dist/build/webpack/plugins/next-font-manifest-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/next-trace-entrypoints-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/next-types-plugin/index.js",
-           "/node_modules/next/dist/build/webpack/plugins/next-types-plugin/shared.js",
-           "/node_modules/next/dist/build/webpack/plugins/nextjs-require-cache-hot-reloader.js",
-           "/node_modules/next/dist/build/webpack/plugins/optional-peer-dependency-resolve-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/pages-manifest-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/profiling-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/react-loadable-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/rspack-flight-client-entry-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/rspack-profiling-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/slow-module-detection-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/subresource-integrity-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/telemetry-plugin/telemetry-plugin.js",
-           "/node_modules/next/dist/build/webpack/plugins/telemetry-plugin/update-telemetry-loader-context-from-swc.js",
-           "/node_modules/next/dist/build/webpack/plugins/telemetry-plugin/use-cache-tracker-utils.js",
-           "/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/getModuleTrace.js",
-           "/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/index.js",
-           "/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parse-dynamic-code-evaluation-error.js",
-           "/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseBabel.js",
-           "/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseCss.js",
-           "/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseNextAppLoaderError.js",
-           "/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseNextFontError.js",
-           "/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseNextInvalidImportError.js",
-           "/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.js",
-           "/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/parseScss.js",
-           "/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/simpleWebpackError.js",
-           "/node_modules/next/dist/build/webpack/plugins/wellknown-errors-plugin/webpackModuleError.js",
-           "/node_modules/next/dist/build/webpack/stringify-request.js",
-           "/node_modules/next/dist/build/webpack/utils.js",
-           "/node_modules/next/dist/build/worker.js",
-           "/node_modules/next/dist/build/write-build-id.js",
            "/node_modules/next/dist/cli/next-test.js",
            "/node_modules/next/dist/client/*",
            "/node_modules/next/dist/compiled/@edge-runtime/cookies/index.js",