Skip to content

Commit

Permalink
fix(stark-core): refactor AbstractStarkMain to enable Angular prod mo…
Browse files Browse the repository at this point in the history
…de before bootstraping the app

ISSUES CLOSED: 506
  • Loading branch information
christophercr committed Jul 13, 2018
1 parent 34af0ae commit bb319fa
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/stark-core/src/common/bootstrap/abstract-stark-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { disableDebugTools, enableDebugTools } from "@angular/platform-browser";
import { createNewHosts } from "@angularclass/hmr";

import { StarkMain } from "./stark-main.intf";
import {StarkEnvironment} from "../environment";
import { StarkEnvironment } from "../environment";

/**
* Parent class for bootstrapping Stark applications.
Expand Down Expand Up @@ -99,6 +99,12 @@ NNNNNNNN NNNNNNNBBBBBBBBBBBBBBBBB BBBBBBBBBBBBBBBBB
We need great software developers like you! https://jobs.nbb.be
`);

if (ENV === "production") {
// IMPORTANT: the production mode should be enabled before bootstrapping the app
// otherwise an error is thrown: "Cannot enable prod mode after platform setup."
enableProdMode();
}

this.bootstrapDomReady();
}

Expand All @@ -109,7 +115,7 @@ We need great software developers like you! https://jobs.nbb.be
* @ignore
*/
protected bootstrapHmr: Function = (module: any, bootstrap: () => Promise<NgModuleRef<any>>) => {
if(ENV === "development") {
if (ENV === "development") {
console.log("Bootstrapping HMR");
let ngModule: NgModuleRef<any>;
module.hot.accept();
Expand Down Expand Up @@ -137,7 +143,6 @@ We need great software developers like you! https://jobs.nbb.be
// written like this because otherwise "this" will not be captured :)
if (this.environment.production) {
console.log("Customizing configuration for production!");
enableProdMode();
disableDebugTools();
} else {
console.log("Customizing configuration for development!");
Expand Down

0 comments on commit bb319fa

Please sign in to comment.