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.
single-spa-angular
Advanced tools
Helpers for building single-spa applications which use Angular. Note that this project works with Angular 2, 3, 4, 5+, despite its name.
This project is great for people who use Angular without angular-cli. But if that's not you, try out single-spa-angular-cli.
An example can be found in the single-spa-examples repository.
First, in the single-spa application, run npm install --save single-spa-angular
. Then, create an entry file for application:
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import singleSpaAngular from 'single-spa-angular';
import mainModule from './main-module.ts';
import {Router} from '@angular/router';
const ngLifecycles = singleSpaAngular({
domElementGetter,
mainModule,
angularPlatform: platformBrowserDynamic(),
template: `<component-to-render />`,
Router,
})
export const bootstrap = [
ngLifecycles.bootstrap,
];
export const mount = [
ngLifecycles.mount,
];
export const unmount = [
ngLifecycles.unmount,
];
function domElementGetter() {
return document.getElementById('angular');
}
All options are passed to single-spa-angular via the opts
parameter when calling singleSpaAngular(opts)
. The following options are available:
mainModule
: (required) An Angular module class. If you're using Typescript or ES6 decorators, this is a class with the @NgModule decorator on it.angularPlatform
: (required) The platform with which to bootstrap your module. The "Angular platform" refers to whether the code is running on the browser, mobile, server, etc. In the case of a single-spa application, you should use the platformBrowserDynamic
platform.template
: (required) An html string that will be put into the DOM Element returned by domElementGetter
. This template can be anything, but it is recommended that you keeping it simple by making it only one Angular component. For example, <my-component />
is recommended, but <div><my-component /><span>Hello</span><another-component /></div>
is allowed. Note that innerHTML
is used to put the template onto the DOM.Router
: (optional) The angular router class. If not provided, single-spa-angular will assume you are not using @angular/router.domElementGetter
: (optional) A function that takes in no arguments and returns a DOMElement. This dom element is where the Angular application will be bootstrapped, mounted, and unmounted.
Note that this opt can only be omitted when domElementGetter is passed in as a custom prop. So you must either
do singleSpaReact({..., domElementGetter: function() {return ...}})
or do singleSpa.registerApplication(name, app, activityFn, {domElementGetter: function() {...}})
reflect-metadata
is only imported once in the root application and is not imported again in the child applications. Otherwise, you might see an No NgModule metadata found
error. See issue thread for more details.FAQs
Helpers for building single-spa applications which use Angular 2
The npm package single-spa-angular receives a total of 42,852 weekly downloads. As such, single-spa-angular popularity was classified as popular.
We found that single-spa-angular demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.