3

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?

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.