MCPcopy Create free account
hub / github.com/angular/angular / compileClasses

Function compileClasses

packages/compiler-cli/preprocessor/src/processor.ts:515–1895  ·  view source on GitHub ↗

* The `Compile` pass: compiles each class into `file.compiledClasses`. Returns the HMR update * module as soon as `ctx.hmrUpdateTarget` is compiled, and `undefined` otherwise.

(file: FileCompilation)

Source from the content-addressed store, hash-verified

513 * module as soon as `ctx.hmrUpdateTarget` is compiled, and `undefined` otherwise.
514 */
515function compileClasses(file: FileCompilation): string | null | undefined {
516 const {
517 ctx,
518 filePath,
519 content,
520 readResource,
521 s,
522 result,
523 printer,
524 out,
525 templatesByClass,
526 sharedPool,
527 importsByBinding,
528 fileExplicitlyDeferredNames,
529 fileDiagnostics,
530 referencedStyleFiles,
531 compiledClasses,
532 deferredOnlyNames,
533 eagerlyBoundNames,
534 eagerlyReferencedNames,
535 eagerDependencyNames,
536 } = file;
537 const {classes} = result;
538 for (const classMeta of classes) {
539 if (ctx.hmrUpdateTarget !== undefined && classMeta.className !== ctx.hmrUpdateTarget) {
540 continue;
541 }
542 const {
543 span,
544 className,
545 constructorParams,
546 injectable,
547 service,
548 component,
549 directive,
550 pipe,
551 hostBindings,
552 hostListeners,
553 ngModule,
554 } = classMeta;
555
556 // Pre-derived by `prepare_members` in ng-analyze/src/analyzer/class_data.rs: model()
557 // expansion, coercion marking, and query ordering.
558 const {inputs, outputs, queries, viewQueries} = classMeta;
559
560 const isJit = Boolean(component?.isJit || directive?.isJit || ngModule?.isJit);
561 if (!isJit || !ctx.emitDeclarationOnly) {
562 for (const span of classMeta.removalSpans) {
563 s.remove(span.start, span.end);
564 }
565 }
566
567 // Stripping the decorators stops tsickle from tagging statics `@nocollapse`; add it back.
568 if (ctx.isClosureCompilerEnabled && !isJit) {
569 for (const insertion of classMeta.nocollapseInsertions) {
570 s.appendLeft(insertion.position, insertion.text);
571 }
572 }

Callers 1

processFileFunction · 0.85

Calls 15

bindMethod · 0.95
compileFactoryFunctionFunction · 0.90
compilePipeFromMetadataFunction · 0.90
makeBindingParserFunction · 0.90
compileServiceFunction · 0.90
compileInjectableFunction · 0.90
compileHmrInitializerFunction · 0.90
buildPropDecoratorsExprFunction · 0.85

Tested by

no test coverage detected