From 5592aecf478f999335bf26987bf08a8d7a7525cd Mon Sep 17 00:00:00 2001 From: Victor Lin <13424970+victorlin@users.noreply.github.com> Date: Tue, 4 Oct 2022 15:06:21 -0700 Subject: [PATCH] react-hot-loader: Disable safetyNet to work with ESM After upgrading webpack and plugins/loaders, there was an error from react-hot-loader: ReferenceError: module is not defined A known workaround is to enable safetyNet [1] so the code referencing `module` is not executed. I'm not sure why this was not shown before the webpack upgrades, but don't feel like digging deeper to find out. [1]: https://github.com/gaearon/react-hot-loader/issues/1102#issuecomment-459570955 --- babel.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/babel.config.js b/babel.config.js index 14c912fd3..806a54f03 100644 --- a/babel.config.js +++ b/babel.config.js @@ -27,7 +27,7 @@ module.exports = function babelConfig(api) { "lodash" ]; if (api.env("development")) { - plugins.push("react-hot-loader/babel"); + plugins.push(["react-hot-loader/babel", { safetyNet: false }]); } if (process.env.BABEL_INCLUDE_TIMING_FUNCTIONS === "false") { plugins.push(["strip-function-call", {strip: ["timerStart", "timerEnd"]}]);