diff --git a/e2e-tests/development-runtime/gatsby-config.js b/e2e-tests/development-runtime/gatsby-config.js index bdc16cdbf1f65..6fefd4aaed7ff 100644 --- a/e2e-tests/development-runtime/gatsby-config.js +++ b/e2e-tests/development-runtime/gatsby-config.js @@ -1,3 +1,8 @@ +// isomorphic-fetch sets global.fetch which seems to conflicts with source-map@<0.8.0 where it does a +// simple browser check if (global.fetch) which is true when isomorphic-fetch is used. This creates an +// exception in react-hot-loader. @see https://github.com/gatsbyjs/gatsby/pull/13713 +require(`isomorphic-fetch`) + module.exports = { siteMetadata: { title: `Gatsby Default Starter`, diff --git a/packages/gatsby/package.json b/packages/gatsby/package.json index 389684bb81674..e96acadf0ddc8 100644 --- a/packages/gatsby/package.json +++ b/packages/gatsby/package.json @@ -107,7 +107,7 @@ "raw-loader": "^0.5.1", "react-dev-utils": "^4.2.1", "react-error-overlay": "^3.0.0", - "react-hot-loader": "^4.6.2", + "react-hot-loader": "^4.8.4", "redux": "^4.0.0", "semver": "^5.6.0", "shallow-compare": "^1.2.2", diff --git a/packages/gatsby/src/utils/webpack-hmr-hooks-patch.js b/packages/gatsby/src/utils/webpack-hmr-hooks-patch.js new file mode 100644 index 0000000000000..169718284d486 --- /dev/null +++ b/packages/gatsby/src/utils/webpack-hmr-hooks-patch.js @@ -0,0 +1,6 @@ +const originalFetch = global.fetch +delete global.fetch + +module.exports = require(`react-hot-loader/webpack`) + +global.fetch = originalFetch diff --git a/packages/gatsby/src/utils/webpack.config.js b/packages/gatsby/src/utils/webpack.config.js index d49f0a9e6b413..1973c505049cf 100644 --- a/packages/gatsby/src/utils/webpack.config.js +++ b/packages/gatsby/src/utils/webpack.config.js @@ -273,6 +273,16 @@ module.exports = async (program, directory, suppliedStage) => { }, ]) + // RHL will patch React, replace React-DOM by React-🔥-DOM and work with fiber directly + // It's necessary to remove the warning in console (https://github.com/gatsbyjs/gatsby/issues/11934) + configRules.push({ + include: /node_modules/, + test: /\.jsx?$/, + use: { + loader: require.resolve(`./webpack-hmr-hooks-patch`), + }, + }) + break } case `build-html`: diff --git a/yarn.lock b/yarn.lock index 6d7651e6a5bf4..5d93bd4290078 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10865,10 +10865,12 @@ hoek@4.x.x: resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.1.tgz#9634502aa12c445dd5a7c5734b572bb8738aacbb" integrity sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA== -hoist-non-react-statics@^2.5.0: - version "2.5.5" - resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz#c5903cf409c0dfd908f388e619d86b9c1174cb47" - integrity sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw== +hoist-non-react-statics@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.0.tgz#b09178f0122184fb95acf525daaecb4d8f45958b" + integrity sha512-0XsbTXxgiaCDYDIWFcwkmerZPSwywfUqYmwT4jzewKTQSWoE6FCMoUVOeBJWK3E/CrWbxRG3m5GzY4lnIwGRBA== + dependencies: + react-is "^16.7.0" home-or-tmp@^2.0.0: version "2.0.0" @@ -13919,7 +13921,7 @@ lodash.memoize@^4.1.2: resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= -lodash.merge@^4.6.0, lodash.merge@^4.6.1: +lodash.merge@^4.6.0: version "4.6.1" resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.1.tgz#adc25d9cb99b9391c59624f379fbba60d7111d54" integrity sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ== @@ -17437,21 +17439,26 @@ react-error-overlay@^3.0.0: resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-3.0.0.tgz#c2bc8f4d91f1375b3dad6d75265d51cd5eeaf655" integrity sha512-XzgvowFrwDo6TWcpJ/WTiarb9UI6lhA4PMzS7n1joK3sHfBBBOQHUc0U4u57D6DWO9vHv6lVSWx2Q/Ymfyv4hw== -react-hot-loader@^4.6.2: - version "4.6.2" - resolved "https://registry.yarnpkg.com/react-hot-loader/-/react-hot-loader-4.6.2.tgz#9844b76a7bf4b6fdd45dd91f7e757ddf3aad5289" - integrity sha512-9XxH/t9jblu4vUDgxHcMLwvm4aOhaoxazzTP9vwjTVzOgU987T4rDYA85XrlmbDan9WkD+h/iVHOK8F8UnQsDg== +react-hot-loader@^4.8.4: + version "4.8.4" + resolved "https://registry.yarnpkg.com/react-hot-loader/-/react-hot-loader-4.8.4.tgz#357ba342e367fd42d6a870a9c0601c23fa0730c6" + integrity sha512-O98btZXcm24ZgP+aPBD0W9N+GEnkOg6vlLEy/IMZ53u3K/dGqO0I/RU4qrmQzE+wMDLpwNo5TwxaAjVw9Y+IBA== dependencies: fast-levenshtein "^2.0.6" global "^4.3.0" - hoist-non-react-statics "^2.5.0" + hoist-non-react-statics "^3.3.0" loader-utils "^1.1.0" - lodash.merge "^4.6.1" + lodash "^4.17.11" prop-types "^15.6.1" react-lifecycles-compat "^3.0.4" shallowequal "^1.0.2" source-map "^0.7.3" +react-is@^16.7.0: + version "16.8.6" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.6.tgz#5bbc1e2d29141c9fbdfed456343fe2bc430a6a16" + integrity sha512-aUk3bHfZ2bRSVFFbbeVS4i+lNPZr3/WM5jT2J5omUVV1zzcs1nAaf3l51ctA5FFvCRbhrH0bdAsRRQddFJZPtA== + react-lifecycles-compat@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"