mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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
@@ -24,8 +24,8 @@ import {ReferencesRegistry} from './references_registry';
|
||||
import {combineResolvers, findAngularDecorator, forwardRefResolver, getValidConstructorDependencies, isExpressionForwardReference, toR3Reference, unwrapExpression} from './util';
|
||||
|
||||
export interface NgModuleAnalysis {
|
||||
ɵmod: R3NgModuleMetadata;
|
||||
ngInjectorDef: R3InjectorMetadata;
|
||||
mod: R3NgModuleMetadata;
|
||||
inj: R3InjectorMetadata;
|
||||
metadataStmt: Statement|null;
|
||||
declarations: Reference<ClassDeclaration>[];
|
||||
exports: Reference<ClassDeclaration>[];
|
||||
@@ -236,7 +236,8 @@ export class NgModuleDecoratorHandler implements DecoratorHandler<NgModuleAnalys
|
||||
return {
|
||||
analysis: {
|
||||
id,
|
||||
ɵmod: ngModuleDef, ngInjectorDef,
|
||||
mod: ngModuleDef,
|
||||
inj: ngInjectorDef,
|
||||
declarations: declarationRefs,
|
||||
exports: exportRefs,
|
||||
metadataStmt: generateSetClassMetadataCall(
|
||||
@@ -256,7 +257,7 @@ export class NgModuleDecoratorHandler implements DecoratorHandler<NgModuleAnalys
|
||||
const context = getSourceFile(node);
|
||||
for (const exportRef of analysis.exports) {
|
||||
if (isNgModule(exportRef.node, scope.compilation)) {
|
||||
analysis.ngInjectorDef.imports.push(this.refEmitter.emit(exportRef, context));
|
||||
analysis.inj.imports.push(this.refEmitter.emit(exportRef, context));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,8 +281,8 @@ export class NgModuleDecoratorHandler implements DecoratorHandler<NgModuleAnalys
|
||||
}
|
||||
|
||||
compile(node: ClassDeclaration, analysis: NgModuleAnalysis): CompileResult[] {
|
||||
const ngInjectorDef = compileInjector(analysis.ngInjectorDef);
|
||||
const ngModuleDef = compileNgModule(analysis.ɵmod);
|
||||
const ngInjectorDef = compileInjector(analysis.inj);
|
||||
const ngModuleDef = compileNgModule(analysis.mod);
|
||||
const ngModuleStatements = ngModuleDef.additionalStatements;
|
||||
if (analysis.metadataStmt !== null) {
|
||||
ngModuleStatements.push(analysis.metadataStmt);
|
||||
@@ -314,7 +315,7 @@ export class NgModuleDecoratorHandler implements DecoratorHandler<NgModuleAnalys
|
||||
type: ngModuleDef.type,
|
||||
},
|
||||
{
|
||||
name: 'ngInjectorDef',
|
||||
name: 'ɵinj',
|
||||
initializer: ngInjectorDef.expression,
|
||||
statements: ngInjectorDef.statements,
|
||||
type: ngInjectorDef.type,
|
||||
|
||||
@@ -77,7 +77,7 @@ runInEachFileSystem(() => {
|
||||
if (detected === undefined) {
|
||||
return fail('Failed to recognize @NgModule');
|
||||
}
|
||||
const moduleDef = handler.analyze(TestModule, detected.metadata).analysis !.ɵmod;
|
||||
const moduleDef = handler.analyze(TestModule, detected.metadata).analysis !.mod;
|
||||
|
||||
expect(getReferenceIdentifierTexts(moduleDef.declarations)).toEqual(['TestComp']);
|
||||
expect(getReferenceIdentifierTexts(moduleDef.exports)).toEqual(['TestComp']);
|
||||
|
||||
@@ -23,7 +23,7 @@ const R3_DEF_NAME_PATTERN = [
|
||||
'ɵcmp',
|
||||
'ɵdir',
|
||||
'ngInjectableDef',
|
||||
'ngInjectorDef',
|
||||
'ɵinj',
|
||||
'ɵmod',
|
||||
'ɵpipe',
|
||||
'ɵfac',
|
||||
|
||||
Reference in New Issue
Block a user