angular2-webpack2-lazy-children-loader

A webpack loader for ng2 lazy loading

Usage no npm install needed!

<script type="module">
  import angular2Webpack2LazyChildrenLoader from 'https://cdn.skypack.dev/angular2-webpack2-lazy-children-loader';
</script>

README

Angular2 load-children loader

This is a webpack loader to Angular2 lazy module loading.

It's recommended to use this loader with webpack 2.x.

  • INPUT:
export const appRoutes: Routes = [
  {path: "", component: MainHomeComponent},
  {path: "about", component: MainAboutComponent },
  {path: "sub", loadChildren: "./sub.module#SubModule" },
];
  • OUTPUT:
export const appRoutes: Routes = [
  {path: "", component: MainHomeComponent},
  {path: "about", component: MainAboutComponent },
  {path: "sub", loadChildren: () => System.import("./sub.module").then(m => m["SubModule"]) },
];

And this loader return a function to call the require function with .ngfactory suffix if the resource is generated by compiler-cli:

export const appRoutes: Routes = [
  {path: "", component: MainHomeComponent},
  {path: "about", component: MainAboutComponent },
  {path: "sub", loadChildren: () => System.import("./sub.module.ngfactory").then(m => m["SubModuleNgFactory"]) },
];

Install

npm install angular2-webpack2-lazy-children-loader -D
npm install @types/node -D

or

typings install node

Notice

Fork of angular2-load-children-loader

License

MIT