Capítulo 420 de 456
Configures Turbopack to transform files and change module resolution — the turbopack top-level config key (previously experimental.turbo, still aliased for 13.0.0-15.2.x).
root: absolute path setting the application root directory (auto-detected via lockfiles; set manually for non-workspace layouts or npm/yarn/pnpm link).rules: maps file glob patterns to webpack loaders (only a subset of the webpack loader API works; only loaders returning JS are supported).resolveAlias: aliases imports to other modules, similar to webpack resolve.alias; supports conditional aliasing via { browser: ... }.resolveExtensions: overrides the list of extensions resolved on import (must repeat defaults you still want).debugIds: enables debug ID generation in JS bundles/source maps.with { turbopackLoader, turbopackLoaderOptions, turbopackAs, turbopackModuleType }): apply a loader per-import instead of globally.condition: advanced rule matching (path, content, query, contentType, plus built-ins browser, foreign, development, production, node, edge-light).type: sets output type directly (asset, ecmascript, typescript, css, css-module, json, wasm, node, raw/text, bytes) without a loader.module.exports = {
turbopack: {
rules: {
'*.svg': {
loaders: ['@svgr/webpack'],
as: '*.js',
},
},
},
}
@svgr/webpack) pra importar .svg como componente React.import rawText from '../data.txt' with { turbopackLoader: 'raw-loader', turbopackAs: '*.js' }
| Option | Description |
|---|---|
root | Sets the application root directory (absolute path). |
rules | Webpack loaders to apply when running with Turbopack. |
resolveAlias | Map aliased imports to modules to load in their place. |
resolveExtensions | List of extensions to resolve when importing files. |
debugIds | Enable debug ID generation in JS bundles and source maps. |
Module types: asset, ecmascript, typescript, css, css-module, json, wasm, node, raw/text, bytes.
importModule, loadModule, emitFile, this.utils, this.resolve): Turbopack's loader-runner não cobre a API completa do webpack; só fs.readFile funciona em fs.require() de plugin modules como valor de opção de loader: só primitivos/objetos/arrays JS puros são aceitos.turbopack substitui experimental.turbo; migrar com npx @next/codemod@latest next-experimental-turbo-to-turbopack ..with { turbopackLoader: ... }) exigem with, não assert, e não têm equivalente em webpack.