I am working on an Angular library with a lot of modules and components, one of them being a plugin loading system.
The way the plugin loading system works is based on the assumption that the project which imports it (via npm) will contain a "plugins" directory with an "index.ts" file in its root and the plugin loading service will import whatever components are exported by index.ts.
I am using the dynamic module importing syntax - the async import('...') statement, which works perfectly when it's pointing to a file which physically exists there, but such a file won't exist at the time when I'm compiling/publishing my library, it exists only at a later stage, inside the project that uses it.
How can I 'trick' the Angular compiler to package the library without the existence of a ../../plugins module and instead fetch the plugins at runtime?
You can use a dynamic module loader, like System.JS.
See this question for a similar implementation:
Load new modules dynamically in run-time with Angular CLI & Angular 5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With