
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy 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 51,287 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
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.