Skip to content

Commit

Permalink
Merge pull request #3942 from webkom/react-fast-refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
eikhr committed May 29, 2023
2 parents 20b1f88 + 143e33e commit bf68417
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 46 deletions.
3 changes: 1 addition & 2 deletions app/Root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ConnectedRouter } from 'connected-react-router';
import { HelmetProvider } from 'react-helmet-async';
import { hot } from 'react-hot-loader/root';
import { Provider } from 'react-redux';
import ErrorBoundary from 'app/components/ErrorBoundary';
import type { Store } from 'app/store/createStore';
Expand Down Expand Up @@ -28,4 +27,4 @@ const Root = (props: Props) => {
);
};

export default hot(Root);
export default Root;
1 change: 0 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ module.exports = (api) => {
],
plugins: [
'@babel/plugin-syntax-dynamic-import',
'react-hot-loader/babel',
'@babel/plugin-proposal-class-properties',
'@loadable/babel-plugin',
],
Expand Down
19 changes: 13 additions & 6 deletions config/webpack.client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const fs = require('fs');
const path = require('path');
const LoadablePlugin = require('@loadable/webpack-plugin');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const AssetsPlugin = require('assets-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
Expand Down Expand Up @@ -52,11 +53,7 @@ module.exports = (env, argv) => {
entry: {
app: isProduction
? ['./app/index.ts']
: [
'webpack-hot-middleware/client',
'react-hot-loader/patch',
'./app/index.ts',
],
: ['webpack-hot-middleware/client', './app/index.ts'],
},

output: {
Expand Down Expand Up @@ -95,6 +92,7 @@ module.exports = (env, argv) => {
}),
process.env.BUNDLE_ANALYZER && new BundleAnalyzerPlugin(),
!isProduction && new webpack.HotModuleReplacementPlugin(),
!isProduction && new ReactRefreshWebpackPlugin(),

new StatsWriterPlugin({
filename: 'stats.json',
Expand Down Expand Up @@ -166,8 +164,17 @@ module.exports = (env, argv) => {
rules: [
{
test: /\.[tj]sx?$/,
loader: 'babel-loader',
include: [path.resolve(root, 'app'), path.resolve(root, 'config')],
use: [
{
loader: require.resolve('babel-loader'),
options: {
plugins: [
!isProduction && require.resolve('react-refresh/babel'),
].filter(Boolean),
},
},
],
},
{
test: /\.css$/,
Expand Down
2 changes: 2 additions & 0 deletions config/webpack.server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('path');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const webpack = require('webpack');
const FilterWarningsPlugin = require('webpack-filter-warnings-plugin');
Expand Down Expand Up @@ -39,6 +40,7 @@ module.exports = (env, argv) => {

plugins: [
!isProduction && new webpack.HotModuleReplacementPlugin(),
!isProduction && new ReactRefreshWebpackPlugin(),
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
"@loadable/babel-plugin": "^5.15.3",
"@loadable/server": "^5.15.3",
"@loadable/webpack-plugin": "^5.15.2",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
"@types/classnames": "^2.3.1",
"@types/enzyme": "^3.10.13",
"@types/express": "^4.17.17",
Expand Down Expand Up @@ -181,7 +182,7 @@
"postcss-preset-env": "^8.4.1",
"prettier": "2.8.8",
"process": "^0.11.10",
"react-hot-loader": "^4.13.1",
"react-refresh": "^0.14.0",
"redux-mock-store": "^1.5.4",
"style-loader": "^3.3.3",
"stylelint": "^15.6.2",
Expand Down
80 changes: 44 additions & 36 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2079,6 +2079,21 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@pmmmwh/react-refresh-webpack-plugin@^0.5.10":
version "0.5.10"
resolved "https://registry.yarnpkg.com/@pmmmwh/react-refresh-webpack-plugin/-/react-refresh-webpack-plugin-0.5.10.tgz#2eba163b8e7dbabb4ce3609ab5e32ab63dda3ef8"
integrity sha512-j0Ya0hCFZPd4x40qLzbhGsh9TMtdb+CJQiso+WxLOPNasohq9cc5SNUcwsZaRH6++Xh91Xkm/xHCkuIiIu0LUA==
dependencies:
ansi-html-community "^0.0.8"
common-path-prefix "^3.0.0"
core-js-pure "^3.23.3"
error-stack-parser "^2.0.6"
find-up "^5.0.0"
html-entities "^2.1.0"
loader-utils "^2.0.4"
schema-utils "^3.0.0"
source-map "^0.7.3"

"@polka/url@^1.0.0-next.20":
version "1.0.0-next.21"
resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.21.tgz#5de5a2385a35309427f6011992b544514d559aa1"
Expand Down Expand Up @@ -3220,7 +3235,7 @@ ansi-escapes@^4.2.1, ansi-escapes@^4.3.0:
dependencies:
type-fest "^0.21.3"

ansi-html-community@0.0.8:
ansi-html-community@0.0.8, ansi-html-community@^0.0.8:
version "0.0.8"
resolved "https://registry.yarnpkg.com/ansi-html-community/-/ansi-html-community-0.0.8.tgz#69fbc4d6ccbe383f9736934ae34c3f8290f1bf41"
integrity sha512-1APHAyr3+PCamwNw3bXCPp4HFLONZt/yIH0sZp0/469KWNTEy+qN5jQ3GVX6DMZ1UXAi34yVwtTeaG/HpBuuzw==
Expand Down Expand Up @@ -4129,6 +4144,11 @@ commander@^7.2.0:
resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7"
integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==

common-path-prefix@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/common-path-prefix/-/common-path-prefix-3.0.0.tgz#7d007a7e07c58c4b4d5f433131a19141b29f11e0"
integrity sha512-QE33hToZseCH3jS0qN96O/bSh3kaw/h+Tq7ngyY9eWDUnTlTNUyqfqvCXioLe5Na5jFsL78ra/wuBU4iuEgd4w==

common-tags@^1.8.0:
version "1.8.2"
resolved "https://registry.yarnpkg.com/common-tags/-/common-tags-1.8.2.tgz#94ebb3c076d26032745fd54face7f688ef5ac9c6"
Expand Down Expand Up @@ -4252,6 +4272,11 @@ core-js-compat@^3.25.1, core-js-compat@^3.30.1, core-js-compat@^3.30.2:
dependencies:
browserslist "^4.21.5"

core-js-pure@^3.23.3:
version "3.30.2"
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.30.2.tgz#005a82551f4af3250dcfb46ed360fad32ced114e"
integrity sha512-p/npFUJXXBkCCTIlEGBdghofn00jWG6ZOtdoIXSJmAu2QBvN0IqpZXWweOytcwE6cfx8ZvVUy1vw8zxhe4Y2vg==

core-js@^3.30.2, core-js@^3.6.5:
version "3.30.2"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.30.2.tgz#6528abfda65e5ad728143ea23f7a14f0dcf503fc"
Expand Down Expand Up @@ -4899,11 +4924,6 @@ dom-serializer@^2.0.0:
domhandler "^5.0.2"
entities "^4.2.0"

dom-walk@^0.1.0:
version "0.1.2"
resolved "https://registry.yarnpkg.com/dom-walk/-/dom-walk-0.1.2.tgz#0c548bef048f4d1f2a97249002236060daa3fd84"
integrity sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w==

domelementtype@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.3.0.tgz#5c45e8e869952626331d7aab326d01daf65d589d"
Expand Down Expand Up @@ -5134,6 +5154,13 @@ error-ex@^1.3.1:
dependencies:
is-arrayish "^0.2.1"

error-stack-parser@^2.0.6:
version "2.1.4"
resolved "https://registry.yarnpkg.com/error-stack-parser/-/error-stack-parser-2.1.4.tgz#229cb01cdbfa84440bfa91876285b94680188286"
integrity sha512-Sk5V6wVazPhq5MhpO+AUxJn5x7XSXGl1R93Vn7i+zS15KDVxQijejNCrz8340/2bgLBjR9GtEG8ZVKONDjcqGQ==
dependencies:
stackframe "^1.3.4"

es-abstract@^1.19.0, es-abstract@^1.19.5, es-abstract@^1.20.0, es-abstract@^1.20.4:
version "1.20.4"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.20.4.tgz#1d103f9f8d78d4cf0713edcd6d0ed1a46eed5861"
Expand Down Expand Up @@ -6095,14 +6122,6 @@ global-prefix@^3.0.0:
kind-of "^6.0.2"
which "^1.3.1"

global@^4.3.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/global/-/global-4.4.0.tgz#3e7b105179006a323ed71aafca3e9c57a5cc6406"
integrity sha512-wv/LAoHdRE3BeTGz53FAamhGlPLhlssK45usmGFThIi4XqnBmjKQ16u+RNbP7WvigRZDxUsM0J3gcQ5yicaL0w==
dependencies:
min-document "^2.19.0"
process "^0.11.10"

globals@^11.1.0, globals@^11.12.0:
version "11.12.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e"
Expand Down Expand Up @@ -7583,7 +7602,7 @@ loader-runner@^4.2.0:
resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.3.0.tgz#c1b4a163b99f614830353b16755e7149ac2314e1"
integrity sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==

loader-utils@^2.0.0, loader-utils@^2.0.3:
loader-utils@^2.0.0, loader-utils@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.4.tgz#8b5cb38b5c34a9a018ee1fc0e6a066d1dfcc528c"
integrity sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw==
Expand Down Expand Up @@ -7891,13 +7910,6 @@ mimic-fn@^2.1.0:
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b"
integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==

min-document@^2.19.0:
version "2.19.0"
resolved "https://registry.yarnpkg.com/min-document/-/min-document-2.19.0.tgz#7bd282e3f5842ed295bb748cdd9f1ffa2c824685"
integrity sha512-9Wy1B3m3f66bPPmU5hdA4DR4PB2OfDU/+GS3yAB7IQozE3tqXaVv2zOjgla7MEGSRv95+ILmOuvhLkOK6wJtCQ==
dependencies:
dom-walk "^0.1.0"

min-indent@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/min-indent/-/min-indent-1.0.1.tgz#a63f681673b30571fbe8bc25686ae746eefa9869"
Expand Down Expand Up @@ -9298,20 +9310,6 @@ react-helmet-async@^1.3.0:
react-fast-compare "^3.2.0"
shallowequal "^1.1.0"

react-hot-loader@^4.13.1:
version "4.13.1"
resolved "https://registry.yarnpkg.com/react-hot-loader/-/react-hot-loader-4.13.1.tgz#979fd7598e27338b3faffae6ed01c65374dace5e"
integrity sha512-ZlqCfVRqDJmMXTulUGic4lN7Ic1SXgHAFw7y/Jb7t25GBgTR0fYAJ8uY4mrpxjRyWGWmqw77qJQGnYbzCvBU7g==
dependencies:
fast-levenshtein "^2.0.6"
global "^4.3.0"
hoist-non-react-statics "^3.3.0"
loader-utils "^2.0.3"
prop-types "^15.6.1"
react-lifecycles-compat "^3.0.4"
shallowequal "^1.1.0"
source-map "^0.7.3"

react-image-crop@^10.0.4:
version "10.0.8"
resolved "https://registry.yarnpkg.com/react-image-crop/-/react-image-crop-10.0.8.tgz#a57400606cdf73ee3436a78fddc82ba6b71801ca"
Expand Down Expand Up @@ -9412,6 +9410,11 @@ react-redux@^8.0.5:
react-is "^18.0.0"
use-sync-external-store "^1.0.0"

react-refresh@^0.14.0:
version "0.14.0"
resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.14.0.tgz#4e02825378a5f227079554d4284889354e5f553e"
integrity sha512-wViHqhAd8OHeLS/IRMJjTSDHF3U9eWi62F/MledQGPdJGDhodXJ9PBLNGr6WWL7qlH12Mt3TyTpbS+hGXMjCzQ==

react-resize-detector@^8.0.4:
version "8.0.4"
resolved "https://registry.yarnpkg.com/react-resize-detector/-/react-resize-detector-8.0.4.tgz#385a68287282ec7835758570f8e74980aa9d234d"
Expand Down Expand Up @@ -10375,6 +10378,11 @@ stack-utils@^2.0.3:
dependencies:
escape-string-regexp "^2.0.0"

stackframe@^1.3.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-1.3.4.tgz#b881a004c8c149a5e8efef37d51b16e412943310"
integrity sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==

statuses@2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63"
Expand Down

0 comments on commit bf68417

Please sign in to comment.