-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(compiler-cli): introduce declaration function to declare cla…
…ss metadata (#41200) This commit refactors the generated code for class metadata in partial compilation mode. Instead of emitting class metadata into a top-level `ɵsetClassMetadata` call guarded by `ngDevMode` flags, the class metadata is now declared using a top-level `ɵɵngDeclareClassMetadata` call. PR Close #41200
- Loading branch information
Showing
81 changed files
with
5,196 additions
and
4,319 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...es/compiler-cli/linker/src/file_linker/partial_linkers/partial_class_metadata_linker_1.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
import {compileClassMetadata, ConstantPool, R3ClassMetadata, R3DeclareClassMetadata, R3PartialDeclaration} from '@angular/compiler'; | ||
import * as o from '@angular/compiler/src/output/output_ast'; | ||
|
||
import {AstObject} from '../../ast/ast_value'; | ||
|
||
import {PartialLinker} from './partial_linker'; | ||
|
||
/** | ||
* A `PartialLinker` that is designed to process `ɵɵngDeclareClassMetadata()` call expressions. | ||
*/ | ||
export class PartialClassMetadataLinkerVersion1<TExpression> implements PartialLinker<TExpression> { | ||
linkPartialDeclaration( | ||
constantPool: ConstantPool, | ||
metaObj: AstObject<R3PartialDeclaration, TExpression>): o.Expression { | ||
const meta = toR3ClassMetadata(metaObj); | ||
return compileClassMetadata(meta); | ||
} | ||
} | ||
|
||
/** | ||
* Derives the `R3ClassMetadata` structure from the AST object. | ||
*/ | ||
export function toR3ClassMetadata<TExpression>( | ||
metaObj: AstObject<R3DeclareClassMetadata, TExpression>): R3ClassMetadata { | ||
return { | ||
type: metaObj.getOpaque('type'), | ||
decorators: metaObj.getOpaque('decorators'), | ||
ctorParameters: metaObj.has('ctorParameters') ? metaObj.getOpaque('ctorParameters') : null, | ||
propDecorators: metaObj.has('propDecorators') ? metaObj.getOpaque('propDecorators') : null, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.