Skip to content

Commit 3dca9d5

Browse files
committed
feat(core): enable dev mode by default
BREAKING CHANGE Before Previously Angular would run in dev prod mode by default, and you could enable the dev mode by calling enableDevMode. After Now, Angular runs in the dev mode by default, and you can enable the prod mode by calling enableProdMode.
1 parent de996ec commit 3dca9d5

File tree

20 files changed

+77
-40
lines changed

20 files changed

+77
-40
lines changed

modules/angular2/core.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ library angular2.core;
22

33
export './src/core/metadata.dart';
44
export './src/core/util.dart';
5-
export './src/core/dev_mode.dart';
5+
export 'package:angular2/src/facade/lang.dart' show enableProdMode;
66
export './src/core/di.dart' hide ForwardRefFn, resolveForwardRef, forwardRef;
77
export './src/facade/facade.dart';
88
export './src/core/application_ref.dart' show platform, createNgZone, PlatformRef, ApplicationRef;

modules/angular2/core.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
*/
66
export * from './src/core/metadata';
77
export * from './src/core/util';
8-
export * from './src/core/dev_mode';
8+
export * from './src/core/prod_mode';
99
export * from './src/core/di';
1010
export * from './src/facade/facade';
11+
export {enableProdMode} from 'angular2/src/facade/lang';
1112
export {platform, createNgZone, PlatformRef, ApplicationRef} from './src/core/application_ref';
1213
export {
1314
APP_ID,
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// #docregion enableDevMode
2-
import {enableDevMode} from 'angular2/core';
1+
// #docregion enableProdMode
2+
import {enableProdMode} from 'angular2/core';
33
import {bootstrap} from 'angular2/bootstrap';
44
import {MyComponent} from 'my_component';
55

6-
enableDevMode();
6+
enableProdMode();
77
bootstrap(MyComponent);
88
// #enddocregion

modules/angular2/manual_typings/globals-es6.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ interface BrowserNodeGlobal {
3030
zone: Zone;
3131
getAngularTestability: Function;
3232
getAllAngularTestabilities: Function;
33-
angularDevMode: boolean;
3433
setTimeout: Function;
3534
clearTimeout: Function;
3635
setInterval: Function;

modules/angular2/src/core/application_ref.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ import {
3434
unimplemented
3535
} from 'angular2/src/facade/exceptions';
3636
import {internalView} from 'angular2/src/core/linker/view_ref';
37+
import {Console} from 'angular2/src/core/console';
3738
import {wtfLeave, wtfCreateScope, WtfScopeFn} from './profile/profile';
3839
import {ChangeDetectorRef} from 'angular2/src/core/change_detection/change_detector_ref';
39-
import {lockDevMode} from 'angular2/src/facade/lang';
40+
import {lockMode} from 'angular2/src/facade/lang';
4041

4142
/**
4243
* Construct providers specific to an individual root component.
@@ -98,7 +99,7 @@ var _platformProviders: any[];
9899
* provides, Angular will throw an exception.
99100
*/
100101
export function platform(providers?: Array<Type | Provider | any[]>): PlatformRef {
101-
lockDevMode();
102+
lockMode();
102103
if (isPresent(_platform)) {
103104
if (ListWrapper.equals(_platformProviders, providers)) {
104105
return _platform;
@@ -425,7 +426,15 @@ export class ApplicationRef_ extends ApplicationRef {
425426
completer.reject(e, e.stack);
426427
}
427428
});
428-
return completer.promise;
429+
return completer.promise.then(_ => {
430+
let c = this._injector.get(Console);
431+
let modeDescription =
432+
assertionsEnabled() ?
433+
"in the development mode. Call enableProdMode() to enable the production mode." :
434+
"in the production mode. Call enableDevMode() to enable the development mode.";
435+
c.log(`Angular 2 is running ${modeDescription}`);
436+
return _;
437+
});
429438
}
430439

431440
/** @internal */
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {Injectable} from 'angular2/src/core/di';
2+
import {print} from 'angular2/src/facade/lang';
3+
4+
@Injectable()
5+
export class Console {
6+
log(message: string): void { print(message); }
7+
}

modules/angular2/src/core/dev_mode.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

modules/angular2/src/core/platform_common_providers.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Type, isBlank, isPresent, assertionsEnabled, CONST_EXPR} from 'angular2/src/facade/lang';
22
import {provide, Provider, Injector, OpaqueToken} from 'angular2/src/core/di';
3+
import {Console} from 'angular2/src/core/console';
34
import {Reflector, reflector} from './reflection/reflection';
45
import {TestabilityRegistry} from 'angular2/src/core/testability/testability';
56

@@ -10,5 +11,5 @@ function _reflector(): Reflector {
1011
/**
1112
* A default set of providers which should be included in any Angular platform.
1213
*/
13-
export const PLATFORM_COMMON_PROVIDERS: Array<Type | Provider | any[]> =
14-
CONST_EXPR([new Provider(Reflector, {useFactory: _reflector, deps: []}), TestabilityRegistry]);
14+
export const PLATFORM_COMMON_PROVIDERS: Array<Type | Provider | any[]> = CONST_EXPR(
15+
[new Provider(Reflector, {useFactory: _reflector, deps: []}), TestabilityRegistry, Console]);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {enableProdMode} from 'angular2/src/facade/lang';

0 commit comments

Comments
 (0)