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
remote.require local typescript module #133
Comments
try just |
Webpack won't copy over files unless they are imported. Therefore, this file won't be included in the final build. |
Thanks for the quick answer. // ./src/electron-app/remote.ts
import { remote } from "electron";
import MyModule from "./myModule";
export const myMod: MyModule = remote.require("./myModule");
// Uncaught Error: Can not find module './myModule' The error persists. // in the vue app file
import MyModule from "./myModule";
import { myMod } from '@/electron-app/remote' Maybe |
I've just created a repository to show the problem. |
You can use fs directly in the render process btw. |
Yes I can, bu my purpose was to create some custom logic on the main process to be reused in the renderer process. I think this is not possible with webpack right now unless you change the configuration by adding an entry for each custom module (losing the live reloads feature). Currently the only solution is to implement my logic using ipc. |
I think IPC channels are your best option over having multiple entries. Should this issue be closed now? |
I think so too, you can close this issue |
I've googled until I'm blue... This is the closest I've gotten to my issue, but I'm not sure if I understand the gist of this. If I need to use the remote-feature of electron inside a And I can't force webpack to include it without losing the HRL? If so, it seems this package is preventing use of an essential electron functionality. And since it seems like electron is getting more adamant about the separation of main and renderer this is getting more essential, right? |
If you need to |
I'm not sure I understand. I'm thinking you don't mean to put the "required" module there, but a .js which includes only the required line with "require('')", right? Like
I can't get this to work, it still doesn't allow my renderer to resolve Is there a path issue here? In the public folder the path to main is |
This describes how paths for electron remote works. |
@thoni56 are you trying to require your |
@nklayman Well that depends. I know you can't directly js-require them, but according to this, which is as "recommended by electron" as you can get:
(I only needed a single function there, which of course could have been factored out of But anyways, since the problem seems to be that webpack doesn't package Thanks for you help! |
Glad that you figured it out! |
@thoni56 How exactly did you reference the js in public folder from the vue app? I spent a lot of time on this and still couldn't figure it out. |
See the docs on static assets. Use |
Describe the bug
I do not know if it's a bug related to vue-electron-builder. I need to make some stuff available from the main process to the renderer process so I'm using the remote.require electron api like below:
Everything works fine but if I try to import a module created by me in the same directory I get the error
Uncaught Error: Can not find module './myModule'
Note: for my project I had to change the directory of the
mainProcessFile
in ./src/electron-app/main.tsTo Reproduce
Se the description above or run this repository:
https://github.com/toriphes/vue-electron-builder-remote-issue
Expected behavior
I expect to be able to import local modules with remote electron exactly as in this example (already existing electron app):
https://github.com/sqlectron/sqlectron-gui/blob/master/src/browser/remote.js
Environment:
The text was updated successfully, but these errors were encountered: