Skip to content

Commit

Permalink
react-hot-loader: Disable safetyNet to work with ESM
Browse files Browse the repository at this point in the history
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]: gaearon/react-hot-loader#1102 (comment)
  • Loading branch information
victorlin committed Nov 22, 2022
1 parent 712f2fa commit e4fec8e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}]);
Expand Down

0 comments on commit e4fec8e

Please sign in to comment.