Skip to content

Commit 157b74a

Browse files
Update Angular2Spa and ReactReduxSpa to use aspnet-prerendering 2.0.0
1 parent 17f9ece commit 157b74a

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

templates/Angular2Spa/ClientApp/boot-server.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import 'angular2-universal-polyfills';
22
import 'zone.js';
3+
import { createServerRenderer, RenderResult } from 'aspnet-prerendering';
34
import { enableProdMode } from '@angular/core';
45
import { platformNodeDynamic } from 'angular2-universal';
56
import { AppModule } from './app/app.module';
67

78
enableProdMode();
89
const platform = platformNodeDynamic();
910

10-
export default function (params: any) : Promise<{ html: string, globals?: any }> {
11-
return new Promise((resolve, reject) => {
11+
export default createServerRenderer(params => {
12+
return new Promise<RenderResult>((resolve, reject) => {
1213
const requestZone = Zone.current.fork({
1314
name: 'angular-universal request',
1415
properties: {
@@ -29,4 +30,4 @@ export default function (params: any) : Promise<{ html: string, globals?: any }>
2930
resolve({ html: html });
3031
}, reject);
3132
});
32-
}
33+
});

templates/Angular2Spa/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"angular2-template-loader": "^0.6.0",
2020
"angular2-universal": "~2.0.11",
2121
"angular2-universal-polyfills": "~2.0.11",
22-
"aspnet-prerendering": "^1.0.7",
22+
"aspnet-prerendering": "^2.0.0",
2323
"aspnet-webpack": "^1.0.17",
2424
"bootstrap": "^3.3.7",
2525
"css": "^2.2.1",

templates/ReactReduxSpa/ClientApp/boot-server.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { Provider } from 'react-redux';
33
import { renderToString } from 'react-dom/server';
44
import { match, RouterContext } from 'react-router';
55
import createMemoryHistory from 'history/lib/createMemoryHistory';
6+
import { createServerRenderer, RenderResult } from 'aspnet-prerendering';
67
import routes from './routes';
78
import configureStore from './configureStore';
8-
type BootResult = { html?: string, globals?: { [key: string]: any }, redirectUrl?: string};
99

10-
export default function (params: any): Promise<{ html: string }> {
11-
return new Promise<BootResult>((resolve, reject) => {
10+
export default createServerRenderer(params => {
11+
return new Promise<RenderResult>((resolve, reject) => {
1212
// Match the incoming request against the list of client-side routes
1313
match({ routes, location: params.location }, (error, redirectLocation, renderProps: any) => {
1414
if (error) {
@@ -47,4 +47,4 @@ export default function (params: any): Promise<{ html: string }> {
4747
}, reject); // Also propagate any errors back into the host application
4848
});
4949
});
50-
}
50+
});

templates/ReactReduxSpa/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@types/webpack": "^1.12.35",
1515
"@types/webpack-env": "^1.12.1",
1616
"@types/whatwg-fetch": "0.0.28",
17-
"aspnet-prerendering": "^1.0.7",
17+
"aspnet-prerendering": "^2.0.0",
1818
"aspnet-webpack": "^1.0.17",
1919
"aspnet-webpack-react": "^1.0.2",
2020
"babel-core": "^6.5.2",

0 commit comments

Comments
 (0)