I have the following renderer:
import SerialPort from \"serialport\";
new SerialPort(\"/dev/tty-usbserial1\", { baudRate: 57600 });
It\'s buil
I wanna thank @Alec Mev for practically the only answer on the entire internet that truly works and has real knowledge inside. I've spent days troubleshooting issues with webpack and native modules for electron until I tried Alec's answer and it perfectly works.
Just a small addition, that if the native code is being used within the main process and not the renderer (most common case when app security is stronger), the shim needs to be adjusted as following:
module.exports = x =>
__non_webpack_require__(
`${require('electron').app.getAppPath()}/${x}`
);