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

Turbopack Ignores Custom ResolveExtensions For Third-Party Dependencies

Next.js Turbopack does not apply user-configured resolveExtensions when resolving imports inside node_modules, causing platform-specific .web.js files to be skipped and breaking apps that depend on packages like react-native-mmkv.

highConfidence 85%Next.jsAffected V16.3.1-Canary.24

Origin Analysis

Turbopack's resolver uses built-in/default extension ordering for modules inside node_modules rather than the user-defined resolveExtensions list, so third-party packages that rely on extension priority (e.g. .web.js over .js) resolve to the wrong implementation.
1. Create a Next.js app with Turbopack enabled. 2. Add react-native-mmkv dependency. 3. Configure turbopack.resolveExtensions to prioritize .web.js extensions. 4. Import createMMKV from react-native-mmkv and run dev/build. Observe that the import resolves to createMMKV.js instead of createMMKV.web.js, leading to runtime errors.

Fixing Code Block

Edge Case Audit

This workaround is package-specific and path-sensitive; it may break if react-native-mmkv changes its internal file structure or if other third-party packages have similar needs. Rollback by removing the alias and upgrading to a Next.js version that fixes the resolver behavior. Not a general solution.

Ecosystem Topology