Skip to content

fix(turbopack): ignore missing optional peerDependencies - #97871

Open
scs0209 wants to merge 1 commit into
vercel:canaryfrom
scs0209:feat-turbopack-optional-peer-deps
Open

fix(turbopack): ignore missing optional peerDependencies#97871
scs0209 wants to merge 1 commit into
vercel:canaryfrom
scs0209:feat-turbopack-optional-peer-deps

Conversation

@scs0209

@scs0209 scs0209 commented Aug 25, 2026

Copy link
Copy Markdown

Bug

Fixes #97870

Turbopack fails to resolve packages that require() a missing optional peer dependency, while webpack succeeds via OptionalPeerDependencyResolverPlugin.

Reproduction: https://github.com/scs0209/nextjs-optional-peer-turbopack-repro

  • next build (Turbopack) → Module not found: Can't resolve 'foo'
  • next build --webpack → succeeds

Fix

In Turbopack module resolution, when a bare package request cannot be found, check the nearest package.json for peerDependenciesMeta[name].optional === true and resolve to Ignore (same outcome as webpack’s path: false).

Also restores the long-skipped e2e case in test/e2e/transpile-packages by moving the route out of the private _peer-deps folder (App Router ignores _ segments) to peer-deps.

Test plan

  • cargo test -p turbopack-tests --test execution optional_peer_dependency
  • Unskipped test/e2e/transpile-packages optional peer case (route rename)
  • CI e2e for test/e2e/transpile-packages

Made with Cursor

Co-authored-by: Cursor <cursoragent@cursor.com>
@scs0209
scs0209 force-pushed the feat-turbopack-optional-peer-deps branch from b5588fa to 818bf47 Compare August 25, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Turbopack: missing optional peerDependencies fail module resolution (webpack ignores them)

1 participant