Skip to content

Commit 117fbb4

Browse files
wardpeetsidharthachatterjee
authored andcommitted
fix(gatsby): fix hot-reloading for hooks (patch hmr) (#13713)
1 parent d67f9f0 commit 117fbb4

File tree

5 files changed

+40
-12
lines changed

5 files changed

+40
-12
lines changed

e2e-tests/development-runtime/gatsby-config.js

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// isomorphic-fetch sets global.fetch which seems to conflicts with source-map@<0.8.0 where it does a
2+
// simple browser check if (global.fetch) which is true when isomorphic-fetch is used. This creates an
3+
// exception in react-hot-loader. @see https://github.com/gatsbyjs/gatsby/pull/13713
4+
require(`isomorphic-fetch`)
5+
16
module.exports = {
27
siteMetadata: {
38
title: `Gatsby Default Starter`,

packages/gatsby/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"raw-loader": "^0.5.1",
109109
"react-dev-utils": "^4.2.1",
110110
"react-error-overlay": "^3.0.0",
111-
"react-hot-loader": "^4.6.2",
111+
"react-hot-loader": "^4.8.4",
112112
"redux": "^4.0.0",
113113
"redux-thunk": "^2.3.0",
114114
"semver": "^5.6.0",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const originalFetch = global.fetch
2+
delete global.fetch
3+
4+
module.exports = require(`react-hot-loader/webpack`)
5+
6+
global.fetch = originalFetch

packages/gatsby/src/utils/webpack.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,16 @@ module.exports = async (program, directory, suppliedStage) => {
284284
},
285285
])
286286

287+
// RHL will patch React, replace React-DOM by React-🔥-DOM and work with fiber directly
288+
// It's necessary to remove the warning in console (https://github.com/gatsbyjs/gatsby/issues/11934)
289+
configRules.push({
290+
include: /node_modules/,
291+
test: /\.jsx?$/,
292+
use: {
293+
loader: require.resolve(`./webpack-hmr-hooks-patch`),
294+
},
295+
})
296+
287297
break
288298
}
289299
case `build-html`:

yarn.lock

+18-11
Original file line numberDiff line numberDiff line change
@@ -10861,10 +10861,12 @@ [email protected]:
1086110861
resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.1.tgz#9634502aa12c445dd5a7c5734b572bb8738aacbb"
1086210862
integrity sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==
1086310863

10864-
hoist-non-react-statics@^2.5.0:
10865-
version "2.5.5"
10866-
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz#c5903cf409c0dfd908f388e619d86b9c1174cb47"
10867-
integrity sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw==
10864+
hoist-non-react-statics@^3.3.0:
10865+
version "3.3.0"
10866+
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.0.tgz#b09178f0122184fb95acf525daaecb4d8f45958b"
10867+
integrity sha512-0XsbTXxgiaCDYDIWFcwkmerZPSwywfUqYmwT4jzewKTQSWoE6FCMoUVOeBJWK3E/CrWbxRG3m5GzY4lnIwGRBA==
10868+
dependencies:
10869+
react-is "^16.7.0"
1086810870

1086910871
home-or-tmp@^2.0.0:
1087010872
version "2.0.0"
@@ -13915,7 +13917,7 @@ lodash.memoize@^4.1.2:
1391513917
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
1391613918
integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=
1391713919

13918-
lodash.merge@^4.6.0, lodash.merge@^4.6.1:
13920+
lodash.merge@^4.6.0:
1391913921
version "4.6.1"
1392013922
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.1.tgz#adc25d9cb99b9391c59624f379fbba60d7111d54"
1392113923
integrity sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ==
@@ -17428,21 +17430,26 @@ react-error-overlay@^3.0.0:
1742817430
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-3.0.0.tgz#c2bc8f4d91f1375b3dad6d75265d51cd5eeaf655"
1742917431
integrity sha512-XzgvowFrwDo6TWcpJ/WTiarb9UI6lhA4PMzS7n1joK3sHfBBBOQHUc0U4u57D6DWO9vHv6lVSWx2Q/Ymfyv4hw==
1743017432

17431-
react-hot-loader@^4.6.2:
17432-
version "4.6.2"
17433-
resolved "https://registry.yarnpkg.com/react-hot-loader/-/react-hot-loader-4.6.2.tgz#9844b76a7bf4b6fdd45dd91f7e757ddf3aad5289"
17434-
integrity sha512-9XxH/t9jblu4vUDgxHcMLwvm4aOhaoxazzTP9vwjTVzOgU987T4rDYA85XrlmbDan9WkD+h/iVHOK8F8UnQsDg==
17433+
react-hot-loader@^4.8.4:
17434+
version "4.8.4"
17435+
resolved "https://registry.yarnpkg.com/react-hot-loader/-/react-hot-loader-4.8.4.tgz#357ba342e367fd42d6a870a9c0601c23fa0730c6"
17436+
integrity sha512-O98btZXcm24ZgP+aPBD0W9N+GEnkOg6vlLEy/IMZ53u3K/dGqO0I/RU4qrmQzE+wMDLpwNo5TwxaAjVw9Y+IBA==
1743517437
dependencies:
1743617438
fast-levenshtein "^2.0.6"
1743717439
global "^4.3.0"
17438-
hoist-non-react-statics "^2.5.0"
17440+
hoist-non-react-statics "^3.3.0"
1743917441
loader-utils "^1.1.0"
17440-
lodash.merge "^4.6.1"
17442+
lodash "^4.17.11"
1744117443
prop-types "^15.6.1"
1744217444
react-lifecycles-compat "^3.0.4"
1744317445
shallowequal "^1.0.2"
1744417446
source-map "^0.7.3"
1744517447

17448+
react-is@^16.7.0:
17449+
version "16.8.6"
17450+
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.6.tgz#5bbc1e2d29141c9fbdfed456343fe2bc430a6a16"
17451+
integrity sha512-aUk3bHfZ2bRSVFFbbeVS4i+lNPZr3/WM5jT2J5omUVV1zzcs1nAaf3l51ctA5FFvCRbhrH0bdAsRRQddFJZPtA==
17452+
1744617453
react-lifecycles-compat@^3.0.4:
1744717454
version "3.0.4"
1744817455
resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"

0 commit comments

Comments
 (0)