add aot (WIP)
This commit is contained in:
parent
0d74c9332f
commit
b0c4422a97
|
@ -0,0 +1,3 @@
|
||||||
|
**/*.js
|
||||||
|
aot/**/*.ts
|
||||||
|
!rollup-config.js
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"port": 8000,
|
||||||
|
"files": ["./aot/**/*.{html,htm,css,js}"],
|
||||||
|
"server": { "baseDir": "./aot" }
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
<!-- #docregion -->
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<base href="/">
|
||||||
|
<title>Angular Tour of Heroes</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="styles.css">
|
||||||
|
|
||||||
|
<script src="https://code.jquery.com/jquery-2.2.4.js"></script>
|
||||||
|
<script src="https://code.angularjs.org/1.5.5/angular.js"></script>
|
||||||
|
<script src="https://code.angularjs.org/1.5.5/angular-animate.js"></script>
|
||||||
|
<script src="https://code.angularjs.org/1.5.5/angular-resource.js"></script>
|
||||||
|
<script src="https://code.angularjs.org/1.5.5/angular-route.js"></script>
|
||||||
|
|
||||||
|
<script src="app.module.ng1.js"></script>
|
||||||
|
<script src="app.config.js"></script>
|
||||||
|
<script src="app.animations.js"></script>
|
||||||
|
<script src="core/core.module.js"></script>
|
||||||
|
<script src="core/phone/phone.module.js"></script>
|
||||||
|
<script src="phone-list/phone-list.module.js"></script>
|
||||||
|
<script src="phone-detail/phone-detail.module.js"></script>
|
||||||
|
|
||||||
|
<script src="shim.min.js"></script>
|
||||||
|
<script src="zone.min.js"></script>
|
||||||
|
<!-- #docregion moduleId -->
|
||||||
|
<script>window.module = 'aot';</script>
|
||||||
|
<!-- #enddocregion moduleId -->
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<my-app>Loading...</my-app>
|
||||||
|
</body>
|
||||||
|
<script src="dist/build.js"></script>
|
||||||
|
</html>
|
|
@ -59,7 +59,7 @@ import { PhoneDetailComponent } from './phone-detail/phone-detail.component';
|
||||||
// #enddocregion phone
|
// #enddocregion phone
|
||||||
{
|
{
|
||||||
provide: '$routeParams',
|
provide: '$routeParams',
|
||||||
useFactory: (i: any) => i.get('$routeParams'),
|
useFactory: routeParamsFactory,
|
||||||
deps: ['$injector']
|
deps: ['$injector']
|
||||||
}
|
}
|
||||||
// #docregion phone
|
// #docregion phone
|
||||||
|
@ -73,3 +73,9 @@ export class AppModule {
|
||||||
// #docregion bare
|
// #docregion bare
|
||||||
}
|
}
|
||||||
// #enddocregion bare, upgrademodule, httpmodule, phone, phonelist, phonedetail, checkmarkpipe
|
// #enddocregion bare, upgrademodule, httpmodule, phone, phonelist, phonedetail, checkmarkpipe
|
||||||
|
|
||||||
|
// #docregion routeparams
|
||||||
|
export function routeParamsFactory(i: any) {
|
||||||
|
return i.get('$routeParams');
|
||||||
|
}
|
||||||
|
// #enddocregion routeparams
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
// #docregion bootstrap
|
||||||
|
import { platformBrowser } from '@angular/platform-browser';
|
||||||
|
import { UpgradeModule } from '@angular/upgrade/static';
|
||||||
|
|
||||||
|
import { AppModuleNgFactory } from '../aot/app/app.module.ngfactory';
|
||||||
|
|
||||||
|
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory).then(platformRef => {
|
||||||
|
let upgrade = platformRef.injector.get(UpgradeModule) as UpgradeModule;
|
||||||
|
upgrade.bootstrap(document.documentElement, ['phonecatApp']);
|
||||||
|
});
|
||||||
|
// #enddocregion bootstrap
|
|
@ -1,5 +1,4 @@
|
||||||
// #docregion bootstrap
|
// #docregion bootstrap
|
||||||
declare var angular: angular.IAngularStatic;
|
|
||||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||||
import { UpgradeModule } from '@angular/upgrade/static';
|
import { UpgradeModule } from '@angular/upgrade/static';
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,7 @@ export class PhoneDetailComponent {
|
||||||
phone: PhoneData;
|
phone: PhoneData;
|
||||||
mainImageUrl: string;
|
mainImageUrl: string;
|
||||||
|
|
||||||
constructor(@Inject('$routeParams')
|
constructor(@Inject('$routeParams') $routeParams: any, phone: Phone) {
|
||||||
$routeParams: angular.route.IRouteParamsService,
|
|
||||||
phone: Phone) {
|
|
||||||
phone.get($routeParams['phoneId']).subscribe(phone => {
|
phone.get($routeParams['phoneId']).subscribe(phone => {
|
||||||
this.phone = phone;
|
this.phone = phone;
|
||||||
this.setImage(phone.images[0]);
|
this.setImage(phone.images[0]);
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
// #docregion
|
||||||
|
import rollup from 'rollup'
|
||||||
|
import nodeResolve from 'rollup-plugin-node-resolve'
|
||||||
|
import commonjs from 'rollup-plugin-commonjs';
|
||||||
|
import uglify from 'rollup-plugin-uglify'
|
||||||
|
|
||||||
|
//paths are relative to the execution path
|
||||||
|
export default {
|
||||||
|
entry: 'app/main-aot.js',
|
||||||
|
dest: 'aot/dist/build.js', // output a single application bundle
|
||||||
|
sourceMap: true,
|
||||||
|
sourceMapFile: 'aot/dist/build.js.map',
|
||||||
|
format: 'iife',
|
||||||
|
plugins: [
|
||||||
|
nodeResolve({jsnext: true, module: true}),
|
||||||
|
commonjs({
|
||||||
|
include: ['node_modules/rxjs/**']
|
||||||
|
}),
|
||||||
|
uglify()
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"module": "es2015",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"sourceMap": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"removeComments": false,
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"suppressImplicitAnyIndexErrors": true,
|
||||||
|
"typeRoots": [
|
||||||
|
"../../node_modules/@types/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
"files": [
|
||||||
|
"app/app.module.ts",
|
||||||
|
"app/main-aot.ts"
|
||||||
|
],
|
||||||
|
|
||||||
|
"angularCompilerOptions": {
|
||||||
|
"genDir": "aot",
|
||||||
|
"skipMetadataEmit" : true
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue