Closed krystianotto closed 5 months ago
Since you installed the module through the github address, the module is not recognized by the externalizeDep
plugin. You can externalize test-module
by specifying it via the include
option of the externalizeDeps
plugin.
https://electron-vite.org/guide/dev#dependencies-vs-devdependencies
@alex8088 it still shows module not found
after I pack the application using electron-builder. Any idea why that is?
How did you configure it?
Your electron-vite config
export default defineConfig(() => {
return {
main: {
plugins: [
externalizeDepsPlugin({ include: ['test-module'] }),
],
...
},
...
});
@alex8088 Yes - I have already done it, but after npm package
when I run the application I still get the error from the last screenshot attached in the description :/ I wonder if that's an issue with Vite or electron-builder.
You should move your electron-builder config file to project root dir.
It is recommended that you use npm create @quick-start/electron@latest
to create the project.
@alex8088 I already tried with the electron-builder configuration in the root directory. That didn't help. Also, creating a new project is out of the question, as this repo is just an example of a problem I encountered in an existing one.
I was able to make it work by adding this code to electron-builder:
files: ["node_modules/test-module/**/*"]
To be fair I'm not too fond of this approach and don't get why it is necessary to move this dependency manually with electron-builder
Describe the bug
I have a few issues moving from webpack to vite. First, one of my dependencies has a dynamic import defined like this:
I then import it as follows:
When I run
electron-vite build
I get an error:Since I'm able to maintain this dependency I can actually change it to:
It works, but only because I can change the code, which is not pleasant. Unfortunately, there is now another error regarding dynamic import.
I was able to fix this by moving this dependency to the root package.json, but again this is not desirable. After fixing these two dependencies manually, another problem appeared after packaging the application with electron-builder:
Here is repo to reproduce the issues.
Electron-Vite Version
2.2.0
Electron Version
25.9.8
Vite Version
5.12.2
Validations