Skip to content

Commit fa8b06b

Browse files
authored
Update Angular to 2.4.5 based on latest from JavaScript Services
1 parent 7b9420e commit fa8b06b

File tree

5 files changed

+64
-74
lines changed

5 files changed

+64
-74
lines changed
Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,36 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
2-
1+
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
32
<PropertyGroup>
43
<TargetFramework>netcoreapp1.1</TargetFramework>
5-
<PreserveCompilationContext>true</PreserveCompilationContext>
6-
<AssemblyName>Angular</AssemblyName>
7-
<OutputType>Exe</OutputType>
8-
<PackageId>Angular</PackageId>
9-
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
10-
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;portable-net45+win8</PackageTargetFallback>
4+
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
5+
<IsPackable>false</IsPackable>
116
</PropertyGroup>
12-
137
<ItemGroup>
14-
<Compile Remove="node_modules\**\*" />
15-
<None Update="ClientApp\dist\**\*;node_modules\**\*;Views\**\*;wwwroot\**\*">
16-
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
17-
</None>
18-
<None Update="wwwroot\dist\*.map">
19-
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
20-
</None>
8+
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.0" />
9+
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.1" />
10+
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="1.1.0" />
11+
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.0" />
12+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.0" />
2113
</ItemGroup>
22-
2314
<ItemGroup>
24-
<PackageReference Include="Microsoft.AspNetCore.AngularServices" Version="1.0.0-*" />
25-
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.1" />
26-
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
27-
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.1" />
28-
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.1" />
29-
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
30-
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="1.1.1" />
31-
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.1" />
32-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.1" />
33-
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.1" />
34-
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" />
35-
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
36-
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.1" />
37-
</ItemGroup>
15+
<!-- Files not to show in IDE -->
16+
<None Remove="yarn.lock" />
3817

39-
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
18+
<!-- Files not to publish (note that the 'dist' subfolders are re-added below) -->
19+
<Content Remove="ClientApp\**" />
20+
</ItemGroup>
21+
<Target Name="RunWebpack" AfterTargets="ComputeFilesToPublish">
22+
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
4023
<Exec Command="npm install" />
4124
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" />
4225
<Exec Command="node node_modules/webpack/bin/webpack.js --env.prod" />
43-
</Target>
4426

45-
<ItemGroup>
46-
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />
47-
</ItemGroup>
48-
49-
</Project>
27+
<!-- Include the newly-built files in the publish output -->
28+
<ItemGroup>
29+
<DistFiles Include="wwwroot\dist\**; ClientApp\dist\**" />
30+
<ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
31+
<RelativePath>%(DistFiles.Identity)</RelativePath>
32+
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
33+
</ResolvedFileToPublish>
34+
</ItemGroup>
35+
</Target>
36+
</Project>

ASP.NET Core Basics/src/Angular/ClientApp/boot-client.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@ import { enableProdMode } from '@angular/core';
33
import { platformUniversalDynamic } from 'angular2-universal';
44
import { AppModule } from './app/app.module';
55
import 'bootstrap';
6+
const rootElemTagName = 'app'; // Update this if you change your root component selector
67

78
// Enable either Hot Module Reloading or production mode
89
if (module['hot']) {
910
module['hot'].accept();
10-
module['hot'].dispose(() => { platform.destroy(); });
11+
module['hot'].dispose(() => {
12+
// Before restarting the app, we create a new root element and dispose the old one
13+
const oldRootElem = document.querySelector(rootElemTagName);
14+
const newRootElem = document.createElement(rootElemTagName);
15+
oldRootElem.parentNode.insertBefore(newRootElem, oldRootElem);
16+
platform.destroy();
17+
});
1118
} else {
1219
enableProdMode();
1320
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
import 'angular2-universal-polyfills';
2+
import 'angular2-universal-patch';
23
import 'zone.js';
4+
import { createServerRenderer, RenderResult } from 'aspnet-prerendering';
35
import { enableProdMode } from '@angular/core';
46
import { platformNodeDynamic } from 'angular2-universal';
57
import { AppModule } from './app/app.module';
68

79
enableProdMode();
810
const platform = platformNodeDynamic();
911

10-
export default function (params: any) : Promise<{ html: string, globals?: any }> {
11-
return new Promise((resolve, reject) => {
12+
export default createServerRenderer(params => {
13+
return new Promise<RenderResult>((resolve, reject) => {
1214
const requestZone = Zone.current.fork({
1315
name: 'angular-universal request',
1416
properties: {
1517
baseUrl: '/',
1618
requestUrl: params.url,
1719
originUrl: params.origin,
1820
preboot: false,
19-
// TODO: Render just the <app> component instead of wrapping it inside an extra HTML document
20-
// Waiting on https://github.com/angular/universal/issues/347
21-
document: '<!DOCTYPE html><html><head></head><body><app></app></body></html>'
21+
document: '<app></app>'
2222
},
2323
onHandleError: (parentZone, currentZone, targetZone, error) => {
2424
// If any error occurs while rendering the module, reject the whole operation
@@ -31,4 +31,4 @@ export default function (params: any) : Promise<{ html: string, globals?: any }>
3131
resolve({ html: html });
3232
}, reject);
3333
});
34-
}
34+
});

ASP.NET Core Basics/src/Angular/Program.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@ public class Program
1212
{
1313
public static void Main(string[] args)
1414
{
15-
var config = new ConfigurationBuilder()
16-
.AddCommandLine(args)
17-
.AddEnvironmentVariables(prefix: "ASPNETCORE_")
18-
.Build();
19-
2015
var host = new WebHostBuilder()
21-
.UseConfiguration(config)
2216
.UseKestrel()
2317
.UseContentRoot(Directory.GetCurrentDirectory())
2418
.UseIISIntegration()

ASP.NET Core Basics/src/Angular/package.json

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,46 @@
22
"name": "Angular2Spa",
33
"version": "0.0.0",
44
"dependencies": {
5-
"@angular/common": "2.1.0",
6-
"@angular/compiler": "2.1.0",
7-
"@angular/core": "2.1.0",
8-
"@angular/forms": "2.1.0",
9-
"@angular/http": "2.1.0",
10-
"@angular/platform-browser": "2.1.0",
11-
"@angular/platform-browser-dynamic": "2.1.0",
12-
"@angular/platform-server": "2.1.0",
13-
"@angular/router": "3.1.0",
14-
"@angular/upgrade": "2.1.0",
15-
"@types/node": "^6.0.48",
5+
"@angular/common": "^2.4.5",
6+
"@angular/compiler": "^2.4.5",
7+
"@angular/core": "^2.4.5",
8+
"@angular/forms": "^2.4.5",
9+
"@angular/http": "^2.4.5",
10+
"@angular/platform-browser": "^2.4.5",
11+
"@angular/platform-browser-dynamic": "^2.4.5",
12+
"@angular/platform-server": "^2.4.5",
13+
"@angular/router": "^3.4.5",
14+
"@types/node": "^6.0.42",
1615
"angular2-platform-node": "~2.0.11",
17-
"angular2-universal": "~2.0.11",
18-
"angular2-universal-polyfills": "~2.0.11",
19-
"aspnet-prerendering": "^1.0.7",
16+
"angular2-template-loader": "^0.6.2",
17+
"angular2-universal": "^2.1.0-rc.1",
18+
"angular2-universal-patch": "^0.2.1",
19+
"angular2-universal-polyfills": "^2.1.0-rc.1",
20+
"aspnet-prerendering": "^2.0.0",
2021
"aspnet-webpack": "^1.0.17",
22+
"awesome-typescript-loader": "^3.0.0",
2123
"bootstrap": "^3.3.7",
2224
"css": "^2.2.1",
2325
"css-loader": "^0.25.0",
2426
"es6-shim": "^0.35.1",
2527
"event-source-polyfill": "^0.0.7",
2628
"expose-loader": "^0.7.1",
27-
"extract-text-webpack-plugin": "^1.0.1",
29+
"extract-text-webpack-plugin": "^2.0.0-rc",
2830
"file-loader": "^0.9.0",
31+
"html-loader": "^0.4.4",
2932
"isomorphic-fetch": "^2.2.1",
30-
"jquery": "^3.1.1",
33+
"jquery": "^2.2.1",
34+
"json-loader": "^0.5.4",
3135
"preboot": "^4.5.2",
3236
"raw-loader": "^0.5.1",
33-
"rxjs": "5.0.0-beta.12",
37+
"rxjs": "^5.0.1",
3438
"style-loader": "^0.13.1",
3539
"to-string-loader": "^1.1.5",
36-
"ts-loader": "^1.2.1",
37-
"typescript": "^2.1.1",
40+
"typescript": "^2.2.1",
3841
"url-loader": "^0.5.7",
39-
"webpack": "^1.13.2",
42+
"webpack": "^2.2.0",
4043
"webpack-hot-middleware": "^2.12.2",
41-
"webpack-node-externals": "^1.4.3",
42-
"webpack-merge": "^0.16.0",
43-
"zone.js": "^0.6.25"
44+
"webpack-merge": "^0.14.1",
45+
"zone.js": "^0.7.6"
4446
}
4547
}

0 commit comments

Comments
 (0)