fix(platform-server): setup NoopAnimationsModule in ServerModule by default (#15131)
This is so that server side rendering does not throw an exception when it encounters animations on the server side and does not need the user to explicitly setup NoopAnimationsModule in their app server module. Fixes #15098, #14784. PR Close #15131
This commit is contained in:

committed by
Miško Hevery

parent
6e9264a79c
commit
5c5c2ae405
@ -6,11 +6,9 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ɵAnimationEngine} from '@angular/animations/browser';
|
||||
import {ApplicationRef, NgModule, NgZone, Provider, RendererFactory2} from '@angular/core';
|
||||
import {ApplicationRef, NgModule} from '@angular/core';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {NoopAnimationsModule, ɵAnimationRendererFactory} from '@angular/platform-browser/animations';
|
||||
import {ServerModule, ɵServerRendererFactory2} from '@angular/platform-server';
|
||||
import {ServerModule} from '@angular/platform-server';
|
||||
import {MdButtonModule} from '@angular2-material/button';
|
||||
// Note: don't refer to third_party_src as we want to test that
|
||||
// we can compile components from node_modules!
|
||||
@ -28,19 +26,6 @@ import {CompUsingRootModuleDirectiveAndPipe, SomeDirectiveInRootModule, SomeLibM
|
||||
import {CompWithNgContent, ProjectingComp} from './projection';
|
||||
import {CompForChildQuery, CompWithChildQuery, CompWithDirectiveChild, DirectiveForQuery} from './queries';
|
||||
|
||||
export function instantiateServerRendererFactory(
|
||||
renderer: RendererFactory2, engine: ɵAnimationEngine, zone: NgZone) {
|
||||
return new ɵAnimationRendererFactory(renderer, engine, zone);
|
||||
}
|
||||
|
||||
// TODO(matsko): create a server module for animations and use
|
||||
// that instead of these manual providers here.
|
||||
export const SERVER_ANIMATIONS_PROVIDERS: Provider[] = [{
|
||||
provide: RendererFactory2,
|
||||
useFactory: instantiateServerRendererFactory,
|
||||
deps: [ɵServerRendererFactory2, ɵAnimationEngine, NgZone]
|
||||
}];
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AnimateCmp,
|
||||
@ -67,7 +52,6 @@ export const SERVER_ANIMATIONS_PROVIDERS: Provider[] = [{
|
||||
BindingErrorComp,
|
||||
],
|
||||
imports: [
|
||||
NoopAnimationsModule,
|
||||
ServerModule,
|
||||
FormsModule,
|
||||
MdButtonModule,
|
||||
@ -77,7 +61,6 @@ export const SERVER_ANIMATIONS_PROVIDERS: Provider[] = [{
|
||||
],
|
||||
providers: [
|
||||
SomeService,
|
||||
SERVER_ANIMATIONS_PROVIDERS,
|
||||
{provide: CUSTOM, useValue: {name: 'some name'}},
|
||||
],
|
||||
entryComponents: [
|
||||
|
Reference in New Issue
Block a user