Skip to content

Commit

Permalink
feat: add enableProdMode() in RenderNgAppService when NODE_ENV !== 'd…
Browse files Browse the repository at this point in the history
…evelopment'
  • Loading branch information
ThibaudAV committed Nov 24, 2020
1 parent 5173358 commit 1c04762
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/angular/src/client/preview/angular/RenderNgAppService.ts
@@ -1,5 +1,5 @@
/* eslint-disable no-undef */
import { NgModule, NO_ERRORS_SCHEMA, Type } from '@angular/core';
import { enableProdMode, NgModule, NO_ERRORS_SCHEMA, PlatformRef, Type } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

Expand Down Expand Up @@ -28,7 +28,7 @@ export class RenderNgAppService {

public static SELECTOR_STORYBOOK_WRAPPER = 'storybook-wrapper';

private platform = platformBrowserDynamic();
private platform: PlatformRef;

private staticRoot = document.getElementById('root');

Expand All @@ -43,6 +43,15 @@ export class RenderNgAppService {
this.staticRoot.innerHTML = '';
this.staticRoot.appendChild(storybookWrapperElement);

if (typeof NODE_ENV === 'string' && NODE_ENV !== 'development') {
try {
enableProdMode();
} catch (e) {
// eslint-disable-next-line no-console
console.debug(e);
}
}
// platform should be set after enableProdMode()
this.platform = platformBrowserDynamic();
}

Expand Down

0 comments on commit 1c04762

Please sign in to comment.