Skip to content

Commit 3490c18

Browse files
committed
test(@ngtools/webpack): add tests for webpack for platform-server
1 parent 1404a1b commit 3490c18

File tree

14 files changed

+247
-0
lines changed

14 files changed

+247
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<div>
2+
<h1>hello world</h1>
3+
<a [routerLink]="['lazy']">lazy</a>
4+
<router-outlet></router-outlet>
5+
</div>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:host {
2+
background-color: blue;
3+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {Component, ViewEncapsulation} from '@angular/core';
2+
import {MyInjectable} from './injectable';
3+
4+
5+
@Component({
6+
selector: 'app-root',
7+
templateUrl: './app.component.html',
8+
styleUrls: ['./app.component.scss'],
9+
encapsulation: ViewEncapsulation.None
10+
})
11+
export class AppComponent {
12+
constructor(public inj: MyInjectable) {
13+
console.log(inj);
14+
}
15+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { NgModule, Component } from '@angular/core';
2+
import { ServerModule } from '@angular/platform-server';
3+
import { RouterModule } from '@angular/router';
4+
import { AppComponent } from './app.component';
5+
6+
@Component({
7+
selector: 'home-view',
8+
template: 'home!'
9+
})
10+
export class HomeView {}
11+
12+
13+
@NgModule({
14+
declarations: [
15+
AppComponent,
16+
HomeView
17+
],
18+
imports: [
19+
ServerModule,
20+
RouterModule.forRoot([
21+
{path: 'lazy', loadChildren: './lazy.module#LazyModule'},
22+
{path: '', component: HomeView}
23+
])
24+
],
25+
bootstrap: [AppComponent]
26+
})
27+
export class AppModule { }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {NgModule, Component} from '@angular/core';
2+
import {RouterModule} from '@angular/router';
3+
4+
@Component({
5+
selector: 'feature-component',
6+
template: 'foo.html'
7+
})
8+
export class FeatureComponent {}
9+
10+
@NgModule({
11+
declarations: [
12+
FeatureComponent
13+
],
14+
imports: [
15+
RouterModule.forChild([
16+
{ path: '', component: FeatureComponent}
17+
])
18+
]
19+
})
20+
export class FeatureModule {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {NgModule, Component} from '@angular/core';
2+
import {RouterModule} from '@angular/router';
3+
import {HttpModule, Http} from '@angular/http';
4+
5+
@Component({
6+
selector: 'lazy-feature-comp',
7+
template: 'lazy feature!'
8+
})
9+
export class LazyFeatureComponent {}
10+
11+
@NgModule({
12+
imports: [
13+
RouterModule.forChild([
14+
{path: '', component: LazyFeatureComponent, pathMatch: 'full'},
15+
{path: 'feature', loadChildren: './feature.module#FeatureModule'}
16+
]),
17+
HttpModule
18+
],
19+
declarations: [LazyFeatureComponent]
20+
})
21+
export class LazyFeatureModule {
22+
constructor(http: Http) {}
23+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {Injectable, Inject, ViewContainerRef} from '@angular/core';
2+
import {DOCUMENT} from '@angular/platform-browser';
3+
4+
5+
@Injectable()
6+
export class MyInjectable {
7+
constructor(public viewContainer: ViewContainerRef, @Inject(DOCUMENT) public doc) {}
8+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {NgModule, Component} from '@angular/core';
2+
import {RouterModule} from '@angular/router';
3+
import {HttpModule, Http} from '@angular/http';
4+
5+
@Component({
6+
selector: 'lazy-comp',
7+
template: 'lazy!'
8+
})
9+
export class LazyComponent {}
10+
11+
@NgModule({
12+
imports: [
13+
RouterModule.forChild([
14+
{path: '', component: LazyComponent, pathMatch: 'full'},
15+
{path: 'feature', loadChildren: './feature/feature.module#FeatureModule'},
16+
{path: 'lazy-feature', loadChildren: './feature/lazy-feature.module#LazyFeatureModule'}
17+
]),
18+
HttpModule
19+
],
20+
declarations: [LazyComponent]
21+
})
22+
export class LazyModule {
23+
constructor(http: Http) {}
24+
}
25+
26+
export class SecondModule {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import 'core-js/es7/reflect';
2+
import {platformDynamicServer} from '@angular/platform-dynamic-server';
3+
import {AppModule} from './app.module';
4+
5+
platformDynamicServer().bootstrapModule(AppModule);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8">
4+
<title>Document</title>
5+
<base href="">
6+
</head>
7+
<body>
8+
<app-root></app-root>
9+
<script src="node_modules/zone.js/dist/zone.js"></script>
10+
<script src="dist/app.main.js"></script>
11+
</body>
12+
</html>

0 commit comments

Comments
 (0)