refactor(core): rename ngModuleDef to ɵmod (#33142)

Module 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
ngModuleDef to mod. 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 #33142
This commit is contained in:
Kara Erickson
2019-10-14 07:20:26 -07:00
committed by Miško Hevery
parent d62eff7316
commit fc93dafab1
24 changed files with 87 additions and 89 deletions

View File

@ -335,14 +335,14 @@ function declareTests(config?: {useJit: boolean}) {
.it('should register a module even if not importing the .ngfactory file or calling create()',
() => {
class ChildModule {
static ngModuleDef = defineNgModule({
static ɵmod = defineNgModule({
type: ChildModule,
id: 'child',
});
}
class Module {
static ngModuleDef = defineNgModule({
static ɵmod = defineNgModule({
type: Module,
id: 'test',
imports: [ChildModule],

View File

@ -156,7 +156,7 @@ ivyEnabled && describe('render3 jit', () => {
class Module {
}
const moduleDef: NgModuleDef<Module> = (Module as any).ngModuleDef;
const moduleDef: NgModuleDef<Module> = (Module as any).ɵmod;
expect(moduleDef).toBeDefined();
if (!Array.isArray(moduleDef.declarations)) {
return fail('Expected an array');
@ -208,7 +208,7 @@ ivyEnabled && describe('render3 jit', () => {
class Module {
}
const moduleDef: NgModuleDef<Module> = (Module as any).ngModuleDef;
const moduleDef: NgModuleDef<Module> = (Module as any).ɵmod;
// directive defs are still null, since no directives were in that component
expect(cmpDef.directiveDefs).toBeNull();
});

View File

@ -1134,7 +1134,7 @@ describe('providers', () => {
{provide: String, useValue: 'From module injector'}
]
});
static ngModuleDef: NgModuleDef<any> = { bootstrap: [] } as any;
static ɵmod: NgModuleDef<any> = { bootstrap: [] } as any;
}
const myAppModuleFactory = new NgModuleFactory(MyAppModule);
const ngModuleRef = myAppModuleFactory.create(null);

View File

@ -553,7 +553,7 @@ describe('TestBed', () => {
// This is an AOT compiled module which declares (but does not export) SomeComponent.
class ModuleClass {
static ngModuleDef = defineNgModule({
static ɵmod = defineNgModule({
type: ModuleClass,
declarations: [SomeComponent],
});