refactor(core): rename ngDirectiveDef to ɵdir (#33110)
Directive 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 ngDirectiveDef to dir. 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. Note that the other "defs" (ngFactoryDef, etc) will be prefixed and shortened in follow-up PRs, in an attempt to limit how large and conflict-y this change is. PR Close #33110
This commit is contained in:

committed by
Miško Hevery

parent
d8249d1230
commit
1a67d70bf8
@ -373,7 +373,7 @@ runInEachFileSystem(os => {
|
||||
const jsContents = env.getContents('test.js');
|
||||
expect(jsContents).toContain('TestBase.ngBaseDef = i0.ɵɵdefineBase');
|
||||
expect(jsContents).toContain('TestComponent.ɵcmp = i0.ɵɵdefineComponent');
|
||||
expect(jsContents).toContain('TestDirective.ngDirectiveDef = i0.ɵɵdefineDirective');
|
||||
expect(jsContents).toContain('TestDirective.ɵdir = i0.ɵɵdefineDirective');
|
||||
expect(jsContents).toContain('TestPipe.ngPipeDef = i0.ɵɵdefinePipe');
|
||||
expect(jsContents).toContain('TestInjectable.ngInjectableDef = i0.ɵɵdefineInjectable');
|
||||
expect(jsContents).toContain('MyModule.ngModuleDef = i0.ɵɵdefineNgModule');
|
||||
@ -1180,7 +1180,7 @@ runInEachFileSystem(os => {
|
||||
|
||||
// Validate that each class has the primary definition.
|
||||
expect(jsContents).toContain('TestCmp.ɵcmp =');
|
||||
expect(jsContents).toContain('TestDir.ngDirectiveDef =');
|
||||
expect(jsContents).toContain('TestDir.ɵdir =');
|
||||
expect(jsContents).toContain('TestPipe.ngPipeDef =');
|
||||
expect(jsContents).toContain('TestNgModule.ngModuleDef =');
|
||||
|
||||
@ -2946,7 +2946,7 @@ runInEachFileSystem(os => {
|
||||
import {ɵɵDirectiveDefWithMeta, ɵɵNgModuleDefWithMeta} from '@angular/core';
|
||||
|
||||
export declare class ExternalDir {
|
||||
static ngDirectiveDef: ɵɵDirectiveDefWithMeta<ExternalDir, '[test]', never, never, never, never>;
|
||||
static ɵdir: ɵɵDirectiveDefWithMeta<ExternalDir, '[test]', never, never, never, never>;
|
||||
}
|
||||
|
||||
export declare class ExternalModule {
|
||||
@ -2990,7 +2990,7 @@ runInEachFileSystem(os => {
|
||||
env.write('node_modules/external/internal.d.ts', `
|
||||
|
||||
export declare class InternalDir {
|
||||
static ngDirectiveDef: ɵɵDirectiveDefWithMeta<InternalDir, '[test]', never, never, never, never>;
|
||||
static ɵdir: ɵɵDirectiveDefWithMeta<InternalDir, '[test]', never, never, never, never>;
|
||||
}
|
||||
`);
|
||||
env.write('test.ts', `
|
||||
@ -3233,7 +3233,7 @@ runInEachFileSystem(os => {
|
||||
import {ɵɵDirectiveDefWithMeta, ɵɵNgModuleDefWithMeta} from '@angular/core';
|
||||
|
||||
export declare class ExternalDir {
|
||||
static ngDirectiveDef: ɵɵDirectiveDefWithMeta<ExternalDir, '[test]', never, never, never, never>;
|
||||
static ɵdir: ɵɵDirectiveDefWithMeta<ExternalDir, '[test]', never, never, never, never>;
|
||||
}
|
||||
|
||||
export declare class ExternalModule {
|
||||
@ -4179,7 +4179,7 @@ export const Foo = Foo__PRE_R3__;
|
||||
import {ɵɵDirectiveDefWithMeta, ɵɵNgModuleDefWithMeta} from '@angular/core';
|
||||
|
||||
export declare class ExternalDir {
|
||||
static ngDirectiveDef: ɵɵDirectiveDefWithMeta<ExternalDir, '[test]', never, never, never, never>;
|
||||
static ɵdir: ɵɵDirectiveDefWithMeta<ExternalDir, '[test]', never, never, never, never>;
|
||||
}
|
||||
|
||||
export declare class AlphaModule {
|
||||
@ -4230,7 +4230,7 @@ export const Foo = Foo__PRE_R3__;
|
||||
import {LibModule} from './lib';
|
||||
|
||||
export declare class ExternalDir {
|
||||
static ngDirectiveDef: ɵɵDirectiveDefWithMeta<ExternalDir, '[test]', never, never, never, never>;
|
||||
static ɵdir: ɵɵDirectiveDefWithMeta<ExternalDir, '[test]', never, never, never, never>;
|
||||
}
|
||||
|
||||
export declare class ExternalModule {
|
||||
@ -4241,7 +4241,7 @@ export const Foo = Foo__PRE_R3__;
|
||||
import {ɵɵDirectiveDefWithMeta, ɵɵNgModuleDefWithMeta} from '@angular/core';
|
||||
|
||||
export declare class LibDir {
|
||||
static ngDirectiveDef: ɵɵDirectiveDefWithMeta<LibDir, '[lib]', never, never, never, never>;
|
||||
static ɵdir: ɵɵDirectiveDefWithMeta<LibDir, '[lib]', never, never, never, never>;
|
||||
}
|
||||
|
||||
export declare class LibModule {
|
||||
|
@ -46,13 +46,13 @@ export declare class IndexPipe {
|
||||
export declare class NgForOf<T> {
|
||||
ngForOf: T[];
|
||||
static ngTemplateContextGuard<T>(dir: NgForOf<T>, ctx: any): ctx is NgForOfContext<T>;
|
||||
static ngDirectiveDef: i0.ɵɵDirectiveDefWithMeta<NgForOf<any>, '[ngFor][ngForOf]', never, {'ngForOf': 'ngForOf'}, {}, never>;
|
||||
static ɵdir: i0.ɵɵDirectiveDefWithMeta<NgForOf<any>, '[ngFor][ngForOf]', never, {'ngForOf': 'ngForOf'}, {}, never>;
|
||||
}
|
||||
|
||||
export declare class NgIf {
|
||||
ngIf: any;
|
||||
static ngTemplateGuard_ngIf: 'binding';
|
||||
static ngDirectiveDef: i0.ɵɵDirectiveDefWithMeta<NgForOf<any>, '[ngIf]', never, {'ngIf': 'ngIf'}, {}, never>;
|
||||
static ɵdir: i0.ɵɵDirectiveDefWithMeta<NgForOf<any>, '[ngIf]', never, {'ngIf': 'ngIf'}, {}, never>;
|
||||
}
|
||||
|
||||
export declare class CommonModule {
|
||||
|
Reference in New Issue
Block a user