fix(plugin-api-docgen): support HMR by using rsbuild-plugin-virtual-module#3080
Merged
fix(plugin-api-docgen): support HMR by using rsbuild-plugin-virtual-module#3080
Conversation
…odule Replace source.define + chokidar with rsbuild-plugin-virtual-module and addDependency for automatic HMR when source files change. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Deploying rspress-v2 with
|
| Latest commit: |
4af6437
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://556c8321.rspress-v2.pages.dev |
| Branch Preview URL: | https://syt-api-doc-gen-hmr.rspress-v2.pages.dev |
Contributor
Rsdoctor Bundle Diff AnalysisFound 3 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
Contributor
There was a problem hiding this comment.
Pull request overview
Updates @rspress/plugin-api-docgen to support HMR by generating the API doc map via an rsbuild virtual module (instead of source.define + chokidar), and switches the client component to import the map directly.
Changes:
- Replace global
define-injected API map +chokidarwatching withrsbuild-plugin-virtual-module+addDependency. - Update the API React component to import the API doc map from a virtual module.
- Simplify docgen types/logic by removing the dev watcher path and returning watched source file paths.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Adds rsbuild-plugin-virtual-module lock entries and updates dependency resolutions for the plugin package. |
| packages/plugin-api-docgen/static/global-components/API.tsx | Switches from global variable access to importing the doc map from a virtual module. |
| packages/plugin-api-docgen/src/types.ts | Removes now-unused types/options related to the old watcher flow. |
| packages/plugin-api-docgen/src/index.ts | Registers a virtual module to produce the API doc map and register dependencies for HMR. |
| packages/plugin-api-docgen/src/docgen.ts | Removes chokidar-based watch/update logic; returns source paths for dependency tracking. |
| packages/plugin-api-docgen/package.json | Removes chokidar, adds rsbuild-plugin-virtual-module. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Timeless0911
approved these changes
Jan 31, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
source.define+chokidarwithrsbuild-plugin-virtual-moduleandaddDependencyfor automatic HMR when API source files changeaddDependencyTest plan
pnpm buildsucceeds🤖 Generated with Claude Code