Skip to content

fix(plugin-api-docgen): support HMR by using rsbuild-plugin-virtual-module#3080

Merged
SoonIter merged 5 commits intomainfrom
syt/api-doc-gen-hmr
Jan 31, 2026
Merged

fix(plugin-api-docgen): support HMR by using rsbuild-plugin-virtual-module#3080
SoonIter merged 5 commits intomainfrom
syt/api-doc-gen-hmr

Conversation

@SoonIter
Copy link
Copy Markdown
Member

@SoonIter SoonIter commented Jan 31, 2026

image

Summary

  • Replace source.define + chokidar with rsbuild-plugin-virtual-module and addDependency for automatic HMR when API source files change
  • Remove chokidar dependency, use virtual module's built-in file watching via addDependency
  • Client component now imports from virtual module instead of using global variable

Test plan

  • Verify pnpm build succeeds
  • Run e2e test for plugin-api-docgen
  • Verify HMR works: modify a source file and confirm the page updates without full reload

🤖 Generated with Claude Code

…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>
Copilot AI review requested due to automatic review settings January 31, 2026 03:31
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Jan 31, 2026

Deploying rspress-v2 with  Cloudflare Pages  Cloudflare Pages

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

View logs

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 31, 2026

Rsdoctor Bundle Diff Analysis

Found 3 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Change
node 11.2 MB 0
node_md 1.5 MB 0
web 15.7 MB 0

Generated by Rsdoctor GitHub Action

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 + chokidar watching with rsbuild-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.

Comment thread packages/plugin-api-docgen/static/global-components/API.tsx
Comment thread pnpm-lock.yaml
Comment thread packages/plugin-api-docgen/package.json
SoonIter and others added 2 commits January 31, 2026 11:46
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@SoonIter SoonIter requested a review from Timeless0911 January 31, 2026 03:52
@SoonIter SoonIter merged commit 4460581 into main Jan 31, 2026
5 checks passed
@SoonIter SoonIter deleted the syt/api-doc-gen-hmr branch January 31, 2026 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants