George Kalpakas 177eab2260 ci: add integration test for Angular Elemens with SSR (#40559)
This commit adds an integration test that uses `@angular/elements` with
`@angular/platform-server` in order to highlight a current
incompatibility. The issue will be fixed in a subsequent commit.

PR Close #40559
2021-02-12 08:55:25 -08:00

33 lines
937 B
TypeScript

import { isPlatformBrowser } from '@angular/common';
import { CUSTOM_ELEMENTS_SCHEMA, Inject, Injector, NgModule, PLATFORM_ID } from '@angular/core';
import { createCustomElement } from '@angular/elements';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { TitleComponent } from './title.component';
@NgModule({
bootstrap: [
AppComponent,
],
declarations: [
AppComponent,
TitleComponent,
],
imports: [
BrowserModule.withServerTransition({ appId: 'serverApp' }),
RouterModule.forRoot([]),
],
schemas: [
CUSTOM_ELEMENTS_SCHEMA,
],
})
export class AppModule {
constructor(injector: Injector, @Inject(PLATFORM_ID) platformId: object) {
if (isPlatformBrowser(platformId)) {
customElements.define('app-title-ce', createCustomElement(TitleComponent, {injector}));
}
}
}