diff --git a/integration/ngcc/test.sh b/integration/ngcc/test.sh index bb7d67bb96..37d7839d8f 100755 --- a/integration/ngcc/test.sh +++ b/integration/ngcc/test.sh @@ -66,16 +66,16 @@ assertSucceeded "Expected 'ngcc' to log 'Compiling'." # Did it compile @angular/core/ApplicationModule correctly? - grep "ApplicationModule.ngModuleDef = ɵɵdefineNgModule" node_modules/@angular/core/fesm2015/core.js + grep "ApplicationModule.ɵmod = ɵɵdefineNgModule" node_modules/@angular/core/fesm2015/core.js assertSucceeded "Expected 'ngcc' to correctly compile 'ApplicationModule' in '@angular/core' (fesm2015)." - grep "ApplicationModule.ngModuleDef = ɵɵdefineNgModule" node_modules/@angular/core/fesm5/core.js + grep "ApplicationModule.ɵmod = ɵɵdefineNgModule" node_modules/@angular/core/fesm5/core.js assertSucceeded "Expected 'ngcc' to correctly compile 'ApplicationModule' in '@angular/core' (fesm5)." - grep "ApplicationModule.ngModuleDef = ɵngcc0.ɵɵdefineNgModule" node_modules/@angular/core/esm2015/src/application_module.js + grep "ApplicationModule.ɵmod = ɵngcc0.ɵɵdefineNgModule" node_modules/@angular/core/esm2015/src/application_module.js assertSucceeded "Expected 'ngcc' to correctly compile 'ApplicationModule' in '@angular/core' (esm2015)." - grep "ApplicationModule.ngModuleDef = ɵngcc0.ɵɵdefineNgModule" node_modules/@angular/core/esm5/src/application_module.js + grep "ApplicationModule.ɵmod = ɵngcc0.ɵɵdefineNgModule" node_modules/@angular/core/esm5/src/application_module.js assertSucceeded "Expected 'ngcc' to correctly compile 'ApplicationModule' in '@angular/core' (esm5)." diff --git a/modules/benchmarks/src/expanding_rows/index_aot.ts b/modules/benchmarks/src/expanding_rows/index_aot.ts index 4ba9a19a1e..d2318d8818 100644 --- a/modules/benchmarks/src/expanding_rows/index_aot.ts +++ b/modules/benchmarks/src/expanding_rows/index_aot.ts @@ -13,10 +13,10 @@ import {platformBrowser} from '@angular/platform-browser'; import {ExpandingRowBenchmarkModule} from './benchmark'; import {ExpandingRowBenchmarkModuleNgFactory} from './benchmark.ngfactory'; -setMode(ExpandingRowBenchmarkModule.hasOwnProperty('ngModuleDef') ? 'Ivy' : 'ViewEngine'); +setMode(ExpandingRowBenchmarkModule.hasOwnProperty('ɵmod') ? 'Ivy' : 'ViewEngine'); enableProdMode(); platformBrowser().bootstrapModuleFactory(ExpandingRowBenchmarkModuleNgFactory); function setMode(name: string): void { document.querySelector('#rendererMode') !.textContent = `Render Mode: ${name}`; -} \ No newline at end of file +} diff --git a/packages/compiler-cli/ngcc/test/rendering/renderer_spec.ts b/packages/compiler-cli/ngcc/test/rendering/renderer_spec.ts index 078a5e0a56..d787ea5e99 100644 --- a/packages/compiler-cli/ngcc/test/rendering/renderer_spec.ts +++ b/packages/compiler-cli/ngcc/test/rendering/renderer_spec.ts @@ -268,14 +268,14 @@ A.ɵdir = ɵngcc0.ɵɵdefineDirective({ type: A, selectors: [["", "a", ""]] }); decorationAnalyses, switchMarkerAnalyses, privateDeclarationsAnalyses); const addDefinitionsSpy = testFormatter.addDefinitions as jasmine.Spy; const definitions: string = addDefinitionsSpy.calls.first().args[2]; - const ngModuleDef = definitions.indexOf('ngModuleDef'); - expect(ngModuleDef).not.toEqual(-1, 'ngModuleDef should exist'); + const ngModuleDef = definitions.indexOf('ɵmod'); + expect(ngModuleDef).not.toEqual(-1, 'ɵmod should exist'); const ngInjectorDef = definitions.indexOf('ngInjectorDef'); expect(ngInjectorDef).not.toEqual(-1, 'ngInjectorDef should exist'); const setClassMetadata = definitions.indexOf('setClassMetadata'); expect(setClassMetadata).not.toEqual(-1, 'setClassMetadata call should exist'); expect(setClassMetadata) - .toBeGreaterThan(ngModuleDef, 'setClassMetadata should follow ngModuleDef'); + .toBeGreaterThan(ngModuleDef, 'setClassMetadata should follow ɵmod'); expect(setClassMetadata) .toBeGreaterThan(ngInjectorDef, 'setClassMetadata should follow ngInjectorDef'); }); diff --git a/packages/compiler-cli/src/ngtsc/annotations/src/ng_module.ts b/packages/compiler-cli/src/ngtsc/annotations/src/ng_module.ts index 95b485a337..9fb1984c45 100644 --- a/packages/compiler-cli/src/ngtsc/annotations/src/ng_module.ts +++ b/packages/compiler-cli/src/ngtsc/annotations/src/ng_module.ts @@ -24,7 +24,7 @@ import {ReferencesRegistry} from './references_registry'; import {combineResolvers, findAngularDecorator, forwardRefResolver, getValidConstructorDependencies, isExpressionForwardReference, toR3Reference, unwrapExpression} from './util'; export interface NgModuleAnalysis { - ngModuleDef: R3NgModuleMetadata; + ɵmod: R3NgModuleMetadata; ngInjectorDef: R3InjectorMetadata; metadataStmt: Statement|null; declarations: Reference[]; @@ -236,8 +236,7 @@ export class NgModuleDecoratorHandler implements DecoratorHandler { if (detected === undefined) { return fail('Failed to recognize @NgModule'); } - const moduleDef = handler.analyze(TestModule, detected.metadata).analysis !.ngModuleDef; + const moduleDef = handler.analyze(TestModule, detected.metadata).analysis !.ɵmod; expect(getReferenceIdentifierTexts(moduleDef.declarations)).toEqual(['TestComp']); expect(getReferenceIdentifierTexts(moduleDef.exports)).toEqual(['TestComp']); diff --git a/packages/compiler-cli/src/ngtsc/metadata/src/dts.ts b/packages/compiler-cli/src/ngtsc/metadata/src/dts.ts index c67da24a7f..bb4a12c634 100644 --- a/packages/compiler-cli/src/ngtsc/metadata/src/dts.ts +++ b/packages/compiler-cli/src/ngtsc/metadata/src/dts.ts @@ -38,7 +38,7 @@ export class DtsMetadataReader implements MetadataReader { // This operation is explicitly not memoized, as it depends on `ref.ownedByModuleGuess`. // TODO(alxhub): investigate caching of .d.ts module metadata. const ngModuleDef = this.reflector.getMembersOfClass(clazz).find( - member => member.name === 'ngModuleDef' && member.isStatic); + member => member.name === 'ɵmod' && member.isStatic); if (ngModuleDef === undefined) { return null; } else if ( diff --git a/packages/compiler-cli/src/ngtsc/scope/test/dependency_spec.ts b/packages/compiler-cli/src/ngtsc/scope/test/dependency_spec.ts index 979fa8b69e..eac3cf14b3 100644 --- a/packages/compiler-cli/src/ngtsc/scope/test/dependency_spec.ts +++ b/packages/compiler-cli/src/ngtsc/scope/test/dependency_spec.ts @@ -90,7 +90,7 @@ runInEachFileSystem(() => { } export declare class Module { - static ngModuleDef: ModuleMeta; + static ɵmod: ModuleMeta; } ` }); @@ -107,11 +107,11 @@ runInEachFileSystem(() => { } export declare class ModuleA { - static ngModuleDef: ModuleMeta; + static ɵmod: ModuleMeta; } export declare class ModuleB { - static ngModuleDef: ModuleMeta; + static ɵmod: ModuleMeta; } ` }); @@ -128,14 +128,14 @@ runInEachFileSystem(() => { } export declare class ModuleA { - static ngModuleDef: ModuleMeta; + static ɵmod: ModuleMeta; } `, 'exported': ` import * as d from 'declaration'; export declare class ModuleB { - static ngModuleDef: ModuleMeta; + static ɵmod: ModuleMeta; } ` }); @@ -156,7 +156,7 @@ runInEachFileSystem(() => { } export declare class DeepModule { - static ngModuleDef: ModuleMeta; + static ɵmod: ModuleMeta; } `, 'middle': ` @@ -167,7 +167,7 @@ runInEachFileSystem(() => { } export declare class MiddleModule { - static ngModuleDef: ModuleMeta; + static ɵmod: ModuleMeta; } `, 'shallow': ` @@ -178,7 +178,7 @@ runInEachFileSystem(() => { } export declare class ShallowModule { - static ngModuleDef: ModuleMeta; + static ɵmod: ModuleMeta; } `, }, @@ -206,7 +206,7 @@ runInEachFileSystem(() => { } export declare class DeepModule { - static ngModuleDef: ModuleMeta; + static ɵmod: ModuleMeta; } `, 'middle': ` @@ -217,7 +217,7 @@ runInEachFileSystem(() => { } export declare class MiddleModule { - static ngModuleDef: ModuleMeta; + static ɵmod: ModuleMeta; } `, 'shallow': ` @@ -228,7 +228,7 @@ runInEachFileSystem(() => { } export declare class ShallowModule { - static ngModuleDef: ModuleMeta; + static ɵmod: ModuleMeta; } `, }, @@ -257,11 +257,11 @@ runInEachFileSystem(() => { } export declare class DeepModule { - static ngModuleDef: ModuleMeta; + static ɵmod: ModuleMeta; } export declare class DeepExportModule { - static ngModuleDef: ModuleMeta; + static ɵmod: ModuleMeta; } `, }, diff --git a/packages/compiler-cli/src/transformers/nocollapse_hack.ts b/packages/compiler-cli/src/transformers/nocollapse_hack.ts index e4a7f0ea57..f91c9591a4 100644 --- a/packages/compiler-cli/src/transformers/nocollapse_hack.ts +++ b/packages/compiler-cli/src/transformers/nocollapse_hack.ts @@ -24,7 +24,7 @@ const R3_DEF_NAME_PATTERN = [ 'ɵdir', 'ngInjectableDef', 'ngInjectorDef', - 'ngModuleDef', + 'ɵmod', 'ɵpipe', 'ɵfac', ].join('|'); diff --git a/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts b/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts index 9ce36d8049..784b3f1311 100644 --- a/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts +++ b/packages/compiler-cli/test/ngtsc/ngtsc_spec.ts @@ -376,7 +376,7 @@ runInEachFileSystem(os => { expect(jsContents).toContain('TestDirective.ɵdir = i0.ɵɵdefineDirective'); expect(jsContents).toContain('TestPipe.ɵpipe = i0.ɵɵdefinePipe'); expect(jsContents).toContain('TestInjectable.ngInjectableDef = i0.ɵɵdefineInjectable'); - expect(jsContents).toContain('MyModule.ngModuleDef = i0.ɵɵdefineNgModule'); + expect(jsContents).toContain('MyModule.ɵmod = i0.ɵɵdefineNgModule'); expect(jsContents).toContain('MyModule.ngInjectorDef = i0.ɵɵdefineInjector'); expect(jsContents).toContain('inputs: { input: "input" }'); expect(jsContents).toContain('outputs: { output: "output" }'); @@ -512,7 +512,7 @@ runInEachFileSystem(os => { 'static ɵcmp: i0.ɵɵComponentDefWithMeta'); expect(dtsContents) .toContain( - 'static ngModuleDef: i0.ɵɵNgModuleDefWithMeta'); + 'static ɵmod: i0.ɵɵNgModuleDefWithMeta'); expect(dtsContents).not.toContain('__decorate'); }); @@ -607,7 +607,7 @@ runInEachFileSystem(os => { declare class RouterModule { static forRoot(): ModuleWithProviders; - static ngModuleDef: ɵɵNgModuleDefWithMeta; + static ɵmod: ɵɵNgModuleDefWithMeta; } `); @@ -657,7 +657,7 @@ runInEachFileSystem(os => { const dtsContents = env.getContents('test.d.ts'); expect(dtsContents) .toContain( - 'static ngModuleDef: i0.ɵɵNgModuleDefWithMeta'); + 'static ɵmod: i0.ɵɵNgModuleDefWithMeta'); expect(dtsContents).toContain('static ngInjectorDef: i0.ɵɵInjectorDef'); }); @@ -697,7 +697,7 @@ runInEachFileSystem(os => { const dtsContents = env.getContents('test.d.ts'); expect(dtsContents) .toContain( - 'static ngModuleDef: i0.ɵɵNgModuleDefWithMeta'); + 'static ɵmod: i0.ɵɵNgModuleDefWithMeta'); expect(dtsContents).toContain('static ngInjectorDef: i0.ɵɵInjectorDef'); }); @@ -741,7 +741,7 @@ runInEachFileSystem(os => { const dtsContents = env.getContents('test.d.ts'); expect(dtsContents) .toContain( - 'static ngModuleDef: i0.ɵɵNgModuleDefWithMeta'); + 'static ɵmod: i0.ɵɵNgModuleDefWithMeta'); expect(dtsContents).toContain('static ngInjectorDef: i0.ɵɵInjectorDef'); }); @@ -1180,7 +1180,7 @@ runInEachFileSystem(os => { expect(jsContents).toContain('TestCmp.ɵcmp ='); expect(jsContents).toContain('TestDir.ɵdir ='); expect(jsContents).toContain('TestPipe.ɵpipe ='); - expect(jsContents).toContain('TestNgModule.ngModuleDef ='); + expect(jsContents).toContain('TestNgModule.ɵmod ='); // Validate that each class also has an injectable definition. expect(jsContents).toContain('TestCmp.ngInjectableDef ='); @@ -1453,7 +1453,7 @@ runInEachFileSystem(os => { declare class RouterModule { static forRoot(): ModuleWithProviders; - static ngModuleDef: ɵɵNgModuleDefWithMeta; + static ɵmod: ɵɵNgModuleDefWithMeta; } `); @@ -1492,7 +1492,7 @@ runInEachFileSystem(os => { env.write('node_modules/router/internal.d.ts', ` import {ɵɵNgModuleDefWithMeta} from '@angular/core'; export declare class InternalRouterModule { - static ngModuleDef: ɵɵNgModuleDefWithMeta; + static ɵmod: ɵɵNgModuleDefWithMeta; } `); @@ -1508,14 +1508,14 @@ runInEachFileSystem(os => { 'i0.ɵɵNgModuleDefWithMeta'); }); - it('should not reference a constant with a ModuleWithProviders value in ngModuleDef imports', + it('should not reference a constant with a ModuleWithProviders value in module def imports', () => { env.write('dep.d.ts', ` import {ModuleWithProviders, ɵɵNgModuleDefWithMeta as ɵɵNgModuleDefWithMeta} from '@angular/core'; export declare class DepModule { static forRoot(arg1: any, arg2: any): ModuleWithProviders; - static ngModuleDef: ɵɵNgModuleDefWithMeta; + static ɵmod: ɵɵNgModuleDefWithMeta; } `); env.write('test.ts', ` @@ -1555,7 +1555,7 @@ runInEachFileSystem(os => { declare class RouterModule { static forRoot(): (MyType)&{ngModule:RouterModule}; - static ngModuleDef: ɵɵNgModuleDefWithMeta; + static ɵmod: ɵɵNgModuleDefWithMeta; } `); @@ -1587,7 +1587,7 @@ runInEachFileSystem(os => { declare class RouterModule { static forRoot(): core.ModuleWithProviders; - static ngModuleDef: ɵɵNgModuleDefWithMeta; + static ɵmod: ɵɵNgModuleDefWithMeta; } `); @@ -2947,7 +2947,7 @@ runInEachFileSystem(os => { } export declare class ExternalModule { - static ngModuleDef: ɵɵNgModuleDefWithMeta; + static ɵmod: ɵɵNgModuleDefWithMeta; } `); env.write('test.ts', ` @@ -2981,7 +2981,7 @@ runInEachFileSystem(os => { export {InternalDir as ExternalDir} from './internal'; export declare class ExternalModule { - static ngModuleDef: ɵɵNgModuleDefWithMeta; + static ɵmod: ɵɵNgModuleDefWithMeta; } `); env.write('node_modules/external/internal.d.ts', ` @@ -3234,7 +3234,7 @@ runInEachFileSystem(os => { } export declare class ExternalModule { - static ngModuleDef: ɵɵNgModuleDefWithMeta; + static ɵmod: ɵɵNgModuleDefWithMeta; } `); @@ -3543,7 +3543,7 @@ runInEachFileSystem(os => { export declare class RouterModule { static forRoot(arg1: any, arg2: any): ModuleWithProviders; static forChild(arg1: any): ModuleWithProviders; - static ngModuleDef: ɵɵNgModuleDefWithMeta; + static ɵmod: ɵɵNgModuleDefWithMeta; } `); }); @@ -4180,7 +4180,7 @@ export const Foo = Foo__PRE_R3__; } export declare class AlphaModule { - static ngModuleDef: ɵɵNgModuleDefWithMeta; + static ɵmod: ɵɵNgModuleDefWithMeta; } `); @@ -4190,7 +4190,7 @@ export const Foo = Foo__PRE_R3__; import {AlphaModule} from './alpha'; export declare class BetaModule { - static ngModuleDef: ɵɵNgModuleDefWithMeta; + static ɵmod: ɵɵNgModuleDefWithMeta; } `); @@ -4231,7 +4231,7 @@ export const Foo = Foo__PRE_R3__; } export declare class ExternalModule { - static ngModuleDef: ɵɵNgModuleDefWithMeta; + static ɵmod: ɵɵNgModuleDefWithMeta; } `); env.write('lib.d.ts', ` @@ -4242,7 +4242,7 @@ export const Foo = Foo__PRE_R3__; } export declare class LibModule { - static ngModuleDef: ɵɵNgModuleDefWithMeta; + static ɵmod: ɵɵNgModuleDefWithMeta; } `); env.write('foo.ts', ` diff --git a/packages/compiler-cli/test/ngtsc/scope_spec.ts b/packages/compiler-cli/test/ngtsc/scope_spec.ts index 7b47e4cc11..2804e5b5cd 100644 --- a/packages/compiler-cli/test/ngtsc/scope_spec.ts +++ b/packages/compiler-cli/test/ngtsc/scope_spec.ts @@ -51,7 +51,7 @@ runInEachFileSystem(() => { const dtsContents = env.getContents('test.d.ts'); expect(dtsContents) .toContain( - 'static ngModuleDef: i0.ɵɵNgModuleDefWithMeta'); + 'static ɵmod: i0.ɵɵNgModuleDefWithMeta'); }); it('should produce an error when an invalid class is imported', () => { @@ -112,7 +112,7 @@ runInEachFileSystem(() => { const dtsContents = env.getContents('test.d.ts'); expect(dtsContents) .toContain( - 'static ngModuleDef: i0.ɵɵNgModuleDefWithMeta'); + 'static ɵmod: i0.ɵɵNgModuleDefWithMeta'); }); it('should produce an error when a non-NgModule class is exported', () => { diff --git a/packages/compiler-cli/test/ngtsc/template_typecheck_spec.ts b/packages/compiler-cli/test/ngtsc/template_typecheck_spec.ts index d3857982f3..f6b5dd4da9 100644 --- a/packages/compiler-cli/test/ngtsc/template_typecheck_spec.ts +++ b/packages/compiler-cli/test/ngtsc/template_typecheck_spec.ts @@ -56,7 +56,7 @@ export declare class NgIf { } export declare class CommonModule { - static ngModuleDef: i0.ɵɵNgModuleDefWithMeta; + static ɵmod: i0.ɵɵNgModuleDefWithMeta; } `); }); diff --git a/packages/compiler/src/render3/r3_module_compiler.ts b/packages/compiler/src/render3/r3_module_compiler.ts index 2e3444bcbe..3c4a865a4e 100644 --- a/packages/compiler/src/render3/r3_module_compiler.ts +++ b/packages/compiler/src/render3/r3_module_compiler.ts @@ -23,7 +23,7 @@ export interface R3NgModuleDef { } /** - * Metadata required by the module compiler to generate a `ngModuleDef` for a type. + * Metadata required by the module compiler to generate a module def (`ɵmod`) for a type. */ export interface R3NgModuleMetadata { /** @@ -261,7 +261,7 @@ export function compileNgModuleFromRender2( } function accessExportScope(module: o.Expression): o.Expression { - const selectorScope = new o.ReadPropExpr(module, 'ngModuleDef'); + const selectorScope = new o.ReadPropExpr(module, 'ɵmod'); return new o.ReadPropExpr(selectorScope, 'exported'); } diff --git a/packages/core/src/core_render3_private_export.ts b/packages/core/src/core_render3_private_export.ts index 6f9baacb80..5a53e3dea4 100644 --- a/packages/core/src/core_render3_private_export.ts +++ b/packages/core/src/core_render3_private_export.ts @@ -224,7 +224,7 @@ export { NG_COMP_DEF as ɵNG_COMP_DEF, NG_DIR_DEF as ɵNG_DIR_DEF, NG_PIPE_DEF as ɵNG_PIPE_DEF, - NG_MODULE_DEF as ɵNG_MODULE_DEF, + NG_MOD_DEF as ɵNG_MOD_DEF, NG_BASE_DEF as ɵNG_BASE_DEF } from './render3/fields'; diff --git a/packages/core/src/linker/ng_module_factory_registration.ts b/packages/core/src/linker/ng_module_factory_registration.ts index 59c96cab2f..a4a86d5570 100644 --- a/packages/core/src/linker/ng_module_factory_registration.ts +++ b/packages/core/src/linker/ng_module_factory_registration.ts @@ -39,14 +39,14 @@ function assertSameOrNotExisting(id: string, type: Type| null, incoming: Ty } export function registerNgModuleType(ngModuleType: NgModuleType) { - if (ngModuleType.ngModuleDef.id !== null) { - const id = ngModuleType.ngModuleDef.id; + if (ngModuleType.ɵmod.id !== null) { + const id = ngModuleType.ɵmod.id; const existing = modules.get(id) as NgModuleType | null; assertSameOrNotExisting(id, existing, ngModuleType); modules.set(id, ngModuleType); } - let imports = ngModuleType.ngModuleDef.imports; + let imports = ngModuleType.ɵmod.imports; if (imports instanceof Function) { imports = imports(); } diff --git a/packages/core/src/render3/assert.ts b/packages/core/src/render3/assert.ts index 71ab4fee95..1610c1253e 100644 --- a/packages/core/src/render3/assert.ts +++ b/packages/core/src/render3/assert.ts @@ -29,8 +29,7 @@ export function assertComponentType( export function assertNgModuleType( actual: any, - msg: string = - 'Type passed in is not NgModuleType, it does not have \'ngModuleDef\' property.') { + msg: string = 'Type passed in is not NgModuleType, it does not have \'ɵmod\' property.') { if (!getNgModuleDef(actual)) { throwError(msg); } diff --git a/packages/core/src/render3/definition.ts b/packages/core/src/render3/definition.ts index 507b109692..423bebbaf3 100644 --- a/packages/core/src/render3/definition.ts +++ b/packages/core/src/render3/definition.ts @@ -16,7 +16,7 @@ import {initNgDevMode} from '../util/ng_dev_mode'; import {stringify} from '../util/stringify'; import {EMPTY_ARRAY, EMPTY_OBJ} from './empty'; -import {NG_BASE_DEF, NG_COMP_DEF, NG_DIR_DEF, NG_FACTORY_DEF, NG_LOCALE_ID_DEF, NG_MODULE_DEF, NG_PIPE_DEF} from './fields'; +import {NG_BASE_DEF, NG_COMP_DEF, NG_DIR_DEF, NG_FACTORY_DEF, NG_LOCALE_ID_DEF, NG_MOD_DEF, NG_PIPE_DEF} from './fields'; import {ComponentDef, ComponentDefFeature, ComponentTemplate, ComponentType, ContentQueriesFunction, DirectiveDef, DirectiveDefFeature, DirectiveType, DirectiveTypesOrFactory, FactoryFn, HostBindingsFunction, PipeDef, PipeType, PipeTypesOrFactory, ViewQueriesFunction, ɵɵBaseDef} from './interfaces/definition'; import {TAttributes} from './interfaces/node'; // while SelectorFlags is unused here, it's required so that types don't get resolved lazily @@ -768,9 +768,9 @@ export function getFactoryDef(type: any, throwNotFound?: boolean): FactoryFn< export function getNgModuleDef(type: any, throwNotFound: true): NgModuleDef; export function getNgModuleDef(type: any): NgModuleDef|null; export function getNgModuleDef(type: any, throwNotFound?: boolean): NgModuleDef|null { - const ngModuleDef = type[NG_MODULE_DEF] || null; + const ngModuleDef = type[NG_MOD_DEF] || null; if (!ngModuleDef && throwNotFound === true) { - throw new Error(`Type ${stringify(type)} does not have 'ngModuleDef' property.`); + throw new Error(`Type ${stringify(type)} does not have 'ɵmod' property.`); } return ngModuleDef; } diff --git a/packages/core/src/render3/fields.ts b/packages/core/src/render3/fields.ts index e2cc955f8d..90f433ed03 100644 --- a/packages/core/src/render3/fields.ts +++ b/packages/core/src/render3/fields.ts @@ -11,7 +11,7 @@ import {getClosureSafeProperty} from '../util/property'; export const NG_COMP_DEF = getClosureSafeProperty({ɵcmp: getClosureSafeProperty}); export const NG_DIR_DEF = getClosureSafeProperty({ɵdir: getClosureSafeProperty}); export const NG_PIPE_DEF = getClosureSafeProperty({ɵpipe: getClosureSafeProperty}); -export const NG_MODULE_DEF = getClosureSafeProperty({ngModuleDef: getClosureSafeProperty}); +export const NG_MOD_DEF = getClosureSafeProperty({ɵmod: getClosureSafeProperty}); export const NG_LOCALE_ID_DEF = getClosureSafeProperty({ngLocaleIdDef: getClosureSafeProperty}); export const NG_BASE_DEF = getClosureSafeProperty({ngBaseDef: getClosureSafeProperty}); export const NG_FACTORY_DEF = getClosureSafeProperty({ɵfac: getClosureSafeProperty}); diff --git a/packages/core/src/render3/jit/module.ts b/packages/core/src/render3/jit/module.ts index 9e0393658e..c1af91e634 100644 --- a/packages/core/src/render3/jit/module.ts +++ b/packages/core/src/render3/jit/module.ts @@ -16,7 +16,7 @@ import {ModuleWithProviders, NgModule, NgModuleDef, NgModuleTransitiveScopes} fr import {deepForEach, flatten} from '../../util/array_utils'; import {assertDefined} from '../../util/assert'; import {getComponentDef, getDirectiveDef, getNgModuleDef, getPipeDef} from '../definition'; -import {NG_COMP_DEF, NG_DIR_DEF, NG_MODULE_DEF, NG_PIPE_DEF} from '../fields'; +import {NG_COMP_DEF, NG_DIR_DEF, NG_MOD_DEF, NG_PIPE_DEF} from '../fields'; import {ComponentDef} from '../interfaces/definition'; import {NgModuleType} from '../ng_module_ref'; import {maybeUnwrapFn, stringifyForError} from '../util/misc_utils'; @@ -93,7 +93,7 @@ export function compileNgModule(moduleType: Type, ngModule: NgModule = {}): } /** - * Compiles and adds the `ngModuleDef` and `ngInjectorDef` properties to the module class. + * Compiles and adds the `ɵmod` and `ngInjectorDef` properties to the module class. * * It's possible to compile a module via this API which will allow duplicate declarations in its * root. @@ -105,7 +105,7 @@ export function compileNgModuleDefs( ngDevMode && assertDefined(ngModule, 'Required value ngModule'); const declarations: Type[] = flatten(ngModule.declarations || EMPTY_ARRAY); let ngModuleDef: any = null; - Object.defineProperty(moduleType, NG_MODULE_DEF, { + Object.defineProperty(moduleType, NG_MOD_DEF, { configurable: true, get: () => { if (ngModuleDef === null) { @@ -115,7 +115,7 @@ export function compileNgModuleDefs( throw new Error(`'${stringifyForError(moduleType)}' module can't import itself`); } ngModuleDef = getCompilerFacade().compileNgModule( - angularCoreEnv, `ng:///${moduleType.name}/ngModuleDef.js`, { + angularCoreEnv, `ng:///${moduleType.name}/ɵmod.js`, { type: moduleType, bootstrap: flatten(ngModule.bootstrap || EMPTY_ARRAY).map(resolveForwardRef), declarations: declarations.map(resolveForwardRef), @@ -429,7 +429,7 @@ export function transitiveScopesFor( moduleType: Type, processNgModuleFn?: (ngModule: NgModuleType) => void): NgModuleTransitiveScopes { if (!isNgModule(moduleType)) { - throw new Error(`${moduleType.name} does not have an ngModuleDef`); + throw new Error(`${moduleType.name} does not have a module def (ɵmod property)`); } const def = getNgModuleDef(moduleType) !; @@ -465,11 +465,11 @@ export function transitiveScopesFor( maybeUnwrapFn(def.imports).forEach((imported: Type) => { const importedType = imported as Type& { // If imported is an @NgModule: - ngModuleDef?: NgModuleDef; + ɵmod?: NgModuleDef; }; if (!isNgModule(importedType)) { - throw new Error(`Importing ${importedType.name} which does not have an ngModuleDef`); + throw new Error(`Importing ${importedType.name} which does not have a ɵmod property`); } if (processNgModuleFn) { @@ -488,7 +488,7 @@ export function transitiveScopesFor( // Components, Directives, NgModules, and Pipes can all be exported. ɵcmp?: any; ɵdir?: any; - ngModuleDef?: NgModuleDef; + ɵmod?: NgModuleDef; ɵpipe?: any; }; @@ -528,6 +528,6 @@ function isModuleWithProviders(value: any): value is ModuleWithProviders<{}> { return (value as{ngModule?: any}).ngModule !== undefined; } -function isNgModule(value: Type): value is Type&{ngModuleDef: NgModuleDef} { +function isNgModule(value: Type): value is Type&{ɵmod: NgModuleDef} { return !!getNgModuleDef(value); } diff --git a/packages/core/src/render3/ng_module_ref.ts b/packages/core/src/render3/ng_module_ref.ts index f46b63e0b6..a5b6e4f023 100644 --- a/packages/core/src/render3/ng_module_ref.ts +++ b/packages/core/src/render3/ng_module_ref.ts @@ -24,7 +24,7 @@ import {getNgLocaleIdDef, getNgModuleDef} from './definition'; import {setLocaleId} from './i18n'; import {maybeUnwrapFn} from './util/misc_utils'; -export interface NgModuleType extends Type { ngModuleDef: NgModuleDef; } +export interface NgModuleType extends Type { ɵmod: NgModuleDef; } const COMPONENT_FACTORY_RESOLVER: StaticProvider = { provide: viewEngine_ComponentFactoryResolver, diff --git a/packages/core/test/linker/ng_module_integration_spec.ts b/packages/core/test/linker/ng_module_integration_spec.ts index e54fd8074a..fa1c8013bd 100644 --- a/packages/core/test/linker/ng_module_integration_spec.ts +++ b/packages/core/test/linker/ng_module_integration_spec.ts @@ -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], diff --git a/packages/core/test/render3/ivy/jit_spec.ts b/packages/core/test/render3/ivy/jit_spec.ts index af8fcad23c..b21cf495f0 100644 --- a/packages/core/test/render3/ivy/jit_spec.ts +++ b/packages/core/test/render3/ivy/jit_spec.ts @@ -156,7 +156,7 @@ ivyEnabled && describe('render3 jit', () => { class Module { } - const moduleDef: NgModuleDef = (Module as any).ngModuleDef; + const moduleDef: NgModuleDef = (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 as any).ngModuleDef; + const moduleDef: NgModuleDef = (Module as any).ɵmod; // directive defs are still null, since no directives were in that component expect(cmpDef.directiveDefs).toBeNull(); }); diff --git a/packages/core/test/render3/providers_spec.ts b/packages/core/test/render3/providers_spec.ts index 8fdea24c65..3a48f99623 100644 --- a/packages/core/test/render3/providers_spec.ts +++ b/packages/core/test/render3/providers_spec.ts @@ -1134,7 +1134,7 @@ describe('providers', () => { {provide: String, useValue: 'From module injector'} ] }); - static ngModuleDef: NgModuleDef = { bootstrap: [] } as any; + static ɵmod: NgModuleDef = { bootstrap: [] } as any; } const myAppModuleFactory = new NgModuleFactory(MyAppModule); const ngModuleRef = myAppModuleFactory.create(null); diff --git a/packages/core/test/test_bed_spec.ts b/packages/core/test/test_bed_spec.ts index e000fb3720..39802b105c 100644 --- a/packages/core/test/test_bed_spec.ts +++ b/packages/core/test/test_bed_spec.ts @@ -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], }); diff --git a/packages/core/testing/src/r3_test_bed_compiler.ts b/packages/core/testing/src/r3_test_bed_compiler.ts index b68a56c5b9..e183346c46 100644 --- a/packages/core/testing/src/r3_test_bed_compiler.ts +++ b/packages/core/testing/src/r3_test_bed_compiler.ts @@ -7,7 +7,7 @@ */ import {ResourceLoader} from '@angular/compiler'; -import {ApplicationInitStatus, COMPILER_OPTIONS, Compiler, Component, Directive, Injector, LOCALE_ID, ModuleWithComponentFactories, ModuleWithProviders, NgModule, NgModuleFactory, NgZone, Pipe, PlatformRef, Provider, Type, ɵDEFAULT_LOCALE_ID as DEFAULT_LOCALE_ID, ɵDirectiveDef as DirectiveDef, ɵNG_COMP_DEF as NG_COMP_DEF, ɵNG_DIR_DEF as NG_DIR_DEF, ɵNG_INJECTOR_DEF as NG_INJECTOR_DEF, ɵNG_MODULE_DEF as NG_MODULE_DEF, ɵNG_PIPE_DEF as NG_PIPE_DEF, ɵNgModuleFactory as R3NgModuleFactory, ɵNgModuleTransitiveScopes as NgModuleTransitiveScopes, ɵNgModuleType as NgModuleType, ɵRender3ComponentFactory as ComponentFactory, ɵRender3NgModuleRef as NgModuleRef, ɵcompileComponent as compileComponent, ɵcompileDirective as compileDirective, ɵcompileNgModuleDefs as compileNgModuleDefs, ɵcompilePipe as compilePipe, ɵgetInjectableDef as getInjectableDef, ɵpatchComponentDefWithScope as patchComponentDefWithScope, ɵsetLocaleId as setLocaleId, ɵtransitiveScopesFor as transitiveScopesFor, ɵɵInjectableDef as InjectableDef} from '@angular/core'; +import {ApplicationInitStatus, COMPILER_OPTIONS, Compiler, Component, Directive, Injector, LOCALE_ID, ModuleWithComponentFactories, ModuleWithProviders, NgModule, NgModuleFactory, NgZone, Pipe, PlatformRef, Provider, Type, ɵDEFAULT_LOCALE_ID as DEFAULT_LOCALE_ID, ɵDirectiveDef as DirectiveDef, ɵNG_COMP_DEF as NG_COMP_DEF, ɵNG_DIR_DEF as NG_DIR_DEF, ɵNG_INJECTOR_DEF as NG_INJECTOR_DEF, ɵNG_MOD_DEF as NG_MOD_DEF, ɵNG_PIPE_DEF as NG_PIPE_DEF, ɵNgModuleFactory as R3NgModuleFactory, ɵNgModuleTransitiveScopes as NgModuleTransitiveScopes, ɵNgModuleType as NgModuleType, ɵRender3ComponentFactory as ComponentFactory, ɵRender3NgModuleRef as NgModuleRef, ɵcompileComponent as compileComponent, ɵcompileDirective as compileDirective, ɵcompileNgModuleDefs as compileNgModuleDefs, ɵcompilePipe as compilePipe, ɵgetInjectableDef as getInjectableDef, ɵpatchComponentDefWithScope as patchComponentDefWithScope, ɵsetLocaleId as setLocaleId, ɵtransitiveScopesFor as transitiveScopesFor, ɵɵInjectableDef as InjectableDef} from '@angular/core'; import {ModuleRegistrationMap, getRegisteredModulesState, restoreRegisteredModulesState} from '../../src/linker/ng_module_factory_registration'; import {clearResolutionOfComponentResourcesQueue, isComponentDefPendingResolution, resolveComponentResources, restoreComponentResolutionQueue} from '../../src/metadata/resource_loading'; @@ -130,7 +130,7 @@ export class R3TestBedCompiler { this.recompileNgModule(ngModule); - // At this point, the module has a valid .ngModuleDef, but the override may have introduced + // At this point, the module has a valid module def (ɵmod), but the override may have introduced // new declarations or imported modules. Ingest any possible new types and add them to the // current queue. this.queueTypesFromModulesArray([ngModule]); @@ -285,7 +285,7 @@ export class R3TestBedCompiler { * @internal */ _getComponentFactories(moduleType: NgModuleType): ComponentFactory[] { - return maybeUnwrapFn(moduleType.ngModuleDef.declarations).reduce((factories, declaration) => { + return maybeUnwrapFn(moduleType.ɵmod.declarations).reduce((factories, declaration) => { const componentDef = (declaration as any).ɵcmp; componentDef && factories.push(new ComponentFactory(componentDef, this.testModuleRef !)); return factories; @@ -380,7 +380,7 @@ export class R3TestBedCompiler { } // Apply provider overrides to imported modules recursively - const moduleDef: any = (moduleType as any)[NG_MODULE_DEF]; + const moduleDef: any = (moduleType as any)[NG_MOD_DEF]; for (const importType of moduleDef.imports) { this.applyProviderOverridesToModule(importType); } @@ -409,7 +409,7 @@ export class R3TestBedCompiler { throw new Error(`Unable to resolve metadata for NgModule: ${ngModule.name}`); } // Cache the initial ngModuleDef as it will be overwritten. - this.maybeStoreNgDef(NG_MODULE_DEF, ngModule); + this.maybeStoreNgDef(NG_MOD_DEF, ngModule); this.maybeStoreNgDef(NG_INJECTOR_DEF, ngModule); compileNgModuleDefs(ngModule as NgModuleType, metadata); @@ -469,7 +469,7 @@ export class R3TestBedCompiler { if (Array.isArray(value)) { this.queueTypesFromModulesArray(value); } else if (hasNgModuleDef(value)) { - const def = value.ngModuleDef; + const def = value.ɵmod; // Look through declarations, imports, and exports, and queue everything found there. this.queueTypeArray(maybeUnwrapFn(def.declarations), value); this.queueTypesFromModulesArray(maybeUnwrapFn(def.imports)); @@ -682,7 +682,7 @@ function initResolvers(): Resolvers { } function hasNgModuleDef(value: Type): value is NgModuleType { - return value.hasOwnProperty('ngModuleDef'); + return value.hasOwnProperty('ɵmod'); } function maybeUnwrapFn(maybeFn: (() => T) | T): T {