]>
Commit | Line | Data |
---|---|---|
1 | ||
2 | // Angular 2 | |
3 | // rc2 workaround | |
4 | import { enableDebugTools, disableDebugTools } from '@angular/platform-browser'; | |
5 | import { enableProdMode, ApplicationRef } from '@angular/core'; | |
6 | // Environment Providers | |
7 | let PROVIDERS: any[] = [ | |
8 | // common env directives | |
9 | ]; | |
10 | ||
11 | // Angular debug tools in the dev console | |
12 | // https://github.com/angular/angular/blob/86405345b781a9dc2438c0fbe3e9409245647019/TOOLS_JS.md | |
13 | let _decorateModuleRef = function identity<T>(value: T): T { return value; }; | |
14 | ||
15 | if ('production' === ENV) { | |
16 | enableProdMode(); | |
17 | ||
18 | // Production | |
19 | _decorateModuleRef = (modRef: any) => { | |
20 | disableDebugTools(); | |
21 | ||
22 | return modRef; | |
23 | }; | |
24 | ||
25 | PROVIDERS = [ | |
26 | ...PROVIDERS, | |
27 | // custom providers in production | |
28 | ]; | |
29 | ||
30 | } else { | |
31 | ||
32 | _decorateModuleRef = (modRef: any) => { | |
33 | const appRef = modRef.injector.get(ApplicationRef); | |
34 | const cmpRef = appRef.components[0]; | |
35 | ||
36 | let _ng = (<any>window).ng; | |
37 | enableDebugTools(cmpRef); | |
38 | (<any>window).ng.probe = _ng.probe; | |
39 | (<any>window).ng.coreTokens = _ng.coreTokens; | |
40 | return modRef; | |
41 | }; | |
42 | ||
43 | // Development | |
44 | PROVIDERS = [ | |
45 | ...PROVIDERS, | |
46 | // custom providers in development | |
47 | ]; | |
48 | ||
49 | } | |
50 | ||
51 | export const decorateModuleRef = _decorateModuleRef; | |
52 | ||
53 | export const ENV_PROVIDERS = [ | |
54 | ...PROVIDERS | |
55 | ]; |