38850bf1ee
Co-authored-by: Balázs Orbán <info@balazsorban.com>
62 lines
3.8 KiB
Text
62 lines
3.8 KiB
Text
---
|
|
title: Turbopack
|
|
description: Turbopack is an incremental bundler optimized for JavaScript and TypeScript, written in Rust, and built into Next.js.
|
|
---
|
|
|
|
[Turbopack](https://turbo.build/pack) (beta) is an incremental bundler optimized for JavaScript and TypeScript, written in Rust, and built into Next.js.
|
|
|
|
## Usage
|
|
|
|
Turbopack can be used in Next.js in both the `pages` and `app` directories for faster local development. To enable Turbopack, use the `--turbo` flag when running the Next.js development server.
|
|
|
|
```json filename="package.json" highlight={3}
|
|
{
|
|
"scripts": {
|
|
"dev": "next dev --turbo",
|
|
"build": "next build",
|
|
"start": "next start",
|
|
"lint": "next lint"
|
|
}
|
|
}
|
|
```
|
|
|
|
## Supported features
|
|
|
|
Turbopack in Next.js requires zero-configuration for most users and can be extended for more advanced use cases. To learn more about the currently supported features for Turbopack, view the [API Reference](/docs/app/api-reference/next-config-js/turbo).
|
|
|
|
## Unsupported features
|
|
|
|
Turbopack currently only supports `next dev` and does not support `next build`. We are currently working on support for builds as we move closer towards stability.
|
|
|
|
These features are currently not supported:
|
|
|
|
- [`webpack()`](/docs/app/api-reference/next-config-js/webpack) configuration in `next.config.js`
|
|
- Turbopack replaces Webpack, this means that webpack configuration is not supported.
|
|
- To configure Turbopack, [see the documentation](/docs/app/api-reference/next-config-js/turbo).
|
|
- A subset of [Webpack loaders](/docs/app/api-reference/next-config-js/turbo#webpack-loaders) are supported in Turbopack.
|
|
- Babel (`.babelrc`)
|
|
- Turbopack leverages the [SWC](/docs/architecture/nextjs-compiler#why-swc) compiler for all transpilation and optimizations. This means that Babel is not included by default.
|
|
- If you have a `.babelrc` file, you might no longer need it because Next.js includes common Babel plugins as SWC transforms that can be enabled. You can read more about this in the [compiler documentation](docs/architecture/nextjs-compiler#supported-features).
|
|
- If you still need to use Babel after verifying your particular use case is not covered, you can leverage Turbopack's [support for custom webpack loaders](/docs/app/api-reference/next-config-js/turbo#webpack-loaders) to include `babel-loader`.
|
|
- Creating a root layout automatically in App Router.
|
|
- This behavior is currently not supported since it changes input files, instead, an error will be shown for you manually add a root layout in the desired location.
|
|
- `@next/font` (legacy font support).
|
|
- `@next/font` is deprecated in favor of `next/font`. [`next/font`](/docs/app/building-your-application/optimizing/fonts) is fully supported with Turbopack.
|
|
- `new Worker('file', import.meta.url)`.
|
|
- We are planning to implement this in the future.
|
|
- [Relay transforms](/docs/architecture/nextjs-compiler#relay)
|
|
- We are planning to implement this in the future.
|
|
- `experimental.nextScriptWorkers`
|
|
- We are planning to implement this in the future.
|
|
- [AMP](/docs/pages/building-your-application/configuring/amp).
|
|
- We are currently not planning to support AMP in Next.js with Turbopack.
|
|
- Yarn PnP
|
|
- We are currently not planning to support Yarn PnP in Next.js with Turbopack.
|
|
- [`experimental.urlImports`](/docs/app/api-reference/next-config-js/urlImports)
|
|
- We are currently not planning to support `experimental.urlImports` in Next.js with Turbopack.
|
|
|
|
## Generating Trace Files
|
|
|
|
Trace files allow the Next.js team to investigate and improve performance metrics and memory usage. To generate a trace file, append `NEXT_TURBOPACK_TRACING=1` to the `next dev --turbo` command, this will generate a `.next/trace.log` file.
|
|
|
|
When reporting issues related to Turbopack performance and memory usage, please include the trace file in your [GitHub](https://github.com/vercel/next.js) issue.
|