Gathering detailed insights and metrics for @umijs/react-refresh-webpack-plugin
Gathering detailed insights and metrics for @umijs/react-refresh-webpack-plugin
Gathering detailed insights and metrics for @umijs/react-refresh-webpack-plugin
Gathering detailed insights and metrics for @umijs/react-refresh-webpack-plugin
npm install @umijs/react-refresh-webpack-plugin
Typescript
Module System
Min. Node Version
Node Version
NPM Version
58.8
Supply Chain
67.6
Quality
76.4
Maintenance
50
Vulnerability
95.1
License
JavaScript (100%)
Total Downloads
1,162,206
Last Day
3,530
Last Week
37,520
Last Month
179,647
Last Year
973,345
3,157 Stars
870 Commits
194 Forks
18 Watching
5 Branches
48 Contributors
Latest Version
0.5.11
Package Id
@umijs/react-refresh-webpack-plugin@0.5.11
Unpacked Size
127.86 kB
Size
35.24 kB
File Count
58
NPM Version
8.19.4
Node Version
16.20.2
Publised On
08 Sept 2023
Cumulative downloads
Total Downloads
Last day
-46.5%
3,530
Compared to previous day
Last week
-17.7%
37,520
Compared to previous week
Last month
44.2%
179,647
Compared to previous month
Last year
415.4%
973,345
Compared to previous year
9
8
43
An EXPERIMENTAL Webpack plugin to enable "Fast Refresh" (also known as Hot Reloading) for React components.
This plugin is not 100% stable. We're hoping to land a v1 release soon - please help us by reporting any issues you've encountered!
Ensure that you are using at least the minimum supported versions of this plugin's peer dependencies - older versions unfortunately do not contain code to orchestrate "Fast Refresh", and thus cannot be made compatible.
We recommend using the following versions:
Dependency | Version |
---|---|
react | 16.13.0 +, 17.x or 18.x |
react-dom | 16.13.0 +, 17.x or 18.x |
react-refresh | 0.10.0 + |
webpack | 4.46.0 + or 5.2.0 + |
Dependency | Version |
---|---|
react | 16.9.0 |
react-dom | 16.9.0 |
react-refresh | 0.10.0 |
webpack | 4.43.0 |
react-three-fiber
, react-pdf
, ink
)To ensure full support of "Fast Refresh" with components rendered by custom renderers,
you should ensure the renderer you're using depends on a recent version of react-reconciler
.
We recommend version 0.25.0
or above, but any versions above 0.22.0
should work.
If the renderer is not compatible, please file them an issue instead.
With all prerequisites met, you can install this plugin using your package manager of choice:
1# if you prefer npm 2npm install -D @pmmmwh/react-refresh-webpack-plugin react-refresh 3 4# if you prefer yarn 5yarn add -D @pmmmwh/react-refresh-webpack-plugin react-refresh 6 7# if you prefer pnpm 8pnpm add -D @pmmmwh/react-refresh-webpack-plugin react-refresh
The react-refresh
package (from the React team) is a required peer dependency of this plugin.
We recommend using version 0.10.0
or above.
TypeScript support is available out-of-the-box for those who use webpack.config.ts
.
Our exported types however depends on type-fest
, so you'll have to add it as a devDependency
:
1# if you prefer npm 2npm install -D type-fest 3 4# if you prefer yarn 5yarn add -D type-fest 6 7# if you prefer pnpm 8pnpm add -D type-fest
:memo: Note:
type-fest@2.x
only supports Node.js v12.20 or above. If you're using an older version of Node.js, please installtype-fest@1.x
.
For most setups, we recommend integrating with babel-loader
.
It covers the most use cases and is officially supported by the React team.
The example below will assume you're using webpack-dev-server
.
If you haven't done so, set up your development Webpack configuration for Hot Module Replacement (HMR).
1const isDevelopment = process.env.NODE_ENV !== 'production'; 2 3module.exports = { 4 mode: isDevelopment ? 'development' : 'production', 5 devServer: { 6 hot: true, 7 }, 8};
webpack-hot-middleware
1const webpack = require('webpack'); 2 3const isDevelopment = process.env.NODE_ENV !== 'production'; 4 5module.exports = { 6 mode: isDevelopment ? 'development' : 'production', 7 plugins: [isDevelopment && new webpack.HotModuleReplacementPlugin()].filter(Boolean), 8};
webpack-plugin-serve
1const { WebpackPluginServe } = require('webpack-plugin-serve'); 2 3const isDevelopment = process.env.NODE_ENV !== 'production'; 4 5module.exports = { 6 mode: isDevelopment ? 'development' : 'production', 7 plugins: [isDevelopment && new WebpackPluginServe()].filter(Boolean), 8};
Then, add the react-refresh/babel
plugin to your Babel configuration and this plugin to your Webpack configuration.
1const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin'); 2 3const isDevelopment = process.env.NODE_ENV !== 'production'; 4 5module.exports = { 6 mode: isDevelopment ? 'development' : 'production', 7 module: { 8 rules: [ 9 { 10 test: /\.[jt]sx?$/, 11 exclude: /node_modules/, 12 use: [ 13 { 14 loader: require.resolve('babel-loader'), 15 options: { 16 plugins: [isDevelopment && require.resolve('react-refresh/babel')].filter(Boolean), 17 }, 18 }, 19 ], 20 }, 21 ], 22 }, 23 plugins: [isDevelopment && new ReactRefreshWebpackPlugin()].filter(Boolean), 24};
:memo: Note:
Ensure both the Babel transform (
react-refresh/babel
) and this plugin are enabled only indevelopment
mode!
ts-loader
:warning: Warning: This is an un-official integration maintained by the community.
Install react-refresh-typescript
.
Ensure your TypeScript version is at least 4.0.
1# if you prefer npm 2npm install -D react-refresh-typescript 3 4# if you prefer yarn 5yarn add -D react-refresh-typescript 6 7# if you prefer pnpm 8pnpm add -D react-refresh-typescript
Then, instead of wiring up react-refresh/babel
via babel-loader
,
you can wire-up react-refresh-typescript
with ts-loader
:
1const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin'); 2const ReactRefreshTypeScript = require('react-refresh-typescript'); 3 4const isDevelopment = process.env.NODE_ENV !== 'production'; 5 6module.exports = { 7 mode: isDevelopment ? 'development' : 'production', 8 module: { 9 rules: [ 10 { 11 test: /\.[jt]sx?$/, 12 exclude: /node_modules/, 13 use: [ 14 { 15 loader: require.resolve('ts-loader'), 16 options: { 17 getCustomTransformers: () => ({ 18 before: [isDevelopment && ReactRefreshTypeScript()].filter(Boolean), 19 }), 20 transpileOnly: isDevelopment, 21 }, 22 }, 23 ], 24 }, 25 ], 26 }, 27 plugins: [isDevelopment && new ReactRefreshWebpackPlugin()].filter(Boolean), 28};
ts-loader
won't work with HMR unlesstranspileOnly
is set totrue
. You should useForkTsCheckerWebpackPlugin
if you need typechecking during development.
swc-loader
:warning: Warning: This is an un-official integration maintained by the community.
Ensure your @swc/core
version is at least 1.2.86
.
It is also recommended to use swc-loader
version 0.1.13
or above.
Then, instead of wiring up react-refresh/babel
via babel-loader
,
you can wire-up swc-loader
and use the refresh
transform:
1const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin'); 2 3const isDevelopment = process.env.NODE_ENV !== 'production'; 4 5module.exports = { 6 mode: isDevelopment ? 'development' : 'production', 7 module: { 8 rules: [ 9 { 10 test: /\.[jt]sx?$/, 11 exclude: /node_modules/, 12 use: [ 13 { 14 loader: require.resolve('swc-loader'), 15 options: { 16 jsc: { 17 transform: { 18 react: { 19 development: isDevelopment, 20 refresh: isDevelopment, 21 }, 22 }, 23 }, 24 }, 25 }, 26 ], 27 }, 28 ], 29 }, 30 plugins: [isDevelopment && new ReactRefreshWebpackPlugin()].filter(Boolean), 31};
Starting from version
0.1.13
,swc-loader
will set thedevelopment
option based on Webpack'smode
option.swc
won't enable fast refresh whendevelopment
isfalse
.
For more information on how to set up "Fast Refresh" with different integrations, please check out our examples.
This plugin integrates with the most common Webpack HMR solutions to surface errors during development - in the form of an error overlay.
By default, webpack-dev-server
is used,
but you can set the overlay.sockIntegration
option to match what you're using.
The supported versions are as follows:
Dependency | Version |
---|---|
webpack-dev-server | 3.6.0 + or 4.x |
webpack-hot-middleware | 2.x |
webpack-plugin-serve | 0.x or 1.x |
Please refer to the API docs for all available options.
Please refer to the Troubleshooting guide for FAQs and resolutions to common issues.
This project is licensed under the terms of the MIT License.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
9 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 7
Reason
Found 0/1 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
23 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More