I just tried to build a new project with Electron and webpack (along with React and babel).
But I lost a couple of hours to figure out an error, thinking that I did something wrong. But it turns out that webpack didn’t follow the principle of least surprise. For some reason, webpack believes, that if you use the same variable name as node, you should be using node and mangled them, silently, no log, no warning, just deal with it!
The problem is not hard to fix. You just add to your plugin section in your config, an ignorePlugin for electron, or any other plugin you didn’t configure but is applied anyway.
plugins: [ new webpack.IgnorePlugin(new RegExp("^(electron)$")), ]