Kara Erickson 86104b82b8 refactor(core): rename ngInjectableDef to ɵprov (#33151)
Injectable defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
ngInjectableDef to "prov" (for "provider", since injector defs
are known as "inj"). This is because property names cannot
be minified by Uglify without turning on property mangling
(which most apps have turned off) and are thus size-sensitive.

PR Close #33151
2019-10-16 16:36:19 -04:00

40 lines
986 B
TypeScript

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {Injector, ɵcreateInjector as createInjector, ɵɵdefineInjectable, ɵɵdefineInjector} from '@angular/core';
export class RootService {
static ɵprov = ɵɵdefineInjectable({
token: RootService,
providedIn: 'root',
factory: () => new RootService(),
});
}
export class ScopedService {
static ɵprov = ɵɵdefineInjectable({
token: ScopedService,
providedIn: null,
factory: () => new ScopedService(),
});
doSomething(): void {
// tslint:disable-next-line:no-console
console.log('Ensure this isn\'t tree-shaken.');
}
}
export class DefinedInjector {
static ɵinj = ɵɵdefineInjector({
factory: () => new DefinedInjector(),
providers: [ScopedService],
});
}
export const INJECTOR = createInjector(DefinedInjector);