Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Crates

Layers

We can split the crates into the following layers:

graph TB
cli_utils[CLI Utils]
Tools --> Facade
CLI --> Facade & cli_utils
Facade --> Output & Modules & Utils & Core
Modules & Output --> Core & Utils
Utils --> Core

Core

There crates are the core of turbopack, providing the basic traits and types. This e. g. handles issue reporting, resolving and environments.

  • turbopack-core: Core types and traits
  • turbopack-resolve: Specific resolving implementations

Utils

These crates provide utility functions and types that are used throughout the project.

  • turbopack-swc-utils: SWC helpers that are shared between ecmascript and css
  • turbopack-node: Node.js pool processing, webpack loaders, postcss transform
  • turbopack-env: .env file loading

Modules

These crates provide implementations of various module types.

  • turbopack-ecmascript: The ecmascript module type (JavaScript, TypeScript, JSX), Tree Shaking
  • turbopack-ecmascript-plugins: Common ecmascript transforms (styled-components, styled-jsx, relay, emotion, etc.)
  • turbopack-css: The CSS module type (CSS, CSS Modules, SWC, lightningcss)
  • turbopack-json: The JSON module type
  • turbopack-static: The static module type (images, fonts, etc.)
  • turbopack-image: Image processing (metadata, optimization, blur placeholder)
  • turbopack-wasm: The WebAssembly module type
  • turbopack-mdx: The mdx module type

Output

These crates provide implementations of various output formats.

  • turbopack-browser: Output format for the browser target, HMR
  • turbopack-nodejs: Output format for the Node.js target
  • turbopack-ecmascript-runtime: The runtime code for bundles
  • turbopack-ecmascript-hmr-protocol: The Rust side of the HMR protocol

Facade

These crates provide the facade to use Turbopack. They combine the different modules and output formats into presets and handle the default module rules.

  • turbopack-binding: A crate reexporting all Turbopack crates for consumption in other projects
  • turbopack: The main facade bundling all module types and rules when to apply them, presets for resolving and module processing

CLI

These crates provide the standalong CLI and the dev server.

  • turbopack-cli: The Turbopack CLI
  • turbopack-dev-server: The on demand dev server implementation

CLI Utils

These crates provide utility functions for the CLI.

  • turbopack-cli-utils: Helper functions for CLI tooling
  • turbopack-trace-utils: Helper function for tracing

Tools

These crates provide tools to test, benchmark and trace Turbopack.

  • turbopack-bench: The Turbopack benchmark
  • turbopack-tests: Integration tests for Turbopack
  • turbopack-create-test-app: A CLI to create a test application with configurable number of modules
  • turbopack-swc-ast-explorer: A CLI tool to explore the SWC AST
  • turbopack-test-utils: Helpers for testing
  • turbopack-trace-server: A CLI to open a trace file and serve it in the browser