Skip to content
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

vite + zeromq + electron === fail (MAIN PROCESS! NOT RENDERER!) #265

Open
devzzzero opened this issue Jan 3, 2025 · 0 comments
Open

vite + zeromq + electron === fail (MAIN PROCESS! NOT RENDERER!) #265

devzzzero opened this issue Jan 3, 2025 · 0 comments

Comments

@devzzzero
Copy link

Please see vitejs/vite#19128

The minimal repo is in https://github.com/devzzzero/vite-zeromq-bug

Basically, I'm trying to get an electron+zeromq+p?react+vite working.
I switched over to vite after running into a blocker with webpack..

Strangely enough, now vite is dying exactly the same way.

I.e. adding zeromq as an external dependecy gets the app to load (this is also required in webpack for the app to run), but the built app (i.e. the result of npm run build) dies with this:

\D5280:x86_64-Linux5:~/gui/vite-bug/ZMQTest>./release/0.0.0/YourAppName-Linux-0.0.0.AppImage 
A JavaScript error occurred in the main process
Uncaught Exception:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'zeromq' imported from /tmp/.mount_YourApYAxnh0/resources/app.asar/dist-electron/main.js
    at packageResolve (node:internal/modules/esm/resolve:861:9)
    at moduleResolve (node:internal/modules/esm/resolve:934:18)
    at defaultResolve (node:internal/modules/esm/resolve:1176:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:227:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:87:39)
    at link (node:internal/modules/esm/module_job:86:36)
D5280:x86_64-Linux5:~/gui/vite-bug/ZMQTest>
D5280:x86_64-Linux5:~/gui/vite-bug/ZMQTest>gdif
diff --git a/ZMQTest/vite.config.ts b/ZMQTest/vite.config.ts
index ece5fc3..4f6d60e 100644
--- a/ZMQTest/vite.config.ts
+++ b/ZMQTest/vite.config.ts
@@ -11,6 +11,14 @@ export default defineConfig({
       main: {
         // Shortcut of `build.lib.entry`.
         entry: 'electron/main.ts',
+        vite: {
+          build: {
+            rollupOptions: {
+              external: ['zeromq',
+                'electron-settings']  // 👈👈
+            },
+          },
+        },
       },
       preload: {
         // Shortcut of `build.rollupOptions.input`.
D5280:x86_64-Linux5:~/gui/vite-bug/ZMQTest>

This is a blocker that I don't yet know how to solve. Can a kind soul please help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant