Gathering detailed insights and metrics for @rspack/plugin-react-refresh
An interesting fact about npm is that it started as a weekend project by its creator, Isaac Z. Schlueter, in 2009. It was officially launched in January 2010.
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.