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
This commit is contained in:

committed by
Matias Niemelä

parent
cda9248b33
commit
86104b82b8
@ -12,7 +12,7 @@ import {NG_FACTORY_DEF} from '../../render3/fields';
|
||||
import {getClosureSafeProperty} from '../../util/property';
|
||||
import {resolveForwardRef} from '../forward_ref';
|
||||
import {Injectable} from '../injectable';
|
||||
import {NG_INJECTABLE_DEF} from '../interface/defs';
|
||||
import {NG_PROV_DEF} from '../interface/defs';
|
||||
import {ClassSansProvider, ExistingSansProvider, FactorySansProvider, ValueProvider, ValueSansProvider} from '../interface/provider';
|
||||
|
||||
import {angularCoreDiEnv} from './environment';
|
||||
@ -22,19 +22,19 @@ import {convertDependencies, reflectDependencies} from './util';
|
||||
|
||||
/**
|
||||
* Compile an Angular injectable according to its `Injectable` metadata, and patch the resulting
|
||||
* `ngInjectableDef` onto the injectable type.
|
||||
* injectable def (`ɵprov`) onto the injectable type.
|
||||
*/
|
||||
export function compileInjectable(type: Type<any>, srcMeta?: Injectable): void {
|
||||
let ngInjectableDef: any = null;
|
||||
let ngFactoryDef: any = null;
|
||||
|
||||
// if NG_INJECTABLE_DEF is already defined on this class then don't overwrite it
|
||||
if (!type.hasOwnProperty(NG_INJECTABLE_DEF)) {
|
||||
Object.defineProperty(type, NG_INJECTABLE_DEF, {
|
||||
// if NG_PROV_DEF is already defined on this class then don't overwrite it
|
||||
if (!type.hasOwnProperty(NG_PROV_DEF)) {
|
||||
Object.defineProperty(type, NG_PROV_DEF, {
|
||||
get: () => {
|
||||
if (ngInjectableDef === null) {
|
||||
ngInjectableDef = getCompilerFacade().compileInjectable(
|
||||
angularCoreDiEnv, `ng:///${type.name}/ngInjectableDef.js`,
|
||||
angularCoreDiEnv, `ng:///${type.name}/ɵprov.js`,
|
||||
getInjectableMetadata(type, srcMeta));
|
||||
}
|
||||
return ngInjectableDef;
|
||||
|
Reference in New Issue
Block a user