### Analyze command usage example Source: https://rsdoctor.rs/llms-full.txt Example of using the analyze command with a local manifest.json file path. ```bash rsdoctor analyze --profile "./dist/.rsdoctor/manifest.json" ``` -------------------------------- ### Bundle diff command usage example Source: https://rsdoctor.rs/llms-full.txt Example of using the bundle-diff command with local paths for baseline and current manifest.json files. ```bash rsdoctor bundle-diff --baseline="baseline/.rsdoctor/manifest.json" --current="current/.rsdoctor/manifest.json" ``` -------------------------------- ### Install @rsdoctor/cli with bun Source: https://rsdoctor.rs/llms-full.txt Install the Rsdoctor CLI package as a development dependency using bun. ```sh bun add @rsdoctor/cli -D ``` -------------------------------- ### Trigger skill via natural language Source: https://rsdoctor.rs/guide/start/ai Example prompt for triggering the installed Rsdoctor skill. ```text Use Rsdoctor to analyze this project and provide optimization suggestions ``` -------------------------------- ### Install @rsdoctor/cli with deno Source: https://rsdoctor.rs/llms-full.txt Install the Rsdoctor CLI package as a development dependency using deno. ```sh deno add npm:@rsdoctor/cli -D ``` -------------------------------- ### Configure AGENTS.md Source: https://rsdoctor.rs/guide/start/ai Example content for an AGENTS.md file to provide project context to AI agents. ```markdown # AGENTS.md You are an expert in JavaScript, Rsdoctor, and build analysis. ## Tools ### Rsdoctor - Run `RSDOCTOR=true npm run build` to build the app with Rsdoctor ## Docs - Rsdoctor: https://rsdoctor.rs/llms.txt ``` -------------------------------- ### Configuration Examples Source: https://rsdoctor.rs/config/options/output Provides JavaScript code examples for configuring Rsdoctor to generate HTML only, JSON only, or both HTML and JSON output formats. ```APIDOC ## Configuration Example Comparison ```js // Generate HTML report only (suitable for offline viewing) new RsdoctorRspackPlugin({ output: { mode: 'brief', options: { type: ['html'], htmlOptions: { reportHtmlName: 'build-report.html', }, }, }, }); // Generate JSON data only (suitable for uploading to Playground) new RsdoctorRspackPlugin({ output: { mode: 'brief', options: { type: ['json'], }, }, }); // Generate both formats (suitable for different use cases) new RsdoctorRspackPlugin({ output: { mode: 'brief', options: { type: ['html', 'json'], htmlOptions: { reportHtmlName: 'build-report.html', }, }, }, }); ``` ``` -------------------------------- ### Configure cjs-require rule Source: https://rsdoctor.rs/guide/rules/rules Defines the configuration interface for ignoring module paths and provides a plugin setup example. ```ts interface Config { /** Module path fragments to ignore */ ignore: string[]; } ``` ```ts import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin'; export default { plugins: [ new RsdoctorRspackPlugin({ linter: { rules: { 'cjs-require': [ 'Warn', { ignore: ['legacy-lib', 'node_modules/@internal/'] }, ], }, }, }), ], }; ``` -------------------------------- ### Install @rsdoctor/cli Source: https://rsdoctor.rs/guide/start/cli Instructions for installing the @rsdoctor/cli package using various package managers. ```APIDOC ## Install @rsdoctor/cli This section details how to install the `@rsdoctor/cli` package using different package managers. ### npm ```sh npm add @rsdoctor/cli -D ``` ### yarn ```sh yarn add @rsdoctor/cli -D ``` ### pnpm ```sh pnpm add @rsdoctor/cli -D ``` ### bun ```sh bun add @rsdoctor/cli -D ``` ### deno ```sh denp add npm:@rsdoctor/cli -D ``` **Note:** Ensure that `@rsdoctor/cli`, `@rsdoctor/webpack-plugin`, and `@rsdoctor/rspack-plugin` share the same major and minor versions. You can also use `npx @rsdoctor/cli [options]` for a non-installation method. ``` -------------------------------- ### Install Rsdoctor analysis skill Source: https://rsdoctor.rs/guide/start/ai Commands to install the rsdoctor-analysis skill using various package managers. ```sh npx skills add rstackjs/agent-skills --skill rsdoctor-analysis ``` ```sh yarn dlx skills add rstackjs/agent-skills --skill rsdoctor-analysis ``` ```sh pnpm dlx skills add rstackjs/agent-skills --skill rsdoctor-analysis ``` ```sh bunx skills add rstackjs/agent-skills --skill rsdoctor-analysis ``` ```sh deno run -A npm:skills add rstackjs/agent-skills --skill rsdoctor-analysis ``` -------------------------------- ### Access Markdown documentation Source: https://rsdoctor.rs/guide/start/ai Example URL for accessing a specific documentation page in Markdown format. ```text https://rsdoctor.rs/guide/start/intro.md ``` -------------------------------- ### Configure module-mixed-chunks rule Source: https://rsdoctor.rs/guide/rules/rules Defines the configuration interface for ignoring module paths and provides a plugin setup example. ```ts interface Config { /** Module path fragments to ignore */ ignore: string[]; } ``` ```ts import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin'; export default { plugin: [ new RsdoctorRspackPlugin({ linter: { rules: { 'module-mixed-chunks': ['Warn', { ignore: ['node_modules/'] }], }, }, }), ], }; ``` -------------------------------- ### Configure tree-shaking-side-effects-only rule Source: https://rsdoctor.rs/guide/rules/rules Defines the configuration interface for ignoring or including specific module paths and provides a plugin setup example. ```ts interface Config { /** Module path fragments to ignore */ ignore: string[]; /** * Module path patterns to include when the module is under node_modules. * Example: ['react', '@babel/runtime'] */ include: string[]; } ``` ```ts import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin'; export default { plugins: [ new RsdoctorRspackPlugin({ linter: { rules: { 'tree-shaking-side-effects-only': [ 'Warn', { ignore: ['src/polyfills'], include: ['some-lib'], }, ], }, }, }), ], }; ``` -------------------------------- ### Example project structure with .bundle files Source: https://rsdoctor.rs/llms-full.txt Rsdoctor automatically detects and analyzes files with the .bundle extension, commonly used in Re.Pack projects. ```text dist/ ├── index.bundle ← Now supported! ├── vendor.bundle ← Now supported! ├── styles.css └── assets/ ``` -------------------------------- ### Install @rsdoctor/core dependency Source: https://rsdoctor.rs/guide/rules/rule-custom Install the core package required for defining custom rules. ```sh npm add @rsdoctor/core -D ``` ```sh yarn add @rsdoctor/core -D ``` ```sh pnpm add @rsdoctor/core -D ``` ```sh bun add @rsdoctor/core -D ``` ```sh deno add npm:@rsdoctor/core -D ``` -------------------------------- ### Configure Rsdoctor to use Brief mode Source: https://rsdoctor.rs/config/options/brief Example of initializing `RsdoctorRspackPlugin` with Brief mode enabled. Use this to generate a concise HTML report. ```javascript new RsdoctorRspackPlugin({ output: { mode: 'brief', }, }); ``` -------------------------------- ### Analyze Command Usage Source: https://rsdoctor.rs/guide/start/cli Command to load a manifest.json file locally and start the analysis report page. ```bash rsdoctor analyze --profile ``` ```bash rsdoctor analyze --profile "./dist/.rsdoctor/manifest.json" ``` -------------------------------- ### Install @rsdoctor/cli with pnpm Source: https://rsdoctor.rs/llms-full.txt Install the Rsdoctor CLI package as a development dependency using pnpm. ```sh pnpm add @rsdoctor/cli -D ``` -------------------------------- ### Rsdoctor Plugin Configuration Example Source: https://rsdoctor.rs/guide/rules/rules An example of how to configure the RsdoctorRspackPlugin to use the 'esm-resolved-to-cjs' rule with specific ignore patterns. ```typescript import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin'; export default { plugins: [ new RsdoctorRspackPlugin({ linter: { rules: { 'esm-resolved-to-cjs': [ 'Warn', { ignore: ['my-legacy-pkg', '@internal/'] }, ], }, }, }), ], }; ``` -------------------------------- ### Install @rsdoctor/cli with npm Source: https://rsdoctor.rs/llms-full.txt Install the Rsdoctor CLI package as a development dependency using npm. ```sh npm add @rsdoctor/cli -D ``` -------------------------------- ### Install @rsdoctor/cli with yarn Source: https://rsdoctor.rs/llms-full.txt Install the Rsdoctor CLI package as a development dependency using yarn. ```sh yarn add @rsdoctor/cli -D ``` -------------------------------- ### Install @rsdoctor/cli Source: https://rsdoctor.rs/guide/start/cli Commands to install the Rsdoctor CLI as a development dependency using various package managers. ```sh npm add @rsdoctor/cli -D ``` ```sh yarn add @rsdoctor/cli -D ``` ```sh pnpm add @rsdoctor/cli -D ``` ```sh bun add @rsdoctor/cli -D ``` ```sh deno add npm:@rsdoctor/cli -D ``` -------------------------------- ### Configure RsdoctorRspackPlugin features Source: https://rsdoctor.rs/config/options/features Examples showing how to enable specific features using an array or disable specific features using an object. ```js new RsdoctorRspackPlugin({ // Only enable bundle, loader, plugins feature analysis, array form will override default configuration. features: ['bundle', 'loader', 'plugins'], }); ``` ```js new RsdoctorRspackPlugin({ features: { // Disable bundle analysis, other feature analysis remains default bundle: false, }, }); ``` -------------------------------- ### Configure Rsdoctor Brief Mode Output Source: https://rsdoctor.rs/config/options/output Example of configuring the RsdoctorRspackPlugin to generate both HTML and JSON reports in brief mode. ```js new RsdoctorRspackPlugin({ output: { mode: 'brief', options: { // Output both HTML and JSON formats type: ['html', 'json'], htmlOptions: { reportHtmlName: 'my-report.html', }, }, }, }); ``` -------------------------------- ### Run Rsdoctor Local Build Source: https://rsdoctor.rs/llms-full.txt Enable Rsdoctor and run a local build. Do not use MCP Client to start the project, as Rsdoctor's local service will block the MCP Client's dialogue process. ```bash npm run build ``` -------------------------------- ### Configure cjs-require Rule Source: https://rsdoctor.rs/llms-full.txt Example usage of the RsdoctorRspackPlugin to configure the cjs-require linter rule. ```ts import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin'; export default { plugins: [ new RsdoctorRspackPlugin({ linter: { rules: { 'cjs-require': [ 'Warn', { ignore: ['legacy-lib', 'node_modules/@internal/'] }, ], }, }, }), ], }; ``` -------------------------------- ### Initialize RsdoctorRspackPlugin (CJS) Source: https://rsdoctor.rs/config/options/options Import and instantiate the RsdoctorRspackPlugin using CommonJS module syntax. This is commonly used in older Node.js environments or specific build setups. ```js const { RsdoctorRspackPlugin } = require('@rsdoctor/rspack-plugin'); new RsdoctorRspackPlugin({ /** RsdoctorRspackPluginOptions */ }); ``` -------------------------------- ### GitHub Workflow for Bundle Analysis Source: https://rsdoctor.rs/guide/start/action Set up a GitHub Actions workflow to automatically perform bundle analysis on pull requests and push events. This workflow checks out code, sets up Node.js and pnpm, installs dependencies, builds the project, and runs the Rsdoctor action for analysis. ```yaml name: Bundle Analysis on: pull_request: types: [opened, synchronize, reopened] push: branches: - main # or your target branch name workflow_dispatch: # Optional, allows manual triggering inputs: target_branch: description: 'Target branch to compare against' required: false default: 'main' type: string jobs: bundle-analysis: runs-on: ubuntu-latest permissions: # Allow commenting on commits contents: write # Allow commenting on issues issues: write # Allow commenting on pull requests pull-requests: write # Allow reading workflow runs and downloading artifacts for baseline comparison actions: read steps: - name: Checkout uses: actions/checkout@08eba0b27e820071cde6df949e0eba9ba4906955 # v4 with: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} - name: Setup Pnpm run: | npm install -g corepack@latest --force corepack enable - name: Setup Node.js uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 with: node-version: 22 cache: 'pnpm' - name: Install Dependencies and Build run: | pnpm install pnpm run build - name: Bundle Analysis uses: web-infra-dev/rsdoctor-action@main with: file_path: 'dist/.rsdoctor/rsdoctor-data.json' # Default 'main'. If you want to use a dynamic target branch, i.e., automatically get the target branch of the current pull request instead of a fixed main branch, you can use the following configuration: # ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || github.event.repository.default_branch }} target_branch: 'main' # Target branch for manual trigger dispatch_target_branch: ${{ github.event.inputs.target_branch }} ``` -------------------------------- ### CLI analyze command Source: https://rsdoctor.rs/llms-full.txt The analyze command loads a manifest.json file locally to start the Rsdoctor analysis report page without requiring a rebuild. ```APIDOC ## analyze ### Description Loads a manifest.json file locally and starts the Rsdoctor analysis report page. ### Parameters #### Arguments - **manifestFile** (string) - Required - The path to the manifest.json file. ### Usage Example rsdoctor analyze --profile "./dist/.rsdoctor/manifest.json" ``` -------------------------------- ### Install Rsdoctor for Rspack Projects (bun) Source: https://rsdoctor.rs/guide/start/quick-start Use this command to add the Rsdoctor Rspack plugin to your Rspack-based projects like Rsbuild or Rslib when using bun. ```sh bun add @rsdoctor/rspack-plugin -D ``` -------------------------------- ### Execute Build Commands Source: https://rsdoctor.rs/guide/start/quick-start Run the build process using various package managers. ```sh npm run build ``` ```sh yarn run build ``` ```sh pnpm run build ``` ```sh bun run build ``` ```sh deno run npm:build ``` -------------------------------- ### Execute Build Command with Bun Source: https://rsdoctor.rs/llms-full.txt Run the build command using Bun. Rsdoctor will generate report data locally. ```sh bun run build ``` -------------------------------- ### Configure Analysis Scripts Source: https://rsdoctor.rs/guide/start/quick-start Add scripts to package.json to open client and server reports. ```ts "scripts": { "client:rsd": "rsdoctor analyze --profile .next/.rsdoctor/manifest.json", // Rsdoctor's client report "server:rsd": "rsdoctor analyze --profile .next/server/.rsdoctor/manifest.json" // Rsdoctor's server report } ``` -------------------------------- ### Execute Build Command with Deno Source: https://rsdoctor.rs/llms-full.txt Run the build command using Deno. Rsdoctor will generate report data locally. ```sh deno run npm:build ``` -------------------------------- ### Project Directory Structure Source: https://rsdoctor.rs/llms-full.txt A representation of a pnpm workspace directory structure showing how peer dependencies can lead to multiple instances of the same package. ```txt ├── node_modules ├── apps │ └── web │ ├── node_modules │ │ ├── component -> ../../packages/component │ │ ├── axios -> ../../../node_modules/.pnpm/axios@0.27.2_debug@4.3.4 │ │ └── debug -> ../../../node_modules/.pnpm/debug@4.3.4 │ ├── src │ │ └── index.js │ ├── rspack.config.js │ └── package.json └── packages └── component ├── node_modules │ └── axios -> ../../../node_modules/.pnpm/axios@0.27.2 ├── src │ └── index.js └── package.json ``` -------------------------------- ### Install Rsdoctor for Rspack Projects Source: https://rsdoctor.rs/llms-full.txt Use this command to add the Rsdoctor Rspack plugin to your Rspack-based projects. It's typically installed as a development dependency. ```sh npm add @rsdoctor/rspack-plugin -D ``` ```sh yarn add @rsdoctor/rspack-plugin -D ``` ```sh pnpm add @rsdoctor/rspack-plugin -D ``` ```sh bun add @rsdoctor/rspack-plugin -D ``` ```sh deno add npm:@rsdoctor/rspack-plugin -D ``` -------------------------------- ### Analyze Report via CLI Source: https://rsdoctor.rs/guide/start/quick-start Manually open a report page by pointing to the manifest file. ```bash rsdoctor analyze --profile .next/server/chunks/.rsdoctor/manifest.json ``` -------------------------------- ### Brief Configuration Options Source: https://rsdoctor.rs/config/options/brief Configuration details for the Brief mode, including reportHtmlName and writeDataJson settings. ```APIDOC ## Brief Configuration ### Description Configures the Brief mode for the Rsdoctor Rspack plugin. Note: This is deprecated in V2; use output.mode: 'brief' instead. ### Parameters - **reportHtmlName** (string) - Optional - Configures the filename of the HTML report. Default: 'report-rsdoctor.html'. - **writeDataJson** (boolean) - Optional - If true, generates additional local JSON data files. Default: false. ### Request Example ```js new RsdoctorRspackPlugin({ output: { mode: 'brief', }, }); ``` ``` -------------------------------- ### Install Rsdoctor for Webpack Projects Source: https://rsdoctor.rs/llms-full.txt Use this command to add the Rsdoctor Webpack plugin to your Webpack projects. Rsdoctor supports webpack version 5 and above. It's installed as a development dependency. ```sh npm add @rsdoctor/webpack-plugin -D ``` ```sh yarn add @rsdoctor/webpack-plugin -D ``` ```sh pnpm add @rsdoctor/webpack-plugin -D ``` ```sh bun add @rsdoctor/webpack-plugin -D ``` ```sh deno add npm:@rsdoctor/webpack-plugin -D ``` -------------------------------- ### Bundle-Diff Command Usage Source: https://rsdoctor.rs/guide/start/cli Command to compare two manifest.json files for bundle analysis. ```bash rsdoctor bundle-diff --baseline --current ``` ```bash rsdoctor bundle-diff --baseline="baseline/.rsdoctor/manifest.json" --current="current/.rsdoctor/manifest.json" ``` -------------------------------- ### Register Rsdoctor in Rsbuild Source: https://rsdoctor.rs/guide/start/quick-start Example configuration for integrating Rsdoctor into an Rsbuild project. ```ts import { defineConfig } from '@rsbuild/core'; import { pluginVue } from '@rsbuild/plugin-vue'; import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin'; export default defineConfig({ plugins: [pluginVue()], performance: { buildCache: false, }, tools: { bundlerChain: (chain, { CHAIN_ID }) => { chain.plugin('Rsdoctor').use(RsdoctorRspackPlugin, [ { // plugin options }, ]); }, }, }); ``` -------------------------------- ### Access llms.txt documentation files Source: https://rsdoctor.rs/guide/start/ai URLs for accessing the structured index and full-content documentation files for AI consumption. ```text https://rsdoctor.rs/llms.txt ``` ```text https://rsdoctor.rs/llms-full.txt ``` -------------------------------- ### Report rule details Source: https://rsdoctor.rs/llms-full.txt Examples of reporting rule results using the report function with different detail types. ```js report({ message: 'The count of assets is bigger than limit', detail: { // ...... description: 'The count of assets is bigger than limit', }, }); ``` ```js report({ detail: { // ...... link: 'http://....', }, }); ``` ```ts report({ message: 'The count of assets is bigger than limit', detail: { type: 'link', link: 'https://rsdoctor.rs/zh/guide/start/quick-start', // This link just for show case. }, }); ``` ```js const detail { type: 'code-view', file: { path: document.path, content: document.content, ranges: [node.loc!], }, }; report({ message, document, detail, }); ``` -------------------------------- ### Define SourceRange Interface Source: https://rsdoctor.rs/guide/rules/rule-custom Represents a range within source code, defined by start and optional end positions. ```typescript /** Source code range */ interface SourceRange { start: SourcePosition; end?: SourcePosition; } ``` -------------------------------- ### Disabling a Linter Rule Example Source: https://rsdoctor.rs/guide/rules/rules Demonstrates how to disable a specific linter rule, 'duplicate-package' in this case, by setting its severity input to 'off'. ```typescript import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin'; export default { plugin: [ new RsdoctorRspackPlugin({ linter: { level: 'Error', extends: [], rules: { 'duplicate-package': 'off', }, }, }), ], }; ``` -------------------------------- ### Execute Build Command with Yarn Source: https://rsdoctor.rs/llms-full.txt Run the build command using Yarn. Rsdoctor will generate report data locally. ```sh yarn run build ``` -------------------------------- ### Disable Parse Bundle Analysis Source: https://rsdoctor.rs/config/options/supports Example configuration to disable the parseBundle capability within the RsdoctorRspackPlugin to reduce build time in large repositories. ```ts chain.plugin('Rsdoctor').use(RsdoctorRspackPlugin, [ { supports: { parseBundle: false, }, }, ]); ``` -------------------------------- ### Execute Build Command with pnpm Source: https://rsdoctor.rs/llms-full.txt Run the build command using pnpm. Rsdoctor will generate report data locally. ```sh pnpm run build ``` -------------------------------- ### Enable Native Plugin for Faster Analysis Source: https://rsdoctor.rs/blog/release/release-note-1_0 Enable Rust-based native plugins for improved build analysis performance. This optimization can reduce overall analysis time by over 20%. ```typescript new RsdoctorRspackPlugin({ experiments: { enableNativePlugin: true, }, }); ``` -------------------------------- ### Install Rsdoctor for Rspack Projects (deno) Source: https://rsdoctor.rs/guide/start/quick-start Use this command to add the Rsdoctor Rspack plugin to your Rspack-based projects like Rsbuild or Rslib when using deno. ```sh deno add npm:@rsdoctor/rspack-plugin -D ``` -------------------------------- ### Install Rsdoctor for Rspack Projects (pnpm) Source: https://rsdoctor.rs/guide/start/quick-start Use this command to add the Rsdoctor Rspack plugin to your Rspack-based projects like Rsbuild or Rslib when using pnpm. ```sh pnpm add @rsdoctor/rspack-plugin -D ``` -------------------------------- ### Install Rsdoctor for Rspack Projects (yarn) Source: https://rsdoctor.rs/guide/start/quick-start Use this command to add the Rsdoctor Rspack plugin to your Rspack-based projects like Rsbuild or Rslib when using yarn. ```sh yarn add @rsdoctor/rspack-plugin -D ``` -------------------------------- ### Install Rsdoctor for Rspack Projects (npm) Source: https://rsdoctor.rs/guide/start/quick-start Use this command to add the Rsdoctor Rspack plugin to your Rspack-based projects like Rsbuild or Rslib when using npm. ```sh npm add @rsdoctor/rspack-plugin -D ``` -------------------------------- ### Brief Configuration Interface Source: https://rsdoctor.rs/config/options/brief Defines the structure for Brief mode configuration. `reportHtmlName` sets the HTML report filename, and `writeDataJson` (deprecated) controls the generation of JSON data files. ```typescript interface BriefConfig { reportHtmlName?: string | undefined; writeDataJson: boolean; } ``` -------------------------------- ### Install Rsdoctor for Webpack Projects (deno) Source: https://rsdoctor.rs/guide/start/quick-start Use this command to add the Rsdoctor Webpack plugin to your Webpack projects. Rsdoctor requires webpack version 5 or higher. ```sh deno add npm:@rsdoctor/webpack-plugin -D ```