Tell Aurelia which route need which plugin?

Is there a way to tell Aurelia which route need which plugin ? This is for optimisation (chunk) purposes.

Currently I load all required plugins for an application in the main.ts, which means they all get loaded on first app display, whichever route is requested. However I have plugins that are only required on some routes and could save lots of kb by not loading them immediately.

I know we can tell Aurelia to load module in different chunk depending on route by doing

// route config
PLATFORM.moduleName(moduleName, 'chunk-name');

But can we then also tell Aurelia which plugins are required on which route ?

1 Like

Seems that this is the best answer so far:

I find that it works pretty well by loading the plugin in the canActivate() lifecycle hook of a module. The downside of this approach is that you need to do the work for each module that need special plugin loading. Would be great to be able to provide some config in the route of configureRouter() but didn’t find a way to do so.

1 Like