-
-
Notifications
You must be signed in to change notification settings - Fork 533
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
Restart (rs
) and the Webpack plugin do not work with a native module
#3052
Comments
Hey @cwellsx, would you mind trying this with v6.0.0? I think we may have addressed this issue in a later beta version than the one you’re running, just want to make sure that’s the case. |
Hi @VerteDinde thank you. |
I tested this on latest forge (inited from template, added depedency, etc.) Had to drop to Electron 19 because that module doesn't support Electron 20 or higher yet (WiseLibs/better-sqlite3#870) but other than that it works fine during both start, restart and package |
@MarshallOfSound @VerteDinde @erickzhao I confirm that I still have this problem, with the 6.0.0 release.
Also the problem doesn't occur when I import the module but when I call its BTW instead of dropping the Electron version I install the pull request: npm install WiseLibs/better-sqlite3#pull/870/head Let me know if you want more information or anything. |
The problem is this line of code:
That TypeScript statement translates to this JavaScript:
When I press
And it's undefined when I have the problem on restart. Maybe it's related to this, because that's to do with setting the IOW maybe the I can work-around the problem using their
So for example if my code looks like this then I don't get the error: export function createSqlDatabase(filename: string): SqlApi {
const options: sqlite.Options = {
nativeBinding:
"C:\\Users\\Christopher\\Source\\Repos\\pic\\.webpack\\main\\native_modules\\build\\Release\\better_sqlite3.node",
};
const db = sqlite(filename, options); That's not ideal, especially when the application is packaged (but a useful work-around to make In summary I guess this problem related to the |
Simple workaround that worked for me (same error when using @napi-rs/canvas): adding This reproduces the same path even if |
Pre-flight checklist
Electron Forge version
6.0.0-beta.67
Electron version
v20.1.1
Operating system
Windows 10 Version 21H1 Build 19043.2130
Last known working Electron Forge version
No response
Expected behavior
I have
better_sqlite3
included in my project, which is based on the Webpack+Typescript template.npm start
works fine, and so doesnpm run package
-- after either of these I can access the SQLite API.It should also work when I restart it using
rs
as mentioned here:Actual behavior
I get an error message when I type
rs
as follows:Steps to reproduce
FYI the git commit I made to include better-sqlite3 in my project is here ...
... but it was easy to do, nothing special, i.e.:
better-sqlite3
as a run-time dependencyimport sqlite from 'better-sqlite3';
Additional information
It finds
better_sqlite3.node
when it starts but not when it restarts.The error message says it's looking for
undefinedbuild/Release/better_sqlite3.node
In fact the
better_sqlite3.node
exists in the following directories:The one which it's successfully using when it starts is presumably the one in the
.webpack\main\native_modules\
directory -- and this is the path fragment that's replaced with"undefined"
during a restart.I see there are previous issues related to
rs
-- https://github.com/electron/forge/issues?q=rs -- but they're all close.The text was updated successfully, but these errors were encountered: