Repository navigation
feat: add Rsdoctor v2 migration skill #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
skills/rsdoctor-analysis/references/install-rsdoctor-webpack.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| --- | ||
| name: rsdoctor-migrate-v2 | ||
| description: Upgrade Rspack projects from Rsdoctor 1.x to 2.0. Use when replacing legacy Rsdoctor packages, converting Rsdoctor setup to ESM, updating removed or deprecated options, moving MCP workflows to Agent CLI, or validating Node.js and Rspack compatibility for an Rsdoctor 2.0 upgrade. | ||
| --- | ||
|
|
||
| # Upgrade Rsdoctor to v2 | ||
|
|
||
| Upgrade with the smallest behavior-preserving diff. Treat the official migration guides and the installed package exports as the source of truth: | ||
|
|
||
| - https://rsdoctor.rs/guide/start/migration-v2 | ||
| - https://rsdoctor.rs/config/options/options-v2 | ||
|
|
||
| ## Workflow | ||
|
|
||
| 1. **Audit the current integration** | ||
| - Read `package.json`, the lockfile, Node.js version files, and the build scripts. | ||
| - Determine the installed Rsdoctor package versions from the lockfile or package metadata, and check which package provides the active `RsdoctorRspackPlugin`. Migrate a 1.x `@rsdoctor/rspack-plugin` integration, including any partially migrated setup that still imports it. If `@rsdoctor/core` 2.x already provides the active plugin, validate the integration instead of migrating it again. `@rsdoctor/core` alone does not prove a 2.x integration because 1.x projects may use it for custom rules. Distinguish direct integration from framework-owned transitive 1.x dependencies. | ||
| - Locate Rspack, Rsbuild, and Rsdoctor configuration files. Preserve any environment condition that enables Rsdoctor only for selected builds. | ||
| - Search source, scripts, and editor configuration for `@rsdoctor/`, `RsdoctorRspackPlugin`, legacy options, MCP setup, and report-output assumptions. | ||
| - Record the current build command and expected report formats before editing. | ||
|
|
||
| 2. **Pass the compatibility gate** | ||
| - Require Node.js `^20.19.0 || >=22.12.0` and verify that the installed Rspack version satisfies the selected `@rsdoctor/core` peer dependency. Check the selected package's `engines` and peer dependencies if they differ. | ||
| - For webpack projects, stop the Rsdoctor upgrade. Keep Rsdoctor 1.x or migrate the project to Rspack as a separate task first. | ||
| - Update only Rsdoctor dependencies and preserve the existing Rspack and framework versions. If a framework supplies Rspack, do not add `@rspack/core` directly. Report a compatibility issue separately only when the installed version does not satisfy Rsdoctor's peer dependency. | ||
|
|
||
| 3. **Plan only applicable changes** | ||
| - Read [references/migration-map.md](references/migration-map.md). | ||
| - List the package, import, module-format, configuration, and AI-workflow changes that apply to this project. | ||
| - Choose one Rsdoctor 2.x target version. Keep `@rsdoctor/core` and `@rsdoctor/cli` on the same version; version `@rsdoctor/agent-cli` independently. | ||
|
|
||
| 4. **Migrate packages and imports** | ||
| - Replace `@rsdoctor/rspack-plugin` with `@rsdoctor/core` and import `RsdoctorRspackPlugin` from `@rsdoctor/core`. | ||
|
yifancong marked this conversation as resolved.
|
||
| - Convert Rsdoctor `require()` calls to ESM imports. When the project remains CommonJS, move only the affected build config to a supported ESM extension such as `.mjs` instead of changing the entire package module type without need. | ||
| - Do not mechanically rename imports from removed low-level packages. Resolve every imported symbol against the public 2.x exports, then type-check it. | ||
| - Use the project's existing package manager and avoid unrelated dependency or lockfile updates. | ||
| - Do not remove framework-owned transitive 1.x dependencies merely because they remain in the lockfile; verify whether the framework still activates its old plugin. | ||
|
|
||
| 5. **Migrate configuration without changing report intent** | ||
| - Replace each removed or deprecated field using the mapping reference. | ||
| - Preserve whether the project needs HTML, JSON, or both, and preserve intentional code-source omission from lite reports. | ||
| - Delete `experiments.enableNativePlugin` and `supports.banner`; both options were removed in 2.0, and the Rspack native plugin is always enabled. | ||
| - If Rspack reports that `experiments.RsdoctorPlugin` is unavailable, report the compatibility issue instead of changing Rspack or framework dependencies as part of the Rsdoctor upgrade. | ||
|
|
||
| 6. **Migrate AI workflows when present** | ||
| - Remove `@rsdoctor/mcp-server`, its editor MCP entries, and scripts that start it. | ||
| - Add `@rsdoctor/agent-cli`, generate a fresh `rsdoctor-data.json`, and invoke `rsdoctor-agent` against that file. | ||
| - Rewrite automation to consume structured CLI output. Agent CLI is not an MCP-compatible or drop-in API replacement. Do not carry over MCP ports or assume its compiler-selection syntax applies; for multi-compiler data, select a compiler using Agent CLI's `--compiler <name>`. | ||
|
|
||
| 7. **Validate the migration** | ||
| - Reinstall dependencies and run the production build under the project's supported Node.js version. | ||
| - Confirm the expected Rsdoctor report is generated and open the overview, compilation, and bundle-analysis pages used by the project. | ||
| - If JSON output or Agent CLI is used, validate a newly generated data file with one representative command. | ||
| - Run the relevant tests and type checks, then search again for removed packages and legacy options. | ||
| - Report what changed, commands run, and any validation that could not be completed. Do not claim success from dependency installation alone. | ||
|
|
||
| ## Output language | ||
|
|
||
| - Write all user-facing explanations, plans, progress updates, and migration summaries in Chinese. | ||
| - Keep package names, API names, configuration fields, commands, file paths, and error messages in their original form; explain their meaning in Chinese when needed. | ||
|
|
||
| ## Guardrails | ||
|
|
||
| - Do not install Rsdoctor 2.x into a webpack-only project. | ||
| - Do not activate 1.x and 2.x plugins together to work around migration errors. Investigate framework-owned transitive 1.x packages separately. | ||
| - Do not silently change report formats, filenames, server ports, or source-code visibility. | ||
| - Do not replace MCP configuration with an invented Agent CLI service configuration. | ||
| - Do not remove compatibility code until the replacement build and report have been verified. | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When ordinary bundle analysis finds an Rspack 2 project without a plugin, this rule unconditionally opts the project into Rsdoctor 2, even though Rsdoctor 1.x's published
@rsdoctor/rspack-pluginmanifest accepts Rspack independently of that major split and Rsdoctor 2 is currently distributed as a prerelease. A request to generate analysis data can therefore unexpectedly become a major/ESM migration; select the Rsdoctor major from an existing integration or explicit migration intent rather than from the Rspack major alone.Useful? React with 👍 / 👎.