Rsdoctor 2.0: Agent-Native Build Analysis Cuts Analysis Time 57%
Rsdoctor 2.0 introduces agent-driven build analysis for Rspack, reducing installation size by 56%, analysis time by 57%, and HMR overhead by 47%, while adding unified multi-compiler reporting and faster bundle visualization.
Agent-Driven Build Analysis
Rsdoctor 2.0 shifts its automation focus to an Agent CLI that reads rsdoctor-data.json and returns structured JSON for programmatic querying. The CLI is installed via pnpm add -D @rsdoctor/agent-cli and paired with the rsdoctor-analysis skill (
npx skills add rstackjs/agent-skills --skill rsdoctor-analysis). To generate the machine-readable report, configure the Rspack plugin in brief mode:
new RsdoctorRspackPlugin({
output: {
mode: 'brief',
options: { type: ['json'] }
}
});Run pnpm run build or RSDOCTOR_OUTPUT=json pnpm run build to produce the JSON. Agents can then be prompted in natural language, e.g., "Use Rsdoctor to analyze the current project and find directions to optimize output size." The agent invokes rsdoctor-agent commands to locate large chunks, duplicate dependencies, module reference chains, loader timings, and tree-shaking failures, iteratively narrowing the scope and proposing fixes. The legacy MCP Server ( @rsdoctor/mcp-server) is deprecated; a migration guide is provided (see
https://rsdoctor.rs/zh/guide/migration/migration-v2#ai-工作流迁移).
Smaller Installation Footprint
Analysis capabilities previously spread across multiple packages are consolidated into @rsdoctor/core, and runtime dependencies are trimmed. Installation size drops from 25.5 MB to 11.1 MB (56.6% reduction) and dependency count from 83 to 18 (78.3% reduction), reducing disk usage in local and CI environments.
Faster Analysis Speed
Since v1.5 Rsdoctor has used Rspack's native plugin for data collection. Version 2.0 moves more collection logic into the native layer and removes the experiments.enableNativePlugin flag. Benchmarks show analysis time falling from 18.07 s to 7.77 s (57.0% faster) and peak RSS from 2,186 MiB to 1,755 MiB (19.7% lower).
Faster Incremental Builds
In watch mode, Rsdoctor now reuses prior analysis results and the report server. Module and asset gzip-size calculations are skipped on rebuilds, and a faster compression level is used for report serialization. HMR median latency improves from 6.81 s to 3.64 s (47% reduction), and repeat-build analysis overhead drops from 250.9 ms to 14.2 ms (94.3% reduction).
Improved Multi-Compiler Support
Multiple compilers are automatically aggregated into a single report with a dropdown to switch between them. Child compilers (e.g., for asset generation) are detected and shown with a "Child" label, separated from the main compiler. Custom grouping is supported via multiCompiler: { group: 'ssr' }; unrelated compilers in the same process can opt out with multiCompiler: false. The Agent CLI also supports compiler selection for targeted analysis.
Bundle Analysis UI Enhancements
The Tree Graph now uses virtual scrolling and render caching to handle thousands of modules smoothly, reducing tooltip and interaction overhead during scroll. The Treemap adds click-to-zoom, breadcrumb navigation, full-screen mode, sidebar collapse, and responsive layout. A filter for JavaScript assets and unified Stat/Parsed/Gzipped size metrics help focus on relevant code. These changes are tracked in PRs #1705, #1782, #1830, #1839 (see https://github.com/web-infra-dev/rsdoctor/pull/1705, https://github.com/web-infra-dev/rsdoctor/pull/1782, https://github.com/web-infra-dev/rsdoctor/pull/1830, https://github.com/web-infra-dev/rsdoctor/pull/1839).
Upgrade Requirements
Runtime: Node.js ^20.19.0 || >=22.12.0 and Rspack 2.0+.
Package & module format: Replace @rsdoctor/rspack-plugin with @rsdoctor/core and use ESM imports.
AI workflow: Migrate from removed @rsdoctor/mcp-server to Agent CLI.
Webpack: Rsdoctor 2.0 no longer supports webpack; webpack projects should stay on 1.x.
Full upgrade steps, config changes, and an agent-assisted migration skill are documented in the Rsdoctor 2.0 migration guide ( https://rsdoctor.rs/zh/guide/migration/migration-v2). See the release page at https://github.com/web-infra-dev/rsdoctor/releases for complete changelog.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ByteDance Web Infra
ByteDance Web Infra team, focused on delivering excellent technical solutions, building an open tech ecosystem, and advancing front-end technology within the company and the industry | The best way to predict the future is to create it
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
