0๐
โ
If you are using webpack already there is no reason to use System.js
as module loader.
Webpack has a built-in lazy loading modules capabilities.
All you need to do is use the import('path/to/my/lazy/module')
, which returns a Promise
which will be resolved when the module is loaded. Webpack will handle the rest of the work.
You code should look like:
export const ApplicationModuleService = {
createModule(name: string, url: string, activeWhen = '/', props = {}): RegisterApplicationConfig {
return {
name,
app: () => import('path/to/lazy/module')
activeWhen,
customProps: props,
};
},
};
For a CDN support, you can specify the publicPath
option.
For more info read this
Source:stackexchange.com