Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
angular2-async-route-loader
Advanced tools
This is a webpack loader to Angular2 lazy module loading.
It's recommended to use this loader with webpack 2.x.
export const appRoutes: Routes = [
{path: "", component: MainHomeComponent},
{path: "about", component: MainAboutComponent },
{path: "sub", loadChildren: "./sub.module#SubModule" },
];
export const appRoutes: Routes = [
{path: "", component: MainHomeComponent},
{path: "about", component: MainAboutComponent },
{path: "sub", loadChildren: () => require("./sub.module")("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: () => require("./sub.module.ngfactory")("SubModuleNgFactory") },
];
npm install angular2-load-children-loader -D
npm install @types/node -D
or
typings install node
export const appRoutes: Routes = [
{path: "", component: MainHomeComponent},
{path: "about", component: MainAboutComponent },
{path: "sub", loadChildren: "es6-promise!./sub.module#SubModule"}
];
The following repository uses this loader:
To load sub modules asynchronously with webpack, you use only es6-promise-loader. For example:
import { Routes, RouterModule } from "@angular/router";
import { MainHomeComponent } from "./main-home.component";
import { MainAboutComponent } from "./main-about.component";
export function loadSubModule(): any {
return require("es6-promise!../sub/sub.module")("SubModule");
}
export const appRoutes: Routes = [
{path: "", component: MainHomeComponent},
{path: "about", component: MainAboutComponent },
{path: "sub", loadChildren: loadSubModule},
];
OK, it works pretty well. But wait. It doesn't work in Angular2 AoT(offline compile) mode.
In AoT context the loadSubModule
function should return not SubModule
but SubModuleNgFactory
(generated by the ngc
command).
In other words, to keep routing configurations to work in the both JiT and AoT context, you should switch the sub module to load as this loader does.
MIT
FAQs
angular2 async route loader
The npm package angular2-async-route-loader receives a total of 0 weekly downloads. As such, angular2-async-route-loader popularity was classified as not popular.
We found that angular2-async-route-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.