refactor(core): rename ngInjectorDef to ɵinj (#33151)
Injector 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 ngInjectorDef to 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
3e14c2d02c
commit
cda9248b33
@ -73,7 +73,7 @@ class:
|
||||
| `hostListeners` | `ɵdir` |
|
||||
| `hostProperties` | `ɵdir` |
|
||||
| `hostAttributes` | `ɵdir` |
|
||||
| `providers` | `ngInjectorDef` |
|
||||
| `providers` | `ɵinj` |
|
||||
| `viewProviders` | `ɵcmp` |
|
||||
| `queries` | `ɵdir` |
|
||||
| `guards` | not used |
|
||||
@ -282,7 +282,7 @@ export class MyPipe {
|
||||
The metadata for a module is transformed by:
|
||||
|
||||
1. Remove the `@NgModule` directive.
|
||||
2. Add `"ngInjectorDef": {}` static field.
|
||||
2. Add `"ɵinj": {}` static field.
|
||||
3. Add `"ngModuleScope": <module-scope>` static field.
|
||||
|
||||
The scope value is an array the following type:
|
||||
@ -329,7 +329,7 @@ export class MyModule {}
|
||||
*my.module.js*
|
||||
```js
|
||||
export class MyModule {
|
||||
static ngInjectorDef = ɵɵdefineInjector(...);
|
||||
static ɵinj = ɵɵdefineInjector(...);
|
||||
}
|
||||
```
|
||||
|
||||
@ -342,7 +342,7 @@ export class MyModule {
|
||||
"MyModule": {
|
||||
"__symbolic": "class",
|
||||
"statics": {
|
||||
"ngInjectorDef": {},
|
||||
"ɵinj": {},
|
||||
"ngModuleScope": [
|
||||
{
|
||||
"type": {
|
||||
@ -389,7 +389,7 @@ manually written as:
|
||||
|
||||
```ts
|
||||
export class MyModule {
|
||||
static ngInjectorDef = ɵɵdefineInjector({
|
||||
static ɵinj = ɵɵdefineInjector({
|
||||
providers: [{
|
||||
provide: Service, useClass: ServiceImpl
|
||||
}],
|
||||
@ -440,7 +440,7 @@ properties by including a `// @__BUILD_OPTIMIZER_REMOVE_` comment:
|
||||
|
||||
```ts
|
||||
export class MyModule {
|
||||
static ngInjectorDef = ɵɵdefineInjector({
|
||||
static ɵinj = ɵɵdefineInjector({
|
||||
providers: [{
|
||||
provide: Service, useClass: ServiceImpl
|
||||
}],
|
||||
|
@ -204,7 +204,7 @@ export class ConstantPool {
|
||||
case DefinitionKind.Directive:
|
||||
return 'ɵdir';
|
||||
case DefinitionKind.Injector:
|
||||
return 'ngInjectorDef';
|
||||
return 'ɵinj';
|
||||
case DefinitionKind.Pipe:
|
||||
return 'ɵpipe';
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ export function compileNgModuleFromRender2(
|
||||
/* name */ className,
|
||||
/* parent */ null,
|
||||
/* fields */[new o.ClassField(
|
||||
/* name */ 'ngInjectorDef',
|
||||
/* name */ 'ɵinj',
|
||||
/* type */ o.INFERRED_TYPE,
|
||||
/* modifiers */[o.StmtModifier.Static],
|
||||
/* initializer */ injectorDef, )],
|
||||
|
Reference in New Issue
Block a user