Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit cdfe957

Browse files
thelgevoldwardbell
authored andcommitted
docs(toh-6-aot): add aot to toh-6 (#2496)
* docs(toh-6-aot): add aot to toh-6 s s s s s * docs(toh-6-aot): add aot to toh-6 * docs(toh-6-aot): make aot e2e tests run in the same project Updates tooling for this purpose and also the prose.
1 parent 2e17d58 commit cdfe957

File tree

21 files changed

+335
-32
lines changed

21 files changed

+335
-32
lines changed

gulpfile.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,12 @@ function runE2eTsTests(appDir, outputFile) {
296296
var appBuildSpawnInfo = spawnExt('npm', ['run', config.build], { cwd: appDir });
297297
var appRunSpawnInfo = spawnExt('npm', ['run', config.run, '--', '-s'], { cwd: appDir });
298298

299-
return runProtractor(appBuildSpawnInfo.promise, appDir, appRunSpawnInfo, outputFile);
299+
var run = runProtractor(appBuildSpawnInfo.promise, appDir, appRunSpawnInfo, outputFile);
300+
301+
if (fs.existsSync(appDir + '/aot/index.html')) {
302+
run = run.then(() => runProtractorAoT(appDir, outputFile));
303+
}
304+
return run;
300305
}
301306

302307
function runProtractor(prepPromise, appDir, appRunSpawnInfo, outputFile) {
@@ -341,6 +346,20 @@ function runProtractor(prepPromise, appDir, appRunSpawnInfo, outputFile) {
341346
}
342347
}
343348

349+
function runProtractorAoT(appDir, outputFile) {
350+
fs.appendFileSync(outputFile, '++ AoT version ++\n');
351+
var aotBuildSpawnInfo = spawnExt('npm', ['run', 'build:aot'], { cwd: appDir });
352+
var promise = aotBuildSpawnInfo.promise;
353+
354+
var copyFileCmd = 'copy-dist-files.js';
355+
if (fs.existsSync(appDir + '/' + copyFileCmd)) {
356+
promise = promise.then(() =>
357+
spawnExt('node', [copyFileCmd], { cwd: appDir }).promise );
358+
}
359+
var aotRunSpawnInfo = spawnExt('npm', ['run', 'http-server:e2e', 'aot', '--', '-s'], { cwd: appDir });
360+
return runProtractor(promise, appDir, aotRunSpawnInfo, outputFile);
361+
}
362+
344363
// start the server in appDir/build/web; then run protractor with the specified
345364
// fileName; then shut down the example. All protractor output is appended
346365
// to the outputFile.
@@ -883,7 +902,7 @@ function harpCompile() {
883902
gutil.log("NODE_ENV: " + process.env.NODE_ENV);
884903

885904
if(argv.page) harpJsonSetJade2NgTo(true);
886-
905+
887906
if(skipLangs && fs.existsSync(WWW) && backupApiHtmlFilesExist(WWW)) {
888907
gutil.log(`Harp site recompile: skipping recompilation of API docs for [${skipLangs}]`);
889908
gutil.log(`API docs will be copied from existing ${WWW} folder.`)

public/docs/_examples/_boilerplate/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"http-server:e2e": "http-server",
1010
"http-server:cli": "http-server dist/",
1111
"lite": "lite-server",
12+
"lite:aot": "lite-server -c aot/bs-config.json",
1213
"postinstall": "typings install",
1314
"test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
1415
"tsc": "tsc",
@@ -17,7 +18,8 @@
1718
"test:webpack": "karma start karma.webpack.conf.js",
1819
"build:webpack": "rimraf dist && webpack --config config/webpack.prod.js --bail",
1920
"build:cli": "ng build",
20-
"build:aot": "ngc -p tsconfig-aot.json && rollup -c rollup.js",
21+
"build:aot": "ngc -p tsconfig-aot.json && rollup -c rollup-config.js",
22+
"copy-dist-files": "node ./copy-dist-files.js",
2123
"i18n": "ng-xi18n"
2224
},
2325
"keywords": [],

public/docs/_examples/_boilerplate/tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@
1010
"noImplicitAny": true,
1111
"suppressImplicitAnyIndexErrors": true,
1212
"types": []
13-
}
13+
},
14+
"exclude": [
15+
"node_modules/*",
16+
"**/*-aot.ts"
17+
]
1418
}

public/docs/_examples/cb-aot-compiler/ts/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
**/*.metadata.json
33
dist
44
!app/tsconfig.json
5-
!rollup.js
5+
!rollup-config.js

public/docs/_examples/cb-aot-compiler/ts/app/app.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ export class AppComponent {
1313
toggleHeading() {
1414
this.showHeading = !this.showHeading;
1515
}
16-
1716
}

public/docs/_examples/cb-aot-compiler/ts/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
<script src="node_modules/core-js/client/shim.min.js"></script>
1111
<script src="node_modules/zone.js/dist/zone.js"></script>
12-
<script src="node_modules/reflect-metadata/Reflect.js"></script>
1312

1413
</head>
1514

public/docs/_examples/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"raw-loader": "^0.5.1",
7575
"rimraf": "^2.5.4",
7676
"rollup-plugin-commonjs": "^4.1.0",
77+
"source-map-explorer": "^1.3.2",
7778
"style-loader": "^0.13.1",
7879
"ts-loader": "^0.8.2",
7980
"ts-node": "^1.3.0",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
**/*.js
2+
aot/**/*.ts
3+
!rollup-config.js
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"port": 8000,
3+
"files": ["./aot/**/*.{html,htm,css,js}"],
4+
"server": { "baseDir": "./aot" }
5+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!-- #docregion -->
2+
<!DOCTYPE html>
3+
<html>
4+
<head>
5+
<base href="/">
6+
<title>Angular Tour of Heroes</title>
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
9+
<script src="shim.min.js"></script>
10+
<script src="zone.min.js"></script>
11+
<!-- #docregion moduleId -->
12+
<script>window.module = 'aot';</script>
13+
<!-- #enddocregion moduleId -->
14+
</head>
15+
16+
<body>
17+
<my-app>Loading...</my-app>
18+
</body>
19+
<script src="dist/build.js"></script>
20+
</html>

public/docs/_examples/toh-6/ts/app/app.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { Component } from '@angular/core';
55
@Component({
66
moduleId: module.id,
77
selector: 'my-app',
8-
98
template: `
109
<h1>{{title}}</h1>
1110
<nav>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// #docregion
2+
import { platformBrowser } from '@angular/platform-browser';
3+
4+
import { AppModuleNgFactory } from '../aot/app/app.module.ngfactory';
5+
6+
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// #docregion
2+
var fs = require('fs');
3+
var resources = [
4+
'node_modules/core-js/client/shim.min.js',
5+
'node_modules/zone.js/dist/zone.min.js'
6+
];
7+
resources.map(function(f) {
8+
var path = f.split('/');
9+
var t = 'aot/' + path[path.length-1];
10+
fs.createReadStream(f).pipe(fs.createWriteStream(t));
11+
});

public/docs/_examples/toh-6/ts/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- #docregion -->
12
<!DOCTYPE html>
23
<html>
34
<head>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// #docregion
2+
import rollup from 'rollup'
3+
import nodeResolve from 'rollup-plugin-node-resolve'
4+
import commonjs from 'rollup-plugin-commonjs';
5+
import uglify from 'rollup-plugin-uglify'
6+
7+
//paths are relative to the execution path
8+
export default {
9+
entry: 'app/main-aot.js',
10+
dest: 'aot/dist/build.js', // output a single application bundle
11+
sourceMap: true,
12+
sourceMapFile: 'aot/dist/build.js.map',
13+
format: 'iife',
14+
plugins: [
15+
nodeResolve({jsnext: true, module: true}),
16+
commonjs({
17+
include: [
18+
'node_modules/rxjs/**',
19+
'node_modules/angular-in-memory-web-api/**'
20+
],
21+
}),
22+
uglify()
23+
]
24+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "es2015",
5+
"moduleResolution": "node",
6+
"sourceMap": true,
7+
"emitDecoratorMetadata": true,
8+
"experimentalDecorators": true,
9+
"removeComments": false,
10+
"noImplicitAny": true,
11+
"suppressImplicitAnyIndexErrors": true,
12+
"types": []
13+
},
14+
15+
"files": [
16+
"app/app.module.ts",
17+
"app/main-aot.ts",
18+
"typings/index.d.ts"
19+
],
20+
21+
"angularCompilerOptions": {
22+
"genDir": "aot",
23+
"skipMetadataEmit" : true
24+
}
25+
}

public/docs/_examples/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
"include": [
2222
"*/e2e-spec.ts"
2323
]
24-
}
24+
}

0 commit comments

Comments
 (0)