Skip to content

Comments

fix(types): add public typing for import.meta.webpackHot.on#7028

Merged
chenjiahan merged 9 commits intomainfrom
fix_module_hot_type_01124
Jan 24, 2026
Merged

fix(types): add public typing for import.meta.webpackHot.on#7028
chenjiahan merged 9 commits intomainfrom
fix_module_hot_type_01124

Conversation

@chenjiahan
Copy link
Member

Summary

  • Added public typing for the new import.meta.webpackHot.on() method to the @rsbuild/core/types module.
  • Updated test cases to verify the type changes.

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings January 24, 2026 08:42
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 import.meta.webpackHot.on method, allowing developers to leverage TypeScript's benefits when handling custom HMR messages. Additionally, it refactors related end-to-end tests to be more streamlined and robust, ensuring the HMR functionality works as expected with the updated typings.

Highlights

  • Enhanced HMR Type Definitions: Public typing for import.meta.webpackHot.on() has been added to @rsbuild/core/types, improving type safety for custom Hot Module Replacement (HMR) events.
  • Refactored E2E Tests: Existing end-to-end tests for custom HMR messages have been refactored to use a new dev() helper, simplifying test setup and making them more robust.
  • Improved Type Safety in HMR Client: Internal HMR client code now uses unknown instead of any for custom HMR event payloads, enhancing type safety.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 24, 2026

Copy link
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

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.Hot interface augmentation with on method 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.Hot interface and improved type safety with unknown instead of any
  • Enhanced test infrastructure to expose RsbuildDevServer in 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.

@chenjiahan chenjiahan merged commit 14c8ff8 into main Jan 24, 2026
6 checks passed
@chenjiahan chenjiahan deleted the fix_module_hot_type_01124 branch January 24, 2026 09:13
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.

1 participant