Choose one: is this a 馃悰 bug report or 馃檵 feature request?
馃悰
any
HMR in electron's BrowserWindow
No HMR
I found the HMR init logic depends on the the module object. But the BrowserWindow in electron has its own window.module. That leads to the bug.
https://github.com/parcel-bundler/parcel/blob/b7b2991d69b960d9f2951828b8145a6d9396ee4e/src/builtins/hmr-runtime.js#L17
A temporary solution is setting nodeIntegration to false in BrowserWindow's options. But it removes some facilities in Electron. For someone indeed need node-integration, here may be a workaround: https://github.com/electron/electron/issues/5113 . However, I wish parcel could handle it.
Use parcel with Electron.
| Software         | Version(s)
| ---------------- | ----------
| Parcel           |  1.2.0
| Node             |  v8.9.3
| npm/Yarn         |  npm 5.6.0
| Operating System | mac 10.13.2
This solution from the Electron FAQ works. It also prevents the require('electron').xxx is undefined. issue:
https://electronjs.org/docs/faq#i-can-not-use-jqueryrequirejsmeteorangularjs-in-electron
Due to the Node.js integration of Electron, there are some extra symbols inserted into the DOM like module, exports, require. This causes problems for some libraries since they want to insert the symbols with the same names.
if you want to keep the abilities of using Node.js and Electron APIs, you have to rename the symbols in the page before including other libraries:
<head>
<script>
window.nodeRequire = require;
delete window.require;
delete window.exports;
delete window.module;
</script>
<script type="text/javascript" src="jquery.js"></script>
</head>
Fixed with #652.
--target=electron
Most helpful comment
This solution from the Electron FAQ works. It also prevents the require('electron').xxx is undefined. issue:
https://electronjs.org/docs/faq#i-can-not-use-jqueryrequirejsmeteorangularjs-in-electron