This repository was archived by the owner on Apr 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 517
Update Angular2Spa template to Angular 2.0/TypeScript 2.0, based on @MarkPieszak's PR #321
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ce0d208
ng2 2.0, Universal 2.0, TS 2.0, Preboot 4.*
MarkPieszak 1e08548
Remove now-redundant 'typings' dir and custom-typings.d.ts
SteveSandersonMS 243a9b4
Add @types/node to avoid intellisense errors for "require" statements
SteveSandersonMS 8f550c5
Simplify Angular 2 template where possible
SteveSandersonMS 297b4db
Move more modules to vendor bundle. Remove explicit reflect-metadata …
SteveSandersonMS a1c1bdb
Simplify imports in boot-client.ts
SteveSandersonMS a91b6a6
Make HMR work again
SteveSandersonMS 85dfdd9
Move tsconfig into ClientApp dir, since it's not needed at root
SteveSandersonMS 4ea7eb1
Simplify webpack config. Eliminate dev/prod override files.
SteveSandersonMS 07a9c16
Remove unnecessary NPM dependencies
SteveSandersonMS 358ee22
Make indentation consistent
SteveSandersonMS 49a8536
Update angular2-universal dependencies (cherry-pick 62dd13b3b)
SteveSandersonMS 494c7b5
Fix trailing whitespace
SteveSandersonMS 83cfb59
Add comment about UniversalModule
SteveSandersonMS ca99a23
Remove style-loader from Angular2Spa vendor bundle as it's not used a…
SteveSandersonMS 41f1f6f
Delay Angular 2 bootstrapping until DOMContentLoaded
SteveSandersonMS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { RouterModule } from '@angular/router'; | ||
import { UniversalModule } from 'angular2-universal'; | ||
import { AppComponent } from './components/app/app.component' | ||
import { NavMenuComponent } from './components/navmenu/navmenu.component'; | ||
import { HomeComponent } from './components/home/home.component'; | ||
import { FetchDataComponent } from './components/fetchdata/fetchdata.component'; | ||
import { CounterComponent } from './components/counter/counter.component'; | ||
|
||
@NgModule({ | ||
bootstrap: [ AppComponent ], | ||
declarations: [ | ||
AppComponent, | ||
NavMenuComponent, | ||
CounterComponent, | ||
FetchDataComponent, | ||
HomeComponent | ||
], | ||
imports: [ | ||
UniversalModule, // Must be first import. This automatically imports BrowserModule, HttpModule, and JsonpModule too. | ||
RouterModule.forRoot([ | ||
{ path: '', redirectTo: 'home', pathMatch: 'full' }, | ||
{ path: 'home', component: HomeComponent }, | ||
{ path: 'counter', component: CounterComponent }, | ||
{ path: 'fetch-data', component: FetchDataComponent }, | ||
{ path: '**', redirectTo: 'home' } | ||
]) | ||
] | ||
}) | ||
export class AppModule { | ||
} |
File renamed without changes.
8 changes: 8 additions & 0 deletions
8
templates/Angular2Spa/ClientApp/app/components/app/app.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app', | ||
template: require('./app.component.html') | ||
}) | ||
export class AppComponent { | ||
} |
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
templates/Angular2Spa/ClientApp/app/components/counter/counter.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'counter', | ||
template: require('./counter.component.html') | ||
}) | ||
export class CounterComponent { | ||
public currentCount = 0; | ||
|
||
public incrementCounter() { | ||
this.currentCount++; | ||
} | ||
} |
File renamed without changes.
10 changes: 5 additions & 5 deletions
10
...ntApp/components/fetch-data/fetch-data.ts → ...mponents/fetchdata/fetchdata.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
8 changes: 8 additions & 0 deletions
8
templates/Angular2Spa/ClientApp/app/components/home/home.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'home', | ||
template: require('./home.component.html') | ||
}) | ||
export class HomeComponent { | ||
} |
File renamed without changes.
8 changes: 8 additions & 0 deletions
8
templates/Angular2Spa/ClientApp/app/components/navmenu/navmenu.component.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'nav-menu', | ||
template: require('./navmenu.component.html') | ||
}) | ||
export class NavMenuComponent { | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
import 'es6-shim'; | ||
require('zone.js'); | ||
import 'angular2-universal-polyfills/browser'; | ||
import { enableProdMode } from '@angular/core'; | ||
import { platformUniversalDynamic } from 'angular2-universal'; | ||
import { AppModule } from './app/app.module'; | ||
|
||
// Include styles in the bundle | ||
import 'bootstrap'; | ||
import 'reflect-metadata'; | ||
import './styles/site.css'; | ||
|
||
import { bootstrap } from '@angular/platform-browser-dynamic'; | ||
import { FormBuilder } from '@angular/common'; | ||
import { provideRouter } from '@angular/router'; | ||
import { HTTP_PROVIDERS } from '@angular/http'; | ||
import { App } from './components/app/app'; | ||
import { routes } from './routes'; | ||
|
||
bootstrap(App, [ | ||
...HTTP_PROVIDERS, | ||
FormBuilder, | ||
provideRouter(routes) | ||
]); | ||
|
||
// Basic hot reloading support. Automatically reloads and restarts the Angular 2 app each time | ||
// you modify source files. This will not preserve any application state other than the URL. | ||
declare var module: any; | ||
if (module.hot) { | ||
module.hot.accept(); | ||
// Enable either Hot Module Reloading or production mode | ||
const hotModuleReplacement = module['hot']; | ||
if (hotModuleReplacement) { | ||
hotModuleReplacement.accept(); | ||
hotModuleReplacement.dispose(() => { platform.destroy(); }); | ||
} else { | ||
enableProdMode(); | ||
} | ||
|
||
// Boot the application | ||
const platform = platformUniversalDynamic(); | ||
document.addEventListener('DOMContentLoaded', () => { | ||
platform.bootstrapModule(AppModule); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,28 @@ | ||
import 'angular2-universal/polyfills'; | ||
import * as ngCore from '@angular/core'; | ||
import { APP_BASE_HREF } from '@angular/common'; | ||
import { provideRouter } from '@angular/router'; | ||
import * as ngUniversal from 'angular2-universal'; | ||
import { BASE_URL, ORIGIN_URL, REQUEST_URL } from 'angular2-universal/common'; | ||
import { App } from './components/app/app'; | ||
import { routes } from './routes'; | ||
import 'angular2-universal-polyfills'; | ||
import 'zone.js'; | ||
import { enableProdMode } from '@angular/core'; | ||
import { platformNodeDynamic } from 'angular2-universal'; | ||
import { AppModule } from './app/app.module'; | ||
|
||
const bootloader = ngUniversal.bootloader({ | ||
async: true, | ||
preboot: false, | ||
platformProviders: [ | ||
ngCore.provide(APP_BASE_HREF, { useValue: '/' }), | ||
] | ||
}); | ||
enableProdMode(); | ||
const platform = platformNodeDynamic(); | ||
|
||
export default function (params: any): Promise<{ html: string, globals?: any }> { | ||
const config: ngUniversal.AppConfig = { | ||
directives: [App], | ||
providers: [ | ||
ngCore.provide(ORIGIN_URL, { useValue: params.origin }), | ||
ngCore.provide(REQUEST_URL, { useValue: params.url }), | ||
...ngUniversal.NODE_HTTP_PROVIDERS, | ||
provideRouter(routes), | ||
...ngUniversal.NODE_LOCATION_PROVIDERS, | ||
], | ||
// TODO: Render just the <app> component instead of wrapping it inside an extra HTML document | ||
// Waiting on https://github.com/angular/universal/issues/347 | ||
template: '<!DOCTYPE html>\n<html><head></head><body><app></app></body></html>' | ||
}; | ||
|
||
return bootloader.serializeApplication(config).then(html => { | ||
return { html }; | ||
export default function (params: any) : Promise<{ html: string, globals?: any }> { | ||
const requestZone = Zone.current.fork({ | ||
name: 'angular-universal request', | ||
properties: { | ||
baseUrl: '/', | ||
requestUrl: params.url, | ||
originUrl: params.origin, | ||
preboot: false, | ||
// TODO: Render just the <app> component instead of wrapping it inside an extra HTML document | ||
// Waiting on https://github.com/angular/universal/issues/347 | ||
document: '<!DOCTYPE html><html><head></head><body><app></app></body></html>' | ||
} | ||
}); | ||
|
||
return requestZone.run<Promise<string>>(() => platform.serializeModule(AppModule)) | ||
.then(html => { | ||
return { html: html }; | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
templates/Angular2Spa/ClientApp/components/counter/counter.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
templates/Angular2Spa/ClientApp/components/nav-menu/nav-menu.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,41 @@ | ||
{ | ||
"name": "WebApplicationBasic", | ||
"name": "Angular2Spa", | ||
"version": "0.0.0", | ||
"dependencies": { | ||
"@angular/common": "2.0.0-rc.4", | ||
"@angular/compiler": "2.0.0-rc.4", | ||
"@angular/core": "2.0.0-rc.4", | ||
"@angular/http": "2.0.0-rc.4", | ||
"@angular/platform-browser": "2.0.0-rc.4", | ||
"@angular/platform-browser-dynamic": "2.0.0-rc.4", | ||
"@angular/platform-server": "2.0.0-rc.4", | ||
"@angular/router": "3.0.0-beta.2", | ||
"angular2-universal": "^0.104.5", | ||
"aspnet-prerendering": "^1.0.2", | ||
"aspnet-webpack": "^1.0.6", | ||
"bootstrap": "^3.3.6", | ||
"@angular/common": "2.0.0", | ||
"@angular/compiler": "2.0.0", | ||
"@angular/core": "2.0.0", | ||
"@angular/forms": "2.0.0", | ||
"@angular/http": "2.0.0", | ||
"@angular/platform-browser": "2.0.0", | ||
"@angular/platform-browser-dynamic": "2.0.0", | ||
"@angular/platform-server": "2.0.0", | ||
"@angular/router": "3.0.0", | ||
"@types/node": "^6.0.38", | ||
"angular2-platform-node": "~2.0.10", | ||
"angular2-universal": "~2.0.10", | ||
"angular2-universal-polyfills": "~2.0.10", | ||
"aspnet-prerendering": "^1.0.6", | ||
"aspnet-webpack": "^1.0.11", | ||
"bootstrap": "^3.3.7", | ||
"css": "^2.2.1", | ||
"css-loader": "^0.23.1", | ||
"css-loader": "^0.25.0", | ||
"es6-shim": "^0.35.1", | ||
"expose-loader": "^0.7.1", | ||
"extendify": "^1.0.0", | ||
"extract-text-webpack-plugin": "^1.0.1", | ||
"file-loader": "^0.8.5", | ||
"file-loader": "^0.9.0", | ||
"isomorphic-fetch": "^2.2.1", | ||
"jquery": "^2.2.1", | ||
"preboot": "^2.0.10", | ||
"preboot": "^4.5.2", | ||
"raw-loader": "^0.5.1", | ||
"rxjs": "5.0.0-beta.6", | ||
"rxjs": "5.0.0-beta.12", | ||
"style-loader": "^0.13.0", | ||
"ts-loader": "^0.8.1", | ||
"typescript": "^1.8.2", | ||
"ts-loader": "^0.8.2", | ||
"typescript": "^2.0.0", | ||
"url-loader": "^0.5.7", | ||
"webpack": "^1.12.14", | ||
"webpack-externals-plugin": "^1.0.0", | ||
"webpack-hot-middleware": "^2.10.0", | ||
"zone.js": "^0.6.12" | ||
"zone.js": "^0.6.21" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much cleaner I like it 👍