Next.js Discord

Discord Forum

Using Turbopack with resolveAlias

Unanswered
able_archer posted this in #help-forum
Open in Discord
Hello,

I am trying to migrate my project to Turbopack. We are migrating from a client-rendered React application and make heavy use of react-query, which is wrapped in an external library hosted in our private repository.

Due to this, we had previously run into an issue with react-query where we had to provide an alias to webpack. See: https://github.com/TanStack/query/issues/3595 for context.


const nextConfig = {
  ...otherConfig,
  webpack: (config, options) => {
    // Fix issues with react-query:
    config.resolve.alias['@tanstack/react-query'] = path.resolve(
      './node_modules/@tanstack/react-query',
    );

    return config;
  },
};


I am struggling to get this configuration working with Turbopack's resolveAlias.

My Turbopack config:

experimental: {
  turbo: {
    resolveAlias: {
      '@tanstack/react-query': './node_modules/@tanstack/react-query',
    },
  },
},

I can see a similar question asked on GitHub: https://github.com/vercel/turbo/issues/6291. But I am wondering and hoping someone here has the answer.

Thanks,
Alex

0 Replies