Bundle plugin with webpack

is it possible to bundle an aurelia plugin with webpack to dynamically include it in an aurelia app using webpack?

1 Like

Start from this comment on github issue

If you want to load arbitrary plugins that are unknown at build-time… that’s your worst case. Webpack is actually not a loader and you’ll have to come up with your own solution to load unknown files at runtime. Webpack is only a bundler and can only handle stuff that is known a build time.

@jbockle please elaborate what you mean by “dynamically include”

If you want to load a random plugin at runtime then no, webpack cannot do that and you’ll have to go to JSPM. Although, I speculated about this awhile ago. You can probably create a bundle which will consist of a root file that you reference in index.html and a chunk file loaded dynamically on demand.

If your goal is to minimise traffic and only load what is used then yes, webpack can create chunks. By calling PLATFORM.moduleName with a second parameter you can move views and resources to a dynamically loaded chunk.

1 Like