mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Update to angular2-universal 0.103.0 and amend boot-server.ts to fix "there can only be one platform" issue
This commit is contained in:
@@ -1,32 +1,33 @@
|
||||
import 'angular2-universal/polyfills';
|
||||
import * as ngCore from '@angular/core';
|
||||
import * as ngRouter from '@angular/router-deprecated';
|
||||
import * as ngUniversal from 'angular2-universal';
|
||||
import { BASE_URL, ORIGIN_URL, REQUEST_URL } from 'angular2-universal/common';
|
||||
import { App } from './components/app/app';
|
||||
|
||||
export default function (params: any): Promise<{ html: string, globals?: any }> {
|
||||
const serverBindings = [
|
||||
ngCore.provide(BASE_URL, { useValue: '/' }),
|
||||
ngCore.provide(ORIGIN_URL, { useValue: params.origin }),
|
||||
ngCore.provide(REQUEST_URL, { useValue: params.url }),
|
||||
...ngUniversal.NODE_PLATFORM_PIPES,
|
||||
...ngUniversal.NODE_ROUTER_PROVIDERS,
|
||||
...ngUniversal.NODE_HTTP_PROVIDERS,
|
||||
];
|
||||
const bootloader = ngUniversal.bootloader({
|
||||
async: true,
|
||||
preboot: false,
|
||||
platformProviders: [
|
||||
ngCore.provide(BASE_URL, { useValue: '/' })
|
||||
]
|
||||
});
|
||||
|
||||
let bootloader = ngUniversal.bootloader({
|
||||
export default function (params: any): Promise<{ html: string, globals?: any }> {
|
||||
const config: ngUniversal.AppConfig = {
|
||||
directives: [App],
|
||||
componentProviders: serverBindings,
|
||||
async: true,
|
||||
preboot: false,
|
||||
providers: [
|
||||
ngCore.provide(REQUEST_URL, { useValue: params.url }),
|
||||
ngCore.provide(ORIGIN_URL, { useValue: params.origin }),
|
||||
...ngUniversal.NODE_PLATFORM_PIPES,
|
||||
...ngUniversal.NODE_ROUTER_PROVIDERS,
|
||||
...ngUniversal.NODE_HTTP_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().then(html => {
|
||||
bootloader.dispose();
|
||||
return bootloader.serializeApplication(config).then(html => {
|
||||
return { html };
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
"@angular/platform-server": "2.0.0-rc.1",
|
||||
"@angular/router": "2.0.0-rc.1",
|
||||
"@angular/router-deprecated": "2.0.0-rc.1",
|
||||
"angular2-universal": "0.100.3",
|
||||
"angular2-universal": "0.103.0",
|
||||
"aspnet-prerendering": "^1.0.2",
|
||||
"aspnet-webpack": "^1.0.1",
|
||||
"css": "^2.2.1",
|
||||
|
||||
Reference in New Issue
Block a user