angular-electron
angular-electron copied to clipboard
How to import native 3rd party module correctly?
Hello,
This is more a question rather than a reported issue. I have a 3rd party module called drivelist that I want to load in the render process. The documentation states:
Please check
providers/electron.service.tsto watch how conditional import of libraries has to be done when using NodeJS / 3rd party libraries in renderer context (i.e. Angular).
I added the dependency to the root package.json files and registered it as an external in angular.webpack.json like this:
config.externals = {
drivelist: "require('drivelist')"
};
Importing the module in the main process works for me. Importing the module on the renderer side in electron.service.ts fails with the famous error:
Uncaught Error: Module did not self-register.".
The doc string says:
https://github.com/maximegris/angular-electron/blob/c26be0a3439a9e7dc53aa60df867f743c672a4d6/src/app/core/services/electron/electron.service.ts#L31-L33
TLDR
Question 1) Which steps are missing to import a native 3rd party module?
Question 2) How can I make use of the TS import mechanism import { Drive } from 'drivelist'. I can't find a way to import this conditionally.
Thanks!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.