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:

committed by
Miško Hevery

parent
d62eff7316
commit
fc93dafab1
@ -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<ClassDeclaration>[];
|
||||
@ -236,8 +236,7 @@ export class NgModuleDecoratorHandler implements DecoratorHandler<NgModuleAnalys
|
||||
return {
|
||||
analysis: {
|
||||
id,
|
||||
ngModuleDef,
|
||||
ngInjectorDef,
|
||||
ɵmod: ngModuleDef, ngInjectorDef,
|
||||
declarations: declarationRefs,
|
||||
exports: exportRefs,
|
||||
metadataStmt: generateSetClassMetadataCall(
|
||||
@ -282,7 +281,7 @@ export class NgModuleDecoratorHandler implements DecoratorHandler<NgModuleAnalys
|
||||
|
||||
compile(node: ClassDeclaration, analysis: NgModuleAnalysis): CompileResult[] {
|
||||
const ngInjectorDef = compileInjector(analysis.ngInjectorDef);
|
||||
const ngModuleDef = compileNgModule(analysis.ngModuleDef);
|
||||
const ngModuleDef = compileNgModule(analysis.ɵmod);
|
||||
const ngModuleStatements = ngModuleDef.additionalStatements;
|
||||
if (analysis.metadataStmt !== null) {
|
||||
ngModuleStatements.push(analysis.metadataStmt);
|
||||
@ -309,7 +308,7 @@ export class NgModuleDecoratorHandler implements DecoratorHandler<NgModuleAnalys
|
||||
}
|
||||
const res: CompileResult[] = [
|
||||
{
|
||||
name: 'ngModuleDef',
|
||||
name: 'ɵmod',
|
||||
initializer: ngModuleDef.expression,
|
||||
statements: ngModuleStatements,
|
||||
type: ngModuleDef.type,
|
||||
|
@ -77,7 +77,7 @@ runInEachFileSystem(() => {
|
||||
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']);
|
||||
|
Reference in New Issue
Block a user