capacitor-community / electron

Deploy your Capacitor apps to Linux, Mac, and Windows desktops, with the Electron platform! 🖥️
https://capacitor-community.github.io/electron/
MIT License
335 stars 59 forks source link

Custom made plugins does not seem to survive packaging #155

Closed filpet95 closed 2 years ago

filpet95 commented 2 years ago

Describe the bug The automatically generated paths for detected electron plugins are an absolute path to the developers machine. Hence, when packaging the app and installing it on another computer the application will fail, saying not finding the module.

To Reproduce Steps to reproduce the behavior:

  1. Create and build a plugin using the plugin example
  2. Import the plugin into an application
  3. The plugin is detected and added to the file ' src/rt/electron-plugins.js' with an absolute path (Users/xxx/Project/..../electron/node_modules/my-custom-plugin/electron/dist/plugin.js for mac and C:\Users\xxx\Project\...\electron\node_modules\my-custom-plugin\electron\dist\plugin.js for windows)
  4. The application works on local PC as the absolute path is OK.
  5. When packaging the application and running on another PC it yields the following error: Error: Cannot find module 'C:/Users/xxx/Project/.../electron/node_modules/my-custom-plugin/electron/dist/plugin.js' Require stack:
    • C:/Users/OtherUser/AppData/Local/Programs/Project/resources/app.asar/build/src/rt/electron-plugins.js
    • C:/Users/OtherUser/AppData/Local/Programs/Project/resources/app.asar/node_modules/@capacitor-community/electron/dist/core/index.js
    • C:/Users/OtherUser/AppData/Local/Programs/Project/resources/app.asar/build/src/index.js
    • at Function.n._resolveFilename (electron/js2c/browser_init.js:257:1128) at Function.f._load (electron/js2c/asar_bundle.js:5:12913) at Object. (- C:/Users/OtherUser/AppData/Local/Programs/Project/resources/app.asar/build/src/rt/electron-plugins.js:2:34)

Expected behavior A relative path to properly detect the plugin. For windows '.\..\..\..\node_modules\my-custom-plugin\electron\dist\plugin.js' worked. Does not seem to work on mac.

Desktop (please complete the following information):

Additional context electron-builder was used to package the application.

jdgjsag67251 commented 2 years ago

This should have been fixed in #151

IT-MikeS commented 2 years ago

This hasn't been released yet to npm, however expect more development of the platform soon.

I had a bit of a hiatus but will be looking to do more shortly again 👍