Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { AppModule } from './app/app.browser.module';
// Enable either Hot Module Reloading or production mode
// Add Redux HMR state management here
/* tslint:disable */
if (module['hot']) {
module['hot'].accept();
module['hot'].dispose(() => { platform.destroy(); });
} else {
enableProdMode();
}
/* tslint:enable */
// Boot the application, either now or when the DOM content is loaded
const platform = platformUniversalDynamic();
const bootApplication = () => { platform.bootstrapModule(AppModule); };
if (document.readyState === 'complete') {
bootApplication();
} else {
document.addEventListener('DOMContentLoaded', bootApplication);
}
// Enable either Hot Module Reloading or production mode
if (module['hot']) {
module['hot'].accept();
module['hot'].dispose(() => {
// Before restarting the app, we create a new root element and dispose the old one
const oldRootElem = document.querySelector(rootElemTagName);
const newRootElem = document.createElement(rootElemTagName);
oldRootElem.parentNode.insertBefore(newRootElem, oldRootElem);
platform.destroy();
});
} else {
enableProdMode();
}
// Boot the application, either now or when the DOM content is loaded
const platform = platformUniversalDynamic();
const bootApplication = () => { platform.bootstrapModule(AppModule); };
if (document.readyState === 'complete') {
bootApplication();
} else {
document.addEventListener('DOMContentLoaded', bootApplication);
}
// the polyfills must be the first thing imported
import 'angular2-universal-polyfills';
// Angular 2
import { enableProdMode} from '@angular/core';
import { platformUniversalDynamic } from 'angular2-universal';
// enable prod for faster renders
enableProdMode();
import { MainModule } from './app/app.browser.module';
const platformRef = platformUniversalDynamic();
// on document ready bootstrap Angular 2
document.addEventListener('DOMContentLoaded', () => {
platformRef.bootstrapModule(MainModule)//,
});
export function main() {
return platformUniversalDynamic().bootstrapModule(AppModule)
.catch(err => console.log(err));
}
import './polyfills.browser.aot';
import './rxjs.imports';
import { enableProdMode } from '@angular/core';
import { platformUniversalDynamic } from 'angular2-universal';
import { AppModuleNgFactory } from '../compiled/src/app/app.module.universal.browser.ngfactory';
if ('production' === ENV) {
enableProdMode();
}
export const platform = platformUniversalDynamic();
export function main() {
return platform.bootstrapModuleFactory(AppModuleNgFactory)
.catch(err => console.log(err));
}
export function bootstrapDomReady() {
document.addEventListener('DOMContentLoaded', main);
}
bootstrapDomReady();
compiler.plugin('emit', (_compilation: any, _callback: any) => {
this.platformRef = this.platformRef || platformUniversalDynamic();
this._options.document = this._options.document || _compilation.assets[this._options.documentPath].source();
const zone = Zone.current.fork({
name: 'UNIVERSAL prerender',
properties: this._options
});
zone.run(() => (this.platformRef.serializeModule(this._options.ngModule, this._options))
.then((html: any) => {
if (typeof html !== 'string' || this._options.cancel) {
_compilation.assets[this._options.documentPath] = {
source: () => this._options.document,
size: () => this._options.document.length
};
return _callback();
}
_compilation.assets[this._options.documentPath] = {
source: () => html,
import 'angular2-universal-polyfills';
import { platformUniversalDynamic } from 'angular2-universal';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';
const platform = platformUniversalDynamic();
if (process.env.ENV === 'production') {
enableProdMode();
}
platform.bootstrapModule(AppModule);