Rspack is a high-performance JavaScript bundler written in Rust that offers strong compatibility with the webpack ecosystem.
- Monorepo with Rust crates (
crates/) and JavaScript packages (packages/) - See Project Architecture for details
- Synchronous concurrency: Prefer
rayonfor CPU-bound parallel work and data-parallel iteration - Asynchronous concurrency: Prefer the abstractions provided by
rspack_parallelinstead of using rawtokiotask orchestration directly - Thread pool boundaries: Avoid mixing
rayonandtokiothread pools for the same workflow unless there is a clear boundary that cannot be avoided - Rule of thumb: Do not use
tokioto parallelize synchronous CPU-heavy work, and do not introducerayoninside async orchestration that should stay withinrspack_parallel
- Rust: Latest stable (via rustup)
- Node.js: Latest LTS
- pnpm: Version in
package.json - Run
pnpm run setupto install and build
pnpm run build:js- Build JavaScript/TypeScript packagespnpm run build:binding:dev- Build Rust crates (dev)pnpm run build:cli:dev- Full build (dev)pnpm run build:binding:debug- Debug buildpnpm run build:binding:release- Release buildpnpm run build:cli:dev:wasm- WASM buildpnpm run build:cli:dev:browser- Browser build
pnpm run test:rs- Rust unit testspnpm run test:unit- JavaScript unit testspnpm run test:e2e- E2E testspnpm run test:base- Integration tests (intests/rspack-test)pnpm run test:hot- HMR testscd tests/rspack-test && pnpm run test -t "configCases/asset"- Run filtered tests
Before running tests after code changes:
- If you modified JavaScript/TypeScript code, run
pnpm run build:jsfirst - If you modified Rust code, run
pnpm run build:binding:devfirst - If your change spans both JS and Rust, run
pnpm run build:cli:devfirst
- VS Code:
.vscode/launch.jsonwithDebug RspackandAttachoptions - Rust: Set breakpoints, use
Debug RspackorAttach Rust - JavaScript: Use
--inspectflag, attach withAttach JavaScript - rust-lldb:
rust-lldb -- node /path/to/rspack buildfor panic debugging
- Linting:
pnpm run lint:js(Rslint),pnpm run lint:rs(cargo check),cargo lint(Rust) - Formatting:
pnpm run format:rs(cargo fmt),pnpm run format:js(prettier),pnpm run format:toml(taplo),cargo fmt --all --check(Rust) - Style: snake_case for Rust, camelCase for JS/TS
- Create feature branch from
main - Implement in appropriate crate/package
- Add tests (Rust unit tests, JS integration tests)
- Update docs if APIs change
- Run linters and tests:
pnpm run lint:js && pnpm run lint:rs && cargo lint && pnpm run test:unit && pnpm run test:rs - Format:
pnpm run format:rs && pnpm run format:js - Create PR
- Rust: Core in
crates/rspack_core/, plugins incrates/rspack_plugin_*/, rebuild withpnpm run build:binding:dev, test withpnpm run test:rs, avoid linting and formatting for fast local development - JS/TS: API in
packages/rspack/src/, CLI inpackages/rspack-cli/src/, rebuild withpnpm run build:js, test withpnpm run test:unit
- Rust: Add
#[test]functions in same file ortests/directory - JavaScript: Add cases in
tests/rspack-test/{type}Cases/(Normal, Config, Hot, Watch, StatsOutput, StatsAPI, Diagnostic, Hash, Compiler, Defaults, Error, Hook, TreeShaking, Builtin)
- Package manager: pnpm (workspaces for monorepo)
- Rust:
Cargo.tomlin each crate - JavaScript:
package.jsonfiles - Version check:
pnpm run check-dependency-version
- Benchmarks:
tests/bench/, run withpnpm run bench:ci(setup:pnpm run bench:prepare) - Profiling:
pnpm run build:binding:profiling - Tracing: See
crates/rspack_tracing/
- Site:
website/directory - Docs:
website/docs/en/(English),website/docs/zh/(Chinese) - API:
website/docs/en/api/
- Template: Use
.github/PULL_REQUEST_TEMPLATE.md - Title prefix:
test:,fix:,feat:,refactor:,chore: - Semver alignment:
fix:-> PATCH bumpfeat:-> MINOR bump- Any breaking change -> MAJOR bump (
type(scope)!:and/orBREAKING CHANGE:in commit body)
- CI: All checks must pass
- Follow existing code patterns
- Add tests for new features
- Update docs when APIs change
- Run linters before submitting
- Use Conventional Commits in semver style:
type(scope): subject - Prefer these types for release impact:
fix,feat; use!orBREAKING CHANGE:only for incompatible changes - Keep PRs focused (one feature/fix per PR)
- Rust core:
crates/rspack_core/ - Plugins:
crates/rspack_plugin_*/ - JavaScript API:
packages/rspack/src/ - CLI:
packages/rspack-cli/src/ - Tests:
tests/rspack-test/
- Use
rspack_errorcrate for Rust errors - Provide clear, actionable error messages
- Include context (file paths, line numbers)
This project includes comprehensive documentation designed for AI assistants and large language models. All AI-friendly documentation is located in the .agents/ directory:
- Architecture Guide - High-level architecture overview, core components, compilation pipeline, and system design
- API Design - API design principles, patterns, versioning strategy, and compatibility guidelines
- Code Style - Coding standards and conventions for Rust and TypeScript/JavaScript
- Common Patterns - Common code patterns, templates, and best practices for plugin/loader development
- Glossary - Comprehensive glossary of terms and concepts used throughout the codebase
- Skills - Required skills and knowledge areas for contributing to Rspack
These documents provide detailed context about the project structure, coding standards, common patterns, and domain-specific knowledge to help AI assistants better understand and contribute to the codebase.