next dev and next build.
To use Webpack instead of Turbopack, pass the
--webpack flag to next dev or next build.Supported platforms
| Platform | Architectures |
|---|---|
| macOS | x64, ARM64 |
| Windows | x64, ARM64 |
| Linux (glibc) | x64, ARM64 |
| Linux (musl) | x64, ARM64 |
--webpack flag on those platforms.
Enabling Turbopack
Turbopack is enabled by default. No configuration is needed:package.json
package.json
Configuration
Turbopack is configured under theturbopack key in next.config.js:
next.config.js
Resolve aliases
Map module names to different packages, similar toresolve.alias in webpack:
A map of module name strings to their replacement module paths.
next.config.js
Resolve extensions
Change or extend the file extensions Turbopack resolves:Ordered list of file extensions to try when resolving imports without an extension.
next.config.js
Webpack loaders
Turbopack supports a subset of webpack loader semantics for transforming files:A map of glob patterns to loader configurations.
next.config.js
Loader paths or
{ loader, options } objects to apply in order.Rename the output file extension (e.g.
'*.js' to treat loader output as JavaScript).Root directory
The filesystem root used for module resolution. Defaults to the project directory. Set this when using symlinked packages outside the project root (e.g.
npm link).next.config.js
Experimental options
The following options are available underexperimental in next.config.js:
| Option | Description | Default (dev) | Default (build) |
|---|---|---|---|
turbopackFileSystemCacheForDev | Enable filesystem cache for the dev server | true | N/A |
turbopackFileSystemCacheForBuild | Enable filesystem cache for builds | N/A | false |
turbopackMinify | Enable minification | false | true |
turbopackSourceMaps | Enable source maps | true | productionBrowserSourceMaps |
turbopackInputSourceMaps | Extract source maps from input files | true | true |
turbopackTreeShaking | Use advanced module-fragments tree shaking | false | false |
turbopackRemoveUnusedImports | Remove unused imports (requires turbopackRemoveUnusedExports) | false | true |
turbopackRemoveUnusedExports | Remove unused exports | false | true |
turbopackModuleIds | Module ID strategy: 'named' or 'deterministic' | 'named' | 'deterministic' |
turbopackScopeHoisting | Enable scope hoisting (always off in dev) | false | true |
next.config.js
Known differences from webpack
Filesystem root
Turbopack resolves modules relative to the project root. Files and symlinks outside the root are not resolved by default. Useturbopack.root to extend the resolution boundary.
CSS module ordering
Turbopack orders CSS modules according to JavaScript import order. Webpack sometimes ignores this order for side-effect-free modules, which can cause subtle differences. To enforce CSS order, use@import in CSS modules:
button.module.css
Sass ~ imports
Webpack supports tilde (~) prefixes for Sass node_modules imports. Turbopack does not. Replace:
next.config.js
Webpack plugins
Turbopack does not support webpack plugins. Webpack loaders are supported via theturbopack.rules configuration.
Performance tracing
To generate a trace file for performance debugging:.next/dev/trace-turbopack file. Include it when reporting issues on the Next.js GitHub repository.
Version history
| Version | Changes |
|---|---|
v16.0.0 | Turbopack becomes the default bundler; automatic Babel support |
v15.5.0 | Turbopack build support in beta |
v15.3.0 | Experimental build support |
v15.0.0 | Turbopack dev stable |
