Enabling React Fast Refresh functionality primarily involves two aspects: code injection and code transformation.
Code injection will inject some code from the react-refresh package, as well as some custom runtime code, all of which are integrated in this plugin and can be injected through.
Compared to the previous approach, this method decouples the React Fast Refresh code injection logic from the transformation logic. The code injection logic is handled uniformly by this plugin, while the code transformation is handled by loaders. This means that this plugin can be used in conjunction with builtin:swc-loader, swc-loader, or babel-loader.
Example
For usage with builtin:swc-loader, you can refer to the example at examples/react-refresh, When using with swc-loader, simply replace builtin:swc-loader with swc-loader.
Specifies which files should be processed by the React Refresh loader. This option is passed to the builtin:react-refresh-loader as the rule.test condition.
Explicitly includes files to be processed by the React Refresh loader. This option is passed to the builtin:react-refresh-loader as the rule.include condition.
Use this to limit processing to specific directories or file patterns.
Works identically to Rspack's rule.include option.
Can be used to exclude certain resources from being processed by the plugin by the resource query. The value is the same as the rule.resourceQuery option in Rspack.
For example, to exclude all resources with the raw query, such as import rawTs from './ReactComponent.ts?raw';, use the following:
The npm package @rspack/plugin-react-refresh receives a total of 1,036,834 weekly downloads. As such, @rspack/plugin-react-refresh popularity was classified as popular.
We found that @rspack/plugin-react-refresh demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 2 open source maintainers collaborating on the project.
Package last updated on 12 Nov 2025
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Socket found a Rust typosquat (finch-rust) that loads sha-rust to steal credentials, using impersonation and an unpinned dependency to auto-deliver updates.
A pair of typosquatted Go packages posing as Google’s UUID library quietly turn helper functions into encrypted exfiltration channels to a paste site, putting developer and CI data at risk.