i’m in the process of making an electron app that will support a plugin system that will not cause any changes in the app it will only load components which are the plugins i want to load.
and im having a problem with how to load these plugins, i have them in
const absolutePath = `${app.getPath('userData')}/Plugins/PluginName/Main.tsx`
and my problem is with how do apps that can load such plugin do that when import()
or require()
can’t seem to find the modules when i pass them that absolutePath
but when i do this
const module = await import(`c:/Users/User/AppData/Roaming/electronApp/Plugins/Plugin1/Main.tsx`)
// or
const module = await require(`c:/Users/User/AppData/Roaming/electronApp/Plugins/Plugin1/Main.tsx`)
it works fine …
and i have also read many cases like mine, except they all used local to the app paths `./ . i checked this [article](https://beyondco.de/blog/plugin-system-for-electron-apps-part-1) which uses _
non_webpack_require
_
to get the module but when i use it .. it causes and error saying require is not defined, which kinda made confused since i thought it will use require() which is a node js but my webstorm ide says that the require i used before is from __WebpackModuleApi. RequireFunction.(path: string): any
.
..
would like to know if that’s really how plugin systems are managed or is it a problem in my project
ryusuke is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.