Skip to content

Commit 436c33d

Browse files
committed
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...
1 parent fe9ab9c commit 436c33d

Some content is hidden

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

65 files changed

+7263
-162
lines changed

Asp2017.csproj

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
<Target Name="RunWebpack" AfterTargets="ComputeFilesToPublish">
3131
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
3232
<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" />
33+
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" />
34+
<Exec Command="node node_modules/webpack/bin/webpack.js --env.prod" />
3535
<!-- Include the newly-built files in the publish output -->
3636
<ItemGroup>
37-
<DistFiles Include="wwwroot\dist\**; Client\dist\**" />
37+
<DistFiles Include="wwwroot\dist\**; ClientApp\dist\**" />
3838
<ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
3939
<RelativePath>%(DistFiles.Identity)</RelativePath>
4040
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
@@ -43,9 +43,9 @@
4343
</Target>
4444
<Target Name="CleanDist" AfterTargets="Clean">
4545
<ItemGroup>
46-
<FilesToDelete Include="Client\dist\**; wwwroot\dist\**" />
46+
<FilesToDelete Include="ClientApp\dist\**; wwwroot\dist\**" />
4747
</ItemGroup>
4848
<Delete Files="@(FilesToDelete)" />
49-
<RemoveDir Directories="Client\dist; wwwroot\dist" />
49+
<RemoveDir Directories="ClientApp\dist; wwwroot\dist" />
5050
</Target>
5151
</Project>

Client/app/app.component.html

-6
This file was deleted.

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.
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
}
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);

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { createServerRenderer, RenderResult } from 'aspnet-prerendering';
77

88
import { ORIGIN_URL } from './app/shared/constants/baseurl.constants';
99
// Grab the (Node) server-specific NgModule
10-
import { ServerAppModule } from './app/server-app.module';
10+
import { AppModule } from './app/app.module.server';
1111
// Temporary * the engine will be on npm soon (`@universal/ng-aspnetcore-engine`)
1212
import { ngAspnetCoreEngine, IEngineOptions, createTransferScript } from './polyfills/temporary-aspnetcore-engine';
1313

@@ -18,7 +18,7 @@ export default createServerRenderer((params: BootFuncParams) => {
1818
// Platform-server provider configuration
1919
const setupOptions: IEngineOptions = {
2020
appSelector: '<app></app>',
21-
ngModule: ServerAppModule,
21+
ngModule: AppModule,
2222
request: params,
2323
providers: [
2424
// Optional - Any other Server providers you want to pass (remember you'll have to provide them for the Browser as well)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Server/Controllers/HomeController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public async Task<IActionResult> Index()
4343
"/",
4444
nodeServices,
4545
cancelToken,
46-
new JavaScriptModuleExport(applicationBasePath + "/Client/dist/main-server"),
46+
new JavaScriptModuleExport(applicationBasePath + "/ClientApp/dist/main-server"),
4747
unencodedAbsoluteUrl,
4848
unencodedPathAndQuery,
4949
transferData, // Our simplified Request object & any other CustommData you want to send!

Views/Home/Index.cshtml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@Html.Raw(ViewData["SpaHtml"])
22

3+
<script src="~/dist/vendor.js" asp-append-version="true"></script>
34
@section scripts {
45
<!-- Our webpack bundle -->
5-
<script src="~/dist/main-browser.js" asp-append-version="true"></script>
6+
<script src="~/dist/main-client.js" asp-append-version="true"></script>
67
}

Views/Shared/_Layout.cshtml

+22-21
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
<!DOCTYPE html>
22
<html>
3-
<head>
4-
<base href="/" />
5-
<title>@ViewData["Title"]</title>
3+
<head>
4+
<base href="/" />
5+
<title>@ViewData["Title"]</title>
66

7-
<meta charset="utf-8" />
8-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
9-
@Html.Raw(ViewData["Meta"])
10-
@Html.Raw(ViewData["Links"])
7+
<meta charset="utf-8" />
8+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
9+
@Html.Raw(ViewData["Meta"])
10+
@Html.Raw(ViewData["Links"])
1111

12-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/0.8.2/css/flag-icon.min.css" />
12+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flag-icon-css/0.8.2/css/flag-icon.min.css" />
13+
<link rel="stylesheet" href="~/dist/vendor.css" asp-append-version="true" />
1314

14-
@Html.Raw(ViewData["Styles"])
15+
@Html.Raw(ViewData["Styles"])
1516

16-
</head>
17-
<body>
18-
@RenderBody()
17+
</head>
18+
<body>
19+
@RenderBody()
1920

20-
<!-- remove if you're not going to use SignalR -->
21-
<script src="https://code.jquery.com/jquery-2.2.4.min.js"
22-
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
23-
crossorigin="anonymous"></script>
21+
<!-- remove if you're not going to use SignalR -->
22+
<script src="https://code.jquery.com/jquery-2.2.4.min.js"
23+
integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
24+
crossorigin="anonymous"></script>
2425

25-
<script src="http://ajax.aspnetcdn.com/ajax/signalr/jquery.signalr-2.2.0.min.js"></script>
26+
<script src="http://ajax.aspnetcdn.com/ajax/signalr/jquery.signalr-2.2.0.min.js"></script>
2627

27-
<!-- Here we're passing down any data to be used by grabbed and parsed by Angular -->
28-
@Html.Raw(ViewData["TransferData"])
28+
<!-- Here we're passing down any data to be used by grabbed and parsed by Angular -->
29+
@Html.Raw(ViewData["TransferData"])
2930

30-
@RenderSection("scripts", required: false)
31-
</body>
31+
@RenderSection("scripts", required: false)
32+
</body>
3233
</html>

0 commit comments

Comments
 (0)