AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Turbopack 16.3: Nft.Json Drops Store Target Files For An ESM ServerExternalPackage Reached Via A 'Use Client' Component In A Shared SSR-Layer Chunk → Dangling Alias → ERR_MODULE_NOT_FOUND On Vercel

In Next.js 16.3 with Turbopack, when an externalized server package is referenced only from a shared SSR-layer chunk (generated for 'use client' components), routes that do not import the package can have the package's content-hashed alias symlink in their .nft.json but not the corresponding store target files. This causes Vercel to pack a dangling symlink, leading to ERR_MODULE_NOT_FOUND and HTTP 500 on affected routes.

highConfidence 90%Next.jsAffected V16.3.0-Preview.6Affected V16.3.0-Canary.86

Origin Analysis

The endpoint file tracer for nft.json includes the alias symlink for a shared SSR chunk because the chunk's specifier string physically contains the alias, but it only traces the store target files for packages present in the endpoint's own module graph. For a shared SSR chunk referenced by endpoints that do not import the package, the alias is collected without its resolved store target, producing a broken trace.
1. Create a Next.js 16.3 app with Turbopack and `serverExternalPackages` including a package like `@ai-sdk/google`. 2. Import the package transitively through a `'use client'` component that gets bundled into a shared SSR-layer chunk, ensuring another route (e.g. auth page) does not import the package but shares the chunk. 3. Run `next build` with a package manager using an isolated linker (e.g. bun). 4. Inspect the `.nft.json` of the non-importing route: it contains the package's content-hashed alias symlink but no store target files. 5. Deploy to Vercel: the route fails with `ERR_MODULE_NOT_FOUND`.

Fixing Code Block

Edge Case Audit

The script adds the entire resolved package directory to the nft trace, which may increase deployment size and include unnecessary files (source maps, test files). It relies on Node.js `fs.realpathSync` and recursive directory walking; on Windows, path separators are normalized for nft. It should be run after `next build` and before deployment; remove the script and revert nft files to rollback. Test thoroughly across platforms and package managers, especially with pnpm/yarn PnP layouts. This is a temporary workaround until the upstream tracer is fixed.

Ecosystem Topology