Skip to content

Commit ad9b46b

Browse files
committed
test(@ngtools/webpack): test webpack only AngularCompilerPlugin
1 parent a996ebf commit ad9b46b

32 files changed

+560
-19
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ test_script:
1818
build: off
1919

2020
cache:
21-
- node_modules
21+
- node_modules -> package-lock.json

package-lock.json

Lines changed: 19 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@
101101
"zone.js": "^0.8.14"
102102
},
103103
"devDependencies": {
104-
"@angular/compiler": "angular/compiler-builds#5.0.0-beta.6+fa6b802",
105-
"@angular/compiler-cli": "angular/compiler-cli-builds#5.0.0-beta.6+fa6b802",
106-
"@angular/core": "angular/core-builds#5.0.0-beta.6+fa6b802",
104+
"@angular/compiler": "^4.0.0",
105+
"@angular/compiler-cli": "^4.0.0",
106+
"@angular/core": "^4.0.0",
107107
"@types/chalk": "^0.4.28",
108108
"@types/common-tags": "^1.2.4",
109109
"@types/copy-webpack-plugin": "^4.0.0",
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 { BrowserModule } from '@angular/platform-browser';
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+
BrowserModule,
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 {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
3+
import {AppModule} from './app.module';
4+
5+
platformBrowserDynamic().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>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "test",
3+
"license": "MIT",
4+
"dependencies": {
5+
"@angular/common": "^5.0.0-beta.5",
6+
"@angular/compiler": "^5.0.0-beta.5",
7+
"@angular/compiler-cli": "^5.0.0-beta.5",
8+
"@angular/core": "^5.0.0-beta.5",
9+
"@angular/http": "^5.0.0-beta.5",
10+
"@angular/platform-browser": "^5.0.0-beta.5",
11+
"@angular/platform-browser-dynamic": "^5.0.0-beta.5",
12+
"@angular/platform-server": "^5.0.0-beta.5",
13+
"@angular/router": "^5.0.0-beta.5",
14+
"@ngtools/webpack": "0.0.0",
15+
"core-js": "^2.4.1",
16+
"rxjs": "^5.4.2",
17+
"zone.js": "^0.8.14"
18+
},
19+
"devDependencies": {
20+
"node-sass": "^3.7.0",
21+
"performance-now": "^0.2.0",
22+
"raw-loader": "^0.5.1",
23+
"sass-loader": "^3.2.0",
24+
"typescript": "~2.4.2",
25+
"webpack": "2.2.0"
26+
}
27+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
// Test comment
3+
"compilerOptions": {
4+
"baseUrl": "",
5+
"module": "es2015",
6+
"moduleResolution": "node",
7+
"target": "es5",
8+
"noImplicitAny": false,
9+
"sourceMap": true,
10+
"mapRoot": "",
11+
"emitDecoratorMetadata": true,
12+
"experimentalDecorators": true,
13+
"lib": [
14+
"es2017",
15+
"dom"
16+
],
17+
"outDir": "lib",
18+
"skipLibCheck": true,
19+
"rootDir": "."
20+
},
21+
"angularCompilerOptions": {
22+
"genDir": "./app/ngfactory",
23+
"entryModule": "app/app.module#AppModule"
24+
}
25+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const ngToolsWebpack = require('@ngtools/webpack');
2+
3+
module.exports = {
4+
resolve: {
5+
extensions: ['.ts', '.js']
6+
},
7+
entry: './app/main.ts',
8+
output: {
9+
path: './dist',
10+
publicPath: 'dist/',
11+
filename: 'app.main.js'
12+
},
13+
plugins: [
14+
new ngToolsWebpack.AngularCompilerPlugin({
15+
tsConfigPath: './tsconfig.json'
16+
})
17+
],
18+
module: {
19+
loaders: [
20+
{ test: /\.scss$/, loaders: ['raw-loader', 'sass-loader'] },
21+
{ test: /\.css$/, loader: 'raw-loader' },
22+
{ test: /\.html$/, loader: 'raw-loader' },
23+
{ test: /\.ts$/, loader: '@ngtools/webpack' }
24+
]
25+
},
26+
devServer: {
27+
historyApiFallback: true
28+
}
29+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"tsConfigPath": "./not/so/source/tsconfig.json",
3+
"mainPath": "app/main.jit.ts"
4+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div>
2+
<h1>hello world</h1>
3+
<a [routerLink]="['lazy']">lazy</a>
4+
<router-outlet></router-outlet>
5+
</div>
6+
7+
<!-- @ifdef DEBUG -->
8+
<p>DEBUG_ONLY</p>
9+
<!-- @endif -->
10+
11+
<!-- @ifndef DEBUG -->
12+
<p>PRODUCTION_ONLY</p>
13+
<!-- @endif -->
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
:host {
2+
background-color: blue;
3+
}
4+
5+
// @ifdef DEBUG
6+
:host::before {
7+
content: 'DEBUG_ONLY';
8+
}
9+
// @endif
10+
11+
// @ifndef DEBUG
12+
:host::before {
13+
content: 'PRODUCTION_ONLY';
14+
}
15+
// @endif
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import {Component, ViewEncapsulation} from '@angular/core';
2+
3+
4+
@Component({
5+
selector: 'app-root',
6+
templateUrl: './app.component.html',
7+
styleUrls: ['./app.component.scss'],
8+
encapsulation: ViewEncapsulation.None
9+
})
10+
export class AppComponent { }

0 commit comments

Comments
 (0)