vercel / vercel/next.js

Turbopack `resolveAlias` doesn't resolve package subpath exports for transitive dependencies

Open
#88,540 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Turbopack
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://github.com/amannn/nextjs-bug-repro-turbo-alias

To Reproduce
git clone https://github.com/amannn/nextjs-bug-repro-turbo-alias
pnpm install
pnpm run dev
open http://localhost:3000

Relevant files:

Current vs. Expected behavior
Current Expected
Page displays "original" "aliased"
Module loaded test-pkg/foodist/foo.js test-pkg/foo/altdist/foo-alt.js

The alias works correctly when test-pkg is a direct dependency, but fails when it's a transitive dependency (nested in wrapper-pkg/node_modules).

Provide environment information
Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 24.6.0: Wed Nov  5 21:30:23 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_X86_64
  Available memory (MB): 16384
  Available CPU cores: 12
Binaries:
  Node: 22.21.1
  npm: 10.9.4
  Yarn: 1.22.22
  pnpm: 10.24.0
Relevant Packages:
  next: 16.1.1-canary.27 // Latest available version is detected (16.1.1-canary.27).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A
Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local)

Additional context

Workaround: use require.resolve() to get the actual file path and convert to a relative path

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Clone the linked reproduction, run pnpm install and pnpm run dev, and inspect apps/web/next.config.ts alongside the wrapper-pkg and test-pkg files named in the report. Trace how Turbopack applies resolveAlias through the transitive dependency and package subpath exports; done means the page displays "aliased" and loads test-pkg/foo/alt rather than the original module.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, next.js, node.js, react, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.