-
-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simple example showing problems with a native module in main entry (dev & packaged) #2949
Comments
Similar to this issue, but easier to reproduce IMHO :) ... #2788 |
Hey @petertorelli been working on this since two days in a very similar case with serialport integration and webpack. With this plugin, serialport package will be included in the build. Only got int running in main process though. But that's ok, since now i got a good reason to look into ipc context bridge. in "plugins": [
// webpack stuff
[
"@timfish/forge-externals-plugin",
{
"externals": [
"serialport"
],
"includeDeps": true
}
]
] and in externals: {
serialport: 'serialport'
} Hope this helps :) |
@A13k2, E.g., try putting This results in Second, this plugin also does not work if there is another entry point that uses Thanks, |
This is an issue with the webpack asset relocator we use. Specifically the fix in cases like this is to either fix the module, or the asset relocator, or both. In this case it required changes in both:
If both those PRs land and get shipped, the |
I moved to 6.0.4 to test again but that isn't packaging correctly, so not sure which ticket I should work on. :O .... see #3120. |
Any updates on this? I have the same issue with node-hid package. It used to work before I upgraded to 6.0.4. I have also tested with @timfish/forge-externals-plugin and it didn't work. So far I have only experienced this on windows, mac seems to work just fine. EditJust tested with
This might be a workaround for someone until this is fixed. |
I am facing this issue uiohook-napi |
Pre-flight checklist
Electron Forge version
6.0.0-beta.67
Electron version
21.1.0
Operating system
MacOS 12.6
Last known working Electron Forge version
first time using
Expected behavior
I expect serialport to work seamlessly in dev and package mode, according to the documentation that claims it should work "out of the box" as described in this doc link:
https://www.electronforge.io/config/plugins/webpack#native-modules
Actual behavior
In dev mode, we get a popup with the classic
Uncaught exception: Error: no native build was found...
error. This can easily be fixed by addingexternals: 'serialport'
to thewebpack.main.config.js
file. But then...When we try to package, it succeeds in building. However, after launching the app we get the other error:
Uncaught exception: Error: Cannot find module 'serialport'...
because it hasn't been copied to the package area.There are some StackExchange code snippets to set up
hooks
that scan the config file and copy modules, but those did work. They also do not work with other entrypoints that are forked withchild_process
which need to useserialport
too.But I'm only filing this issue because 'out-of-the-box' is not described in the docs as far as I can tell (I hope I didn't miss a key footnote).
Steps to reproduce
serialport@10.4.0
.src/main.js
and add these lines to the very bottom:webpack.main.config.js
:Additional information
I tried this hack but it didn't work:
https://stackoverflow.com/questions/71930401/webpack-not-including-module-with-electron-forge-and-serialport
The text was updated successfully, but these errors were encountered: