Skip to content

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

@amannn

Description

@amannn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    TurbopackRelated to Turbopack with Next.js.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions