Skip to main content

How to Migrate from Webpack to Turbopack

ERROR: This build is using Turbopack, but it has a Webpack config and no Turbopack config.

Published 2 min readMarkdown
How to Migrate from Webpack to Turbopack

Webpack and Turbopack are bundlers. A bundler is a tool that optimizes the browser’s performance by reducing the number of HTTP requests it makes. To make this possible, the bundler takes files in a web app and combines them into bundles.

Since NextJS 16, Turbopack is the default bundler used for local development. While this significantly speeds up build times, there’s a conflict since your default next.config.ts lacks the turbopackconfig. The compiler raises this error because it is uncertain whether your app will break without the Webpack config being replicated in Turbopack.

For example:

const nextConfig = {  
// NO TURBOPACK CONFIG
    webpack: (config: Configuration) => {
        config.experiments = {
          ...config.experiments,
          asyncWebAssembly: true,
          layers: true,
        };
}

A Quick Fix

You will silence the error by having your Webpack experiments and an empty turbopack config:

 const nextConfig = {
      experimental: {
        turbopack: {}, // SILENCE
      },
    webpack: (config) => {
      config.experiments = { asyncWebAssembly: true, layers: true };
      return config;
    },
};

An empty config works because Turbopack supports many standard Webpack features out of the box, and often doesn’t require an extra config for standard imports. You define aliases or loaders when needed.

Force Webpack

Explicitly tell NextJS to use Webpack by running your dev server with a flag:

iano@iano$ next dev --webpack

Alternatively, you can update the dev script in your package.json file:

"scripts": {
  "dev": "next dev --webpack"
}

About the author

No comments yet. Be the first to comment.