[16.3] Turbopack: retain conditions when replacing resolve request keys - #97453
Merged
Merged
Conversation
) Closes #97358 `ResolveResult::with_replaced_request_key` overwrote the `conditions` of every result key with the conditions of the replacement key (empty at all call sites). Those conditions are what distinguishes the results one request resolved to under different export conditions, so both the `module-sync` and the `default`/`require` target of the same subpath ended up under the same `RequestKey`. That is lossy as soon as a request resolves in more than one `node_modules` directory: the results are merged through a `RequestKey`-keyed map, so one of the two targets is silently dropped. With a single candidate directory `ResolveResult::alternatives` short-circuits and never builds that map, which is why this only showed up in nested layouts. In practice this broke `output: 'standalone'` with the Turbopack production bundler for pnpm installs, whose virtual store hoists every package into `node_modules/.pnpm/node_modules` and thereby creates that second candidate directory: `next-server.js.nft.json` recorded only `@swc/helpers/cjs/_interop_require_default.cjs`, while Node >= 22.12 resolves `@swc/helpers/_/_interop_require_default` to the `module-sync` target `esm/_interop_require_default.js` (`@swc/helpers` 0.5.23 lists `module-sync` first). The copied `.next/standalone/server.js` then exited with MODULE_NOT_FOUND before listening. --------- Co-authored-by: vercel-fleet[bot] <308483924+vercel-fleet[bot]@users.noreply.github.com>
Contributor
Stats from current PR🔴 4 regressions, 1 improvement
📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles
Server Middleware
Build DetailsBuild Manifests
Build Cache
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📝 Changed Files (33 files)Files with changes:
View diffsapp-page-exp..ntime.dev.jsfailed to diffapp-page-exp..time.prod.jsfailed to diffapp-page-tur..ntime.dev.jsfailed to diffapp-page-tur..time.prod.jsfailed to diffapp-page-tur..ntime.dev.jsfailed to diffapp-page-tur..time.prod.jsfailed to diffapp-page.runtime.dev.jsfailed to diffapp-page.runtime.prod.jsfailed to diffapp-route-ex..ntime.dev.jsDiff too large to display app-route-ex..time.prod.jsDiff too large to display app-route-tu..ntime.dev.jsDiff too large to display app-route-tu..time.prod.jsDiff too large to display app-route-tu..ntime.dev.jsDiff too large to display app-route-tu..time.prod.jsDiff too large to display app-route.runtime.dev.jsDiff too large to display app-route.ru..time.prod.jsDiff too large to display dev-validati..ntime.dev.jsfailed to diffdev-validati..ntime.dev.jsfailed to diffdev-validati..ntime.dev.jsfailed to diffdev-validati..ntime.dev.jsfailed to diffpages-api-tu..ntime.dev.jsDiff too large to display pages-api-tu..time.prod.jsDiff too large to display pages-api.runtime.dev.jsDiff too large to display pages-api.ru..time.prod.jsDiff too large to display pages-turbo...ntime.dev.jsDiff too large to display pages-turbo...time.prod.jsDiff too large to display pages.runtime.dev.jsDiff too large to display pages.runtime.prod.jsDiff too large to display server.runtime.prod.jsDiff too large to display use-cache-pr..ntime.dev.jsDiff too large to display use-cache-pr..ntime.dev.jsDiff too large to display use-cache-pr..ntime.dev.jsDiff too large to display use-cache-pr..ntime.dev.jsDiff too large to display 📎 Tarball URLCommit: 363203e |
Contributor
Tests PassedCommit: 363203e |
sokra
approved these changes
Aug 19, 2026
owine
added a commit
to owine/house-manager
that referenced
this pull request
Aug 24, 2026
## Why now `next.config.ts` has carried a temporary `outputFileTracingIncludes` block since #414. Its delete condition — "the upstream backport ships in a stable release" — is now met: - **vercel/next.js#97453** (*Turbopack: retain conditions when replacing resolve request keys*) merged into the `next-16-3` branch on 2026-08-19 as `5ac2327`. - **v16.3.2** was published 2026-08-21. `gh api repos/vercel/next.js/compare/5ac2327...v16.3.2` reports `ahead_by: 3, behind_by: 0` — the tag contains the fix. - #425 brought 16.3.2 into `main`. ## Verification A fresh `pnpm build` with the block removed traces the helpers correctly on its own: ``` @swc/helpers/esm: _interop_require_default.js, _interop_require_wildcard.js @swc/helpers/cjs: _interop_require_default.cjs, _interop_require_wildcard.cjs ``` Both conditions are now emitted for each helper. Grepping the traced `next/dist` for `@swc/helpers/_/*` returns exactly those two names, so that is the complete set — the workaround's glob was copying all 108 `esm/` files to cover 2. The bug this guarded against (`createEsmNotFoundErr` at web boot) is only reproducible in the image, so **`build-image` + `scripts/smoke-image.sh` is the real gate here** — a local build resolves against the full source tree and can't see it. Deliberately a standalone PR, separate from the version bump, so a red CI is unambiguous about which change caused it. ## Summary by Sourcery Enhancements: - Remove the temporary SWC helpers file-tracing workaround now that the upstream Next.js fix is included in the stable release.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backports #97372