Skip to content

Commit 5568436

Browse files
authored
WIP - Re-sync with JavaScriptServices (#376)
* WIP - Re-sync with JavaScriptServices Main goal is to re-align a bit more with JavaScriptServices to ensure people coming from there, wanting to add additional features, have an easier time syncing with this repo. Adds back vendor builds, Adds back fast HMR (but waiting for aspnet/JavaScriptServices#1204) AoT faster Cleans up multiple tsconfigs etc etc... * fix gitignore * fix HMR, VS builds, misc updates * add package-lock to gitignore closes #307 closes #318 closes #296 closes #294 closes #271 closes #267 closes #230 closes #161
1 parent fe9ab9c commit 5568436

File tree

68 files changed

+341
-210
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+341
-210
lines changed

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Obj/
3535
.vs/
3636

3737
/wwwroot/dist/
38-
/Client/dist/
38+
/ClientApp/dist/
3939

4040
# MSTest test Results
4141
[Tt]est[Rr]esult*/
@@ -187,6 +187,7 @@ BundleArtifacts/
187187
!*.[Cc]ache/
188188

189189
# Others
190+
*.db
190191
ClientBin/
191192
~$*
192193
*~
@@ -259,3 +260,6 @@ _Pvt_Extensions
259260

260261
# Jest Code Coverage report
261262
coverage/
263+
264+
.DS_Store
265+
package-lock.json

.vscode/launch.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"type": "coreclr",
2121
"request": "launch",
2222
"preLaunchTask": "build",
23-
"program": "${workspaceRoot}/bin/Debug/netcoreapp1.1/Asp2017.dll",
23+
"program": "${workspaceRoot}/bin/Debug/netcoreapp2.0/Asp2017.dll",
2424
"args": [],
2525
"cwd": "${workspaceRoot}",
2626
"stopAtEntry": false,
@@ -51,7 +51,7 @@
5151
"type": "coreclr",
5252
"request": "launch",
5353
"preLaunchTask": "build",
54-
"program": "${workspaceRoot}/bin/Debug/netcoreapp1.1/Asp2017.dll",
54+
"program": "${workspaceRoot}/bin/Debug/netcoreapp2.0/Asp2017.dll",
5555
"args": [],
5656
"cwd": "${workspaceRoot}",
5757
"stopAtEntry": false,
@@ -82,7 +82,7 @@
8282
"type": "coreclr",
8383
"request": "launch",
8484
"preLaunchTask": "build",
85-
"program": "${workspaceRoot}/bin/Debug/netcoreapp1.1/Asp2017.dll",
85+
"program": "${workspaceRoot}/bin/Debug/netcoreapp2.0/Asp2017.dll",
8686
"args": [],
8787
"cwd": "${workspaceRoot}",
8888
"stopAtEntry": false,

Asp2017.csproj

+42-25
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,68 @@
11
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
2+
23
<PropertyGroup>
3-
<TargetFramework>netcoreapp2.0</TargetFramework>
4+
<TargetFramework Condition="'$(TargetFrameworkOverride)' == ''">netcoreapp2.0</TargetFramework>
5+
<TargetFramework Condition="'$(TargetFrameworkOverride)' != ''">TargetFrameworkOverride</TargetFramework>
46
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
7+
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
58
<IsPackable>false</IsPackable>
69
</PropertyGroup>
7-
<ItemGroup>
8-
<!-- New Meta Package has SpaServices in It -->
10+
11+
<ItemGroup Condition="'$(TargetFrameworkOverride)' == ''">
912
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
13+
</ItemGroup>
14+
<ItemGroup Condition="'$(TargetFrameworkOverride)' != ''">
15+
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" />
16+
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" />
17+
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="2.0.0" />
18+
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.0" />
19+
</ItemGroup>
20+
<ItemGroup>
1021
<PackageReference Include="NETStandard.Library" Version="2.0.0" />
1122
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.0" />
1223
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.0.0" />
1324
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
1425
</ItemGroup>
15-
<ItemGroup>
16-
<!-- Files not to show in IDE -->
17-
<None Remove="yarn.lock" />
18-
<Content Remove="wwwroot\dist\**" />
19-
<None Remove="Client\dist\**" />
20-
<Content Remove="coverage\**" />
2126

22-
<!-- Files not to publish (note that the 'dist' subfolders are re-added below) -->
23-
<Content Remove="Client\**" />
27+
<ItemGroup>
28+
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
2429
</ItemGroup>
30+
2531
<ItemGroup>
26-
<Content Include="Client\tsconfig.browser.json" />
27-
<Content Include="Client\tsconfig.server.aot.json" />
28-
<Content Include="Client\tsconfig.server.json" />
32+
<!-- Files not to publish (note that the 'dist' subfolders are re-added below) -->
33+
<Content Remove="ClientApp\**" />
2934
</ItemGroup>
30-
<Target Name="RunWebpack" AfterTargets="ComputeFilesToPublish">
35+
36+
<!--/-:cnd:noEmit -->
37+
<Target Name="DebugRunWebpack" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('wwwroot\dist') ">
38+
<!-- Ensure Node.js is installed -->
39+
<Exec Command="node --version" ContinueOnError="true">
40+
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
41+
</Exec>
42+
<Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
43+
44+
<!-- In development, the dist files won't exist on the first run or when cloning to
45+
a different machine, so rebuild them if not already present. -->
46+
<Message Importance="high" Text="Performing first-run Webpack build..." />
47+
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js" />
48+
<Exec Command="node node_modules/webpack/bin/webpack.js" />
49+
</Target>
50+
<!--/+:cnd:noEmit -->
51+
52+
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
3153
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
3254
<Exec Command="npm install" />
33-
<Exec Command="node node_modules/webpack/bin/webpack.js --env.aot --env.client" />
34-
<Exec Command="node node_modules/webpack/bin/webpack.js --env.aot --env.server" />
55+
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" />
56+
<Exec Command="node node_modules/webpack/bin/webpack.js --env.prod" />
57+
3558
<!-- Include the newly-built files in the publish output -->
3659
<ItemGroup>
37-
<DistFiles Include="wwwroot\dist\**; Client\dist\**" />
60+
<DistFiles Include="wwwroot\dist\**; ClientApp\dist\**" />
3861
<ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
3962
<RelativePath>%(DistFiles.Identity)</RelativePath>
4063
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
4164
</ResolvedFileToPublish>
4265
</ItemGroup>
4366
</Target>
44-
<Target Name="CleanDist" AfterTargets="Clean">
45-
<ItemGroup>
46-
<FilesToDelete Include="Client\dist\**; wwwroot\dist\**" />
47-
</ItemGroup>
48-
<Delete Files="@(FilesToDelete)" />
49-
<RemoveDir Directories="Client\dist; wwwroot\dist" />
50-
</Target>
67+
5168
</Project>

Client/main.server.aot.ts

-41
This file was deleted.

Client/tsconfig.browser.json

-9
This file was deleted.

Client/tsconfig.server.aot.json

-8
This file was deleted.

Client/tsconfig.server.json

-9
This file was deleted.

Client/app/app.component.html renamed to ClientApp/app/app.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
</div>
44
<div class="col-sm-9 body-content">
55
<router-outlet></router-outlet>
6-
</div>
6+
</div>
File renamed without changes.
File renamed without changes.

Client/app/browser-app.module.ts renamed to ClientApp/app/app.module.browser.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
66
import { SignalRModule, SignalRConfiguration } from 'ng2-signalr';
77

88
import { ORIGIN_URL } from './shared/constants/baseurl.constants';
9-
import { AppModule } from './app.module';
9+
import { AppModuleShared } from './app.module';
1010
import { AppComponent } from './app.component';
1111
import { REQUEST } from './shared/constants/request';
1212
import { BrowserTransferStateModule } from '../modules/transfer-state/browser-transfer-state.module';
@@ -41,7 +41,7 @@ export function getRequest() {
4141
BrowserTransferStateModule,
4242

4343
// Our Common AppModule
44-
AppModule,
44+
AppModuleShared,
4545

4646
SignalRModule.forRoot(createConfig)
4747
],
@@ -58,5 +58,4 @@ export function getRequest() {
5858
}
5959
]
6060
})
61-
export class BrowserAppModule {
62-
}
61+
export class AppModule { }

Client/app/server-app.module.ts renamed to ClientApp/app/app.module.server.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ServerModule } from '@angular/platform-server';
33
import { BrowserModule } from '@angular/platform-browser';
44
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
55

6-
import { AppModule } from './app.module';
6+
import { AppModuleShared } from './app.module';
77
import { AppComponent } from './app.component';
88
import { ServerTransferStateModule } from '../modules/transfer-state/server-transfer-state.module';
99
import { TransferState } from '../modules/transfer-state/transfer-state';
@@ -20,10 +20,10 @@ import { TransferState } from '../modules/transfer-state/transfer-state';
2020
ServerTransferStateModule,
2121

2222
// Our Common AppModule
23-
AppModule
23+
AppModuleShared
2424
]
2525
})
26-
export class ServerAppModule {
26+
export class AppModule {
2727

2828
constructor(private transferState: TransferState) { }
2929

Client/app/app.module.ts renamed to ClientApp/app/app.module.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { NgModule, Inject } from '@angular/core';
2-
import { RouterModule } from '@angular/router';
2+
import { RouterModule, PreloadAllModules } from '@angular/router';
33
import { CommonModule, APP_BASE_HREF } from '@angular/common';
44
import { HttpModule, Http } from '@angular/http';
55
import { FormsModule } from '@angular/forms';
@@ -134,9 +134,9 @@ export function createTranslateLoader(http: Http, baseHref) {
134134
]
135135
}
136136
},
137-
137+
138138
{ path: 'lazy', loadChildren: './containers/lazy/lazy.module#LazyModule'},
139-
139+
140140
{
141141
path: '**', component: NotFoundComponent,
142142
data: {
@@ -148,7 +148,12 @@ export function createTranslateLoader(http: Http, baseHref) {
148148
]
149149
}
150150
}
151-
])
151+
], {
152+
// Router options
153+
useHash: false,
154+
preloadingStrategy: PreloadAllModules,
155+
initialNavigation: 'enabled'
156+
})
152157
],
153158
providers: [
154159
LinkService,
@@ -157,5 +162,5 @@ export function createTranslateLoader(http: Http, baseHref) {
157162
TranslateModule
158163
]
159164
})
160-
export class AppModule {
165+
export class AppModuleShared {
161166
}

Client/app/containers/chat/chat.component.ts renamed to ClientApp/app/containers/chat/chat.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class ChatMessage {
1111
@Component({
1212
selector: 'chat',
1313
templateUrl: './chat.component.html',
14-
styleUrls: ['./chat.component.css']
14+
styleUrls: ['./chat.component.scss']
1515
})
1616
export class ChatComponent implements OnInit {
1717

Client/app/containers/home/home.component.html renamed to ClientApp/app/containers/home/home.component.html

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
<h1>
2-
{{ title }}</h1>
1+
<h1>{{ title }}</h1>
32

43
<blockquote>
54
<strong>Enjoy the latest features from .NET Core & Angular 4.0!</strong>
65
<br> For more info check the repo here: <a href="https://github.com/MarkPieszak/aspnetcore-angular2-universal">AspNetCore-Angular2-Universal repo</a>
7-
86
<br><br>
97
</blockquote>
108

11-
129
<div class="row">
1310
<div class="col-lg-6">
1411
<h2>{{ 'HOME_FEATURE_LIST_TITLE' | translate }} </h2>
1512
<ul>
16-
<li>ASP.NET Core 1.1 :: ( Visual Studio 2017 )</li>
13+
<li>ASP.NET Core 2.0 :: ( Visual Studio 2017 )</li>
1714
<li>
1815
Angular 4.* front-end UI framework
1916
<ul>
20-
<li>Angular **platform-server** (Universal moved into Core here) - server-side rendering for SEO, deep-linking, and
17+
<li>Angular **platform-server** (aka: Universal) - server-side rendering for SEO, deep-linking, and
2118
incredible performance.</li>
2219
<!--<li>HMR State Management - Don't lose your applications state during HMR!</li>-->
2320
<li>AoT (Ahead-of-time) production compilation for even faster Prod builds.</li>
@@ -33,7 +30,7 @@ <h2>{{ 'HOME_FEATURE_LIST_TITLE' | translate }} </h2>
3330
</ul>-->
3431
</li>
3532
<li>
36-
Webpack 2
33+
Webpack
3734
<ul>
3835
<!--<li>TS2 aware path support</li>-->
3936
<li>Hot Module Reloading/Replacement for an amazing development experience.</li>
@@ -65,11 +62,11 @@ <h2>{{ 'HOME_ISSUES_TITLE' | translate }}</h2>
6562
<h2> {{ 'SWITCH_LANGUAGE' | translate }}</h2>
6663

6764
<button class="btn btn-default" (click)="setLanguage('en')">
68-
<span class="flag-icon flag-icon-us"></span> {{ 'ENGLISH' | translate }}
65+
<span class="flag-icon flag-icon-us"></span> {{ 'ENGLISH' | translate }}
6966
</button>
7067

7168
<button class="btn btn-default" (click)="setLanguage('no')">
72-
<span class="flag-icon flag-icon-no"></span> {{ 'NORWEGIAN' | translate }}
69+
<span class="flag-icon flag-icon-no"></span> {{ 'NORWEGIAN' | translate }}
7370
</button>
7471

7572
</div>

Client/app/containers/home/home.component.ts renamed to ClientApp/app/containers/home/home.component.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import { TranslateService } from '@ngx-translate/core';
88
})
99
export class HomeComponent implements OnInit {
1010

11-
title: string = 'Angular 4.0 Universal & ASP.NET Core advanced starter-kit';
11+
title: string = 'Angular 4.0 Universal & ASP.NET Core 2.0 advanced starter-kit';
1212

1313
// Use "constructor"s only for dependency injection
14-
constructor(public translate: TranslateService) { }
14+
constructor(
15+
public translate: TranslateService
16+
) { }
1517

1618
// Here you want to handle anything with @Input()'s @Output()'s
1719
// Data retrieval / etc - this is when the Component is "ready" and wired up
File renamed without changes.

Client/main.browser.ts renamed to ClientApp/boot.browser.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import './polyfills/browser.polyfills';
22
import { enableProdMode } from '@angular/core';
33
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
4-
import { BrowserAppModule } from './app/browser-app.module';
4+
import { AppModule } from './app/app.module.browser';
55

66
const rootElemTagName = 'app'; // Update this if you change your root component selector
77

@@ -15,4 +15,4 @@ if (module['hot']) {
1515
enableProdMode();
1616
}
1717

18-
const modulePromise = platformBrowserDynamic().bootstrapModule(BrowserAppModule);
18+
const modulePromise = platformBrowserDynamic().bootstrapModule(AppModule);

0 commit comments

Comments
 (0)