Rust Turbopack rust-turbopack
Build, test, verify, and benchmark Rust changes in the Next.js repository, including Turbopack crates and next-napi-bindings.
Use it when native-binding rebuilds before e2e tests, clippy or Miri, Turbopack snapshot and execution fixtures, UPDATE=1 snapshot refreshes, fixture discovery, analyzer graph snapshots, wasi test failures, worktree target directory mistakes, Rust disk usage, TURBO_ENGINE_IGNORE_DIRTY, persistent cache benchmarks, RSS measurements, or Criterion runs.
- Our test
- —
- not tested yet
- GitHub stars
- 144k
- vercel/next.js
- Added by
- 0
- members
- Updated
- Dec 6
- commit ca9ff35
- Content
- 2 files
- no scripts · 10 KB
- License
- MIT
- free to use
What our test found
Not tested yet. Our model tries every skill on a realistic request and scores the result, the most popular skills first. Until then, the safety checks on the right still apply.
name: rust-turbopack description: > Build, test, verify, and benchmark Rust changes in the Next.js repository, including Turbopack crates and next-napi-bindings. Use for native-binding rebuilds before e2e tests, clippy or Miri, Turbopack snapshot and execution fixtures, UPDATE=1 snapshot refreshes, fixture discovery, analyzer graph snapshots, wasi test failures, worktree target directory mistakes, Rust disk usage, TURBO_ENGINE_IGNORE_DIRTY, persistent cache benchmarks, RSS measurements, or Criterion runs. metadata: internal: true
Rust and Turbopack
Use this skill when changing or verifying Rust code. Code-level turbo_tasks rules live in turbopack/AGENTS.md. Benchmark guidance is in .
Rebuild before Next.js tests
Next.js e2e tests use the compiled native binding, not Rust source. After a Rust change, rebuild before running Next.js tests, even when cargo check passes:
(cd packages/next-swc && CARGO_PROFILE_DEV_DEBUG=0 pnpm build-native)
pnpm build-all- The first command is a faster debug native build. The second matches the normal full JS and Rust build.
- Check that the test uses the binding you built. The test harness logs
swcNativeDirectory. - A debug native build can make build-heavy tests slower than CI.
- Native builds can update
packages/next/src/build/swc/generated-native.d.ts. Commit only intended changes. @napi-rs/cliis a dependency ofpackages/next-swc. Run it throughpnpm --filter @next/swc exec napi ..., and pass--cwdas an absolute path.
Run CI-equivalent checks
- Format with
cargo fmt --all, then gate withcargo fmt --all -- --check. Re-run formatting after the last edit, including mechanical renames. - CI clippy uses warnings as errors. The
packages/next-swcscript is:cargo clippy --workspace --all-targets -- -D warnings -A deprecated. For a focused check, also run clippy for affected dependents with--all-targets. turbopackdepends onturbopack-nodewithout default features. For a standalonecargo check -p turbopack, enable--features turbopack-node/process_pool.- CI runs Miri on a fixed package allowlist with specific flags. Run it with
pnpm --filter @next/swc run test-cargo-unit-miri(seepackages/next-swc/package.json) from the checkout sorust-toolchain.tomlselects the pinned nightly. A barecargo miri test -p <crate>omits those flags and can abort on filesystem access. Add a crate to the allowlist only after confirming it runs under Miri. - Cargo commands can update
Cargo.lock. Checkgit statusand revert unrelated changes. - For an internal compiler error related to incremental compilation, delete the affected
*/incrementaldirectories in the target directory and retry.
Turbopack fixtures
- Refresh snapshot tests with
UPDATE=1 cargo nextest run -E 'test(snapshot)', as documented inturbopack/crates/turbopack-tests/README.md. Without nextest, useUPDATE=1 cargo test -p turbopack-tests --test snapshot <filter>. Then run again withoutUPDATEand review the diff. - Snapshot
output/files are tracked. Execution-testoutput/directories are ignored. Use a snapshot fixture when exact generated code matters. - Fixture tests are generated from directory globs at compile time. After adding or deleting a fixture directory, touch the relevant harness (for example
tests/snapshot.rs,tests/execution.rs, orturbopack-ecmascript/src/references/tests.rs) so Cargo rebuilds it. - Execution fixtures enable scope hoisting by default. Add a
"scopeHoisting": falsefixture when testing generated cross-module code. - Prettier can rewrite syntax-sensitive fixture input. Use
// prettier-ignorewhen the exact syntax is what the test checks. - Snapshot tests embed the workspace root at compile time (
TURBO_PNPM_WORKSPACE_DIRin.cargo/config.toml). Run them from the checkout that built the test binary. - Analyzer graph snapshots include
Effectdebug output. After changing it, runUPDATE=1 cargo test -p turbopack-ecmascript --lib analyzer::testsand check that the snapshot diff contains only the intended change.
wasi tests
Use scripts/wasi-test-host/README.md for host setup and commands.
- The
test next-swc wasijob runs Rust tests on a target that aborts on panic. A failing assertion can stop the whole test binary. Tests that require unwinding need a wasm-specific ignore, like existing examples. - A contended
parking_lotlock panics on wasm. Tests that need blocking locks must account for that platform limitation.
Target directories
- Don't share one
CARGO_TARGET_DIRbetween worktrees. Cargo can reuse a workspace crate built from another worktree and test the wrong source. Use one target directory per worktree. - Rust targets can become very large. Check free disk space before broad builds.
target/debug/incrementalis disposable when it causes disk pressure. - For a test binary, use the executable path printed by
cargo test --no-run. - Rust's test harness hides output from passing tests. Pass
-- --nocapturewhen you need instrumentation output. - Parallel copies of tests that use a persistent cache need separate cache or target directories.
Related Skills
$pr-status-triage- CI failure triage$sandbox-bench- end-to-end render-pipeline A/B benchmarks