Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Turbopack

ASecurity

Turbopack expert guidance. Use when configuring the Next.js bundler, optimizing HMR, debugging build issues, or understanding the Turbopack vs Webpack differences.

9 stars
0 votes
0 copies
0 views
Added 9/23/2026
developmentjavascripttypescriptrustjavabashreactnextjsnodeexpressdebugging

Works with

cliapi

Security Analysis

A96/100
mediumInstalls packages at runtime which could introduce malicious dependencies

Scanned 9/23/2026

Install to Claude Code

$npx -y skills add stanfish06/skillquarium --skill turbopack --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Turbopack?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Turbopack
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/stanfish06-turbopack/badge)](https://www.skillsdirectory.com/skills/stanfish06-turbopack)

More formats (shields.io, HTML) on the badges page.

Download with Pro
Files
SKILL.md
---
name: turbopack
description: Turbopack expert guidance. Use when configuring the Next.js bundler, optimizing HMR, debugging build issues, or understanding the Turbopack vs Webpack differences.
metadata:
  priority: 4
  docs:
    - "https://turbo.build/pack/docs"
    - "https://nextjs.org/docs/architecture/turbopack"
  sitemap: "https://turbo.build/sitemap.xml"
  pathPatterns: 
    - 'next.config.*'
  bashPatterns: 
    - '\bnext\s+dev\s+--turbo\b'
    - '\bnext\s+dev\s+--turbopack\b'
---

# Turbopack

You are an expert in Turbopack — the Rust-powered JavaScript/TypeScript bundler built by Vercel. It is the default bundler in Next.js 16.

## Key Features

- **Instant HMR**: Hot Module Replacement that doesn't degrade with app size
- **File System Caching (Stable)**: Dev server artifacts cached on disk between restarts — up to 14x faster startup on large projects. Enabled by default in Next.js 16.1+, no config needed. Build caching planned next.
- **Multi-environment builds**: Browser, Server, Edge, SSR, React Server Components
- **Native RSC support**: Built for React Server Components from the ground up
- **TypeScript, JSX, CSS, CSS Modules, WebAssembly**: Out of the box
- **Rust-powered**: Incremental computation engine for maximum performance

## Configuration (Next.js 16)

In Next.js 16, Turbopack config is top-level (moved from `experimental.turbopack`):

```js
// next.config.ts
import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  turbopack: {
    // Resolve aliases (like webpack resolve.alias)
    resolveAlias: {
      'old-package': 'new-package',
    },
    // Custom file extensions to resolve
    resolveExtensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
  },
}

export default nextConfig
```

## CSS and CSS Modules Handling

Turbopack handles CSS natively without additional configuration.

### Global CSS

Import global CSS in your root layout:

```tsx
// app/layout.tsx
import './globals.css'
```

### CSS Modules

CSS Modules work out of the box with `.module.css` files:

```tsx
// components/Button.tsx
import styles from './Button.module.css'

export function Button({ children }) {
  return <button className={styles.primary}>{children}</button>
}
```

### PostCSS

Turbopack reads your `postcss.config.js` automatically. Tailwind CSS v4 works with zero config:

```js
// postcss.config.js
module.exports = {
  plugins: {
    '@tailwindcss/postcss': {},
    autoprefixer: {},
  },
}
```

### Sass / SCSS

Install `sass` and import `.scss` files directly — Turbopack compiles them natively:

```bash
npm install sass
```

```tsx
import styles from './Component.module.scss'
```

### Common CSS pitfalls

- **CSS ordering differs from webpack**: Turbopack may load CSS chunks in a different order. Avoid relying on source-order specificity across files — use more specific selectors or CSS Modules.
- **`@import` in global CSS**: Use standard CSS `@import` — Turbopack resolves them, but circular imports cause build failures.
- **CSS-in-JS libraries**: `styled-components` and `emotion` work but require their SWC plugins configured under `compiler` in next.config.

## Tree Shaking

Turbopack performs tree shaking at the module level in production builds. Key behaviors:

- **ES module exports**: Only used exports are included — write `export` on each function/constant rather than barrel `export *`
- **Side-effect-free packages**: Mark packages as side-effect-free in `package.json` to enable aggressive tree shaking:

```json
{
  "name": "my-ui-lib",
  "sideEffects": false
}
```

- **Barrel file optimization**: Turbopack can skip unused re-exports from barrel files (`index.ts`) when the package declares `"sideEffects": false`
- **Dynamic imports**: `import()` expressions create async chunk boundaries — Turbopack splits these into separate chunks automatically

### Diagnosing large bundles

**Built-in analyzer (Next.js 16.1+, experimental)**: Works natively with Turbopack. Offers route-specific filtering, import tracing, and RSC boundary analysis:

```ts
// next.config.ts
const nextConfig: NextConfig = {
  experimental: {
    bundleAnalyzer: true,
  },
}
```

**Legacy `@next/bundle-analyzer`**: Still works as a fallback:

```bash
ANALYZE=true next build
```

```ts
// next.config.ts
import withBundleAnalyzer from '@next/bundle-analyzer'

const nextConfig = withBundleAnalyzer({
  enabled: process.env.ANALYZE === 'true',
})({
  // your config
})
```

## Custom Loader Migration from Webpack

Turbopack does not support webpack loaders directly. Here is how to migrate common patterns:

| Webpack Loader | Turbopack Equivalent |
|----------------|---------------------|
| `css-loader` + `style-loader` | Built-in CSS support — remove loaders |
| `sass-loader` | Built-in — install `sass` package |
| `postcss-loader` | Built-in — reads `postcss.config.js` |
| `file-loader` / `url-loader` | Built-in static asset handling |
| `svgr` / `@svgr/webpack` | Use `@svgr/webpack` via `turbopack.rules` |
| `raw-loader` | Use `import x from './file?raw'` |
| `graphql-tag/loader` | Use a build-time codegen step instead |
| `worker-loader` | Use native `new Worker(new URL(...))` syntax |

### Configuring custom rules (loader replacement)

For loaders that have no built-in equivalent, use `turbopack.rules`:

```js
// next.config.ts
const nextConfig: NextConfig = {
  turbopack: {
    rules: {
      '*.svg': {
        loaders: ['@svgr/webpack'],
        as: '*.js',
      },
    },
  },
}
```

### When migration isn't possible

If a webpack loader has no Turbopack equivalent and no workaround, fall back to webpack:

```js
const nextConfig: NextConfig = {
  bundler: 'webpack',
}
```

File an issue at [github.com/vercel/next.js](https://github.com/vercel/next.js) — the Turbopack team tracks loader parity requests.

## Production Build Diagnostics

### Build failing with Turbopack

1. **Check for unsupported config**: Remove any `webpack()` function from next.config — it's ignored by Turbopack and may mask the real config
2. **Verify `turbopack.rules`**: Ensure custom rules reference valid loaders that are installed
3. **Check for Node.js built-in usage in edge/client**: Turbopack enforces environment boundaries — `fs`, `path`, etc. cannot be imported in client or edge bundles
4. **Module not found errors**: Ensure `turbopack.resolveAlias` covers any custom resolution that was previously in webpack config

### Build output too large

- Audit `"use client"` directives — each client component boundary creates a new chunk
- Check for accidentally bundled server-only packages in client components
- Use `server-only` package to enforce server/client boundaries at import time:

```bash
npm install server-only
```

```ts
// lib/db.ts
import 'server-only' // Build fails if imported in a client component
```

### Comparing webpack vs Turbopack output

Run both bundlers and compare:

```bash
# Turbopack build (default in Next.js 16)
next build

# Webpack build
BUNDLER=webpack next build
```

Compare `.next/` output sizes and page-level chunks.

## Performance Profiling

### HMR profiling

Enable verbose HMR timing in development:

```bash
NEXT_TURBOPACK_TRACING=1 next dev
```

This writes a `trace.json` to the project root — open it in `chrome://tracing` or [Perfetto](https://ui.perfetto.dev/) to see module-level timing.

### Build profiling

Profile production builds:

```bash
NEXT_TURBOPACK_TRACING=1 next build
```

Look for:
- **Long-running transforms**: Indicates a slow SWC plugin or heavy PostCSS config
- **Large module graphs**: Reduce barrel file re-exports
- **Cache misses**: If incremental builds aren't hitting cache, check for files that change every build (e.g., generated timestamps)

### Memory usage

Turbopack's Rust core manages its own memory. If builds OOM:
- Increase Node.js heap: `NODE_OPTIONS='--max-old-space-size=8192' next build`
- Reduce concurrent tasks if running inside Turborepo: `turbo build --concurrency=2`

## Turbopack vs Webpack

| Feature | Turbopack | Webpack |
|---------|-----------|---------|
| Language | Rust | JavaScript |
| HMR speed | Constant (O(1)) | Degrades with app size |
| RSC support | Native | Plugin-based |
| Cold start | Fast | Slower |
| Ecosystem | Growing | Massive (loaders, plugins) |
| Status in Next.js 16 | Default | Still supported |
| Tree shaking | Module-level | Module-level |
| CSS handling | Built-in | Requires loaders |
| Production builds | Supported | Supported |

## When You Might Need Webpack

- Custom webpack loaders with no Turbopack equivalent
- Complex webpack plugin configurations (e.g., `ModuleFederationPlugin`)
- Specific webpack features not yet in Turbopack (e.g., custom `externals` functions)

To use webpack instead:
```js
// next.config.ts
const nextConfig: NextConfig = {
  bundler: 'webpack', // Opt out of Turbopack
}
```

## Development vs Production

- **Development**: Turbopack provides instant HMR and fast refresh
- **Production**: Turbopack handles the production build (replaces webpack in Next.js 16)

## Common Issues

1. **Missing loader equivalent**: Some webpack loaders don't have Turbopack equivalents yet. Check Turbopack docs for supported transformations.
2. **Config migration**: Move `experimental.turbopack` to top-level `turbopack` in next.config.
3. **Custom aliases**: Use `turbopack.resolveAlias` instead of `webpack.resolve.alias`.
4. **CSS ordering changes**: Test visual regressions when migrating — CSS chunk order may differ.
5. **Environment boundary errors**: Server-only modules imported in client components fail at build time — use `server-only` package.

## Official Documentation

- [Turbopack](https://turborepo.dev/pack)
- [Turbopack Documentation](https://turborepo.dev/pack/docs)
- [Next.js Turbopack Config](https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack)
- [GitHub: Turbopack](https://github.com/vercel/turborepo)

Attribution

stanfish06stanfish06
View sourceMore from stanfish06 →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

284722 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2192 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

9881 votes

Pentest

PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.

5491 votes
View all in development →