fix(types): add public typing for import.meta.webpackHot.on#7028
fix(types): add public typing for import.meta.webpackHot.on#7028chenjiahan merged 9 commits intomainfrom
import.meta.webpackHot.on#7028Conversation
Summary of ChangesHello @chenjiahan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request primarily focuses on improving the developer experience and type safety around custom Hot Module Replacement (HMR) events within Rsbuild. It introduces public type definitions for the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request successfully adds public typing for the import.meta.webpackHot.on() method and refactors the associated E2E tests for clarity and maintainability. The changes are well-implemented. I have one suggestion to further improve type safety in the new public API.
Deploying rsbuild with
|
| Latest commit: |
a958b13
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://d8f1a518.rsbuild-v2.pages.dev |
| Branch Preview URL: | https://fix-module-hot-type-01124.rsbuild-v2.pages.dev |
There was a problem hiding this comment.
Pull request overview
This PR adds public TypeScript typing for the import.meta.webpackHot.on() method to support custom HMR message handling, following the implementation added in PR #7003. The change augments the Rspack.Hot interface from @rspack/core/module to include the new on method, making it available to TypeScript users.
Changes:
- Added
Rspack.Hotinterface augmentation withonmethod for custom HMR event handling - Updated server message types to support non-object payloads for greater flexibility
- Refactored internal HMR code to use the new
Rspack.Hotinterface and improved type safety withunknowninstead ofany - Enhanced test infrastructure to expose
RsbuildDevServerin test helpers and verify the type changes
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/types.d.ts | Adds Rspack.Hot interface augmentation with the on method for custom HMR events |
| packages/core/tsconfig.json | Includes types.d.ts in TypeScript compilation for proper type resolution |
| packages/core/src/server/socketServer.ts | Changes ServerCustomMessage.data.data type from Record<string, any> to any for flexibility |
| packages/core/src/client/hmr.ts | Refactors to use new Rspack.Hot interface and improves type safety with unknown |
| e2e/tsconfig.json | Adds test source files to TypeScript compilation for type checking |
| e2e/helper/jsApi.ts | Exposes RsbuildDevServer instance in dev helper for testing sockWrite functionality |
| e2e/cases/javascript-api/server-custom-message/src/index.ts | Adds type declarations and uses non-null assertion for type safety |
| e2e/cases/javascript-api/server-custom-message/src/env.d.ts | References @rsbuild/core/types to enable import.meta.webpackHot.on typing |
| e2e/cases/javascript-api/server-custom-message/index.test.ts | Refactors tests to use the dev fixture and verify HMR custom message handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
import.meta.webpackHot.on()method to the@rsbuild/core/typesmodule.Related Links
Checklist