Skip to content

[Turbopack] Import statements are not resolved in the order specified in the resolve extensions config #91117

@gabrieltrompiz

Description

@gabrieltrompiz

Link to the code that reproduces this issue

https://github.com/gabrieltrompiz/turbopack-rn-reproduction-app

To Reproduce

  1. Start the application in dev mode (pnpm dev, yarn dev or npm run dev)
  2. Go to localhost:3000 (or whatever port Next is using)

Current vs. Expected behavior

Using Turbopack, the app throws an error while compiling the page because it tries to import React Native code. I assume this happens because it's not resolving the modules using the order specified in the resolve extensions config. The extension web.js should be evaluated before .js since that's the usual way third-party React Native libraries allow for React Native for Web usage.

If Webpack is used (with --webpack flag), then the application compiles successfully. I would expect the resolve extensions from Turbopack to work similarly to how Webpack resolve extensions option works.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.2.0: Tue Nov 18 21:07:05 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6020
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 24.11.1
  npm: 11.6.2
  Yarn: 1.22.22
  pnpm: 10.26.2
Relevant Packages:
  next: 16.2.0-canary.85 // Latest available version is detected (16.2.0-canary.85).
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  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

Next config being used:

const nextConfig: NextConfig = {
  turbopack: {
    resolveAlias: {
      "react-native": "react-native-web",
    },
    resolveExtensions: [
      ".web.js",
      ".web.jsx",
      ".web.ts",
      ".web.tsx",
      ".mdx",
      ".tsx",
      ".ts",
      ".jsx",
      ".js",
      ".mjs",
      ".json",
    ],
    root: __dirname,
  },

  webpack: (config) => {
    config.resolve.alias = {
      ...(config.resolve.alias || {}),
      // Transform all direct `react-native` imports to `react-native-web`
      "react-native$": "react-native-web",
    };
    config.resolve.extensions = [
      ".web.js",
      ".web.jsx",
      ".web.ts",
      ".web.tsx",
      ...config.resolve.extensions,
    ];
    return config;
  },
};

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