File size: 686 Bytes
b91e262 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | import type { Compiler } from 'webpack'
const PLUGIN_NAME = 'ReactRefreshRspackPlugin'
class ReactRefreshRspackPlugin {
static loader = 'builtin:react-refresh-loader'
apply(compiler: Compiler) {
new compiler.webpack.ProvidePlugin({
$ReactRefreshRuntime$: require.resolve('./internal/RspackReactRefresh'),
}).apply(compiler)
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
compilation.hooks.additionalTreeRuntimeRequirements.tap(
PLUGIN_NAME,
(_, runtimeRequirements) => {
runtimeRequirements.add(compiler.webpack.RuntimeGlobals.moduleCache)
}
)
})
}
}
export default ReactRefreshRspackPlugin
|