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