1 | /// <amd-module name="@angular/compiler-cli/ngcc/src/packages/transformer" />
|
---|
2 | /**
|
---|
3 | * @license
|
---|
4 | * Copyright Google LLC All Rights Reserved.
|
---|
5 | *
|
---|
6 | * Use of this source code is governed by an MIT-style license that can be
|
---|
7 | * found in the LICENSE file at https://angular.io/license
|
---|
8 | */
|
---|
9 | import * as ts from 'typescript';
|
---|
10 | import { ParsedConfiguration } from '../../..';
|
---|
11 | import { ReadonlyFileSystem } from '../../../src/ngtsc/file_system';
|
---|
12 | import { Logger } from '../../../src/ngtsc/logging';
|
---|
13 | import { ModuleWithProvidersAnalyses } from '../analysis/module_with_providers_analyzer';
|
---|
14 | import { ExportInfo } from '../analysis/private_declarations_analyzer';
|
---|
15 | import { SwitchMarkerAnalyses } from '../analysis/switch_marker_analyzer';
|
---|
16 | import { CompiledFile } from '../analysis/types';
|
---|
17 | import { NgccReflectionHost } from '../host/ngcc_host';
|
---|
18 | import { RenderingFormatter } from '../rendering/rendering_formatter';
|
---|
19 | import { FileToWrite } from '../rendering/utils';
|
---|
20 | import { EntryPointBundle } from './entry_point_bundle';
|
---|
21 | export declare type TransformResult = {
|
---|
22 | success: true;
|
---|
23 | diagnostics: ts.Diagnostic[];
|
---|
24 | transformedFiles: FileToWrite[];
|
---|
25 | } | {
|
---|
26 | success: false;
|
---|
27 | diagnostics: ts.Diagnostic[];
|
---|
28 | };
|
---|
29 | /**
|
---|
30 | * A Package is stored in a directory on disk and that directory can contain one or more package
|
---|
31 | * formats - e.g. fesm2015, UMD, etc. Additionally, each package provides typings (`.d.ts` files).
|
---|
32 | *
|
---|
33 | * Each of these formats exposes one or more entry points, which are source files that need to be
|
---|
34 | * parsed to identify the decorated exported classes that need to be analyzed and compiled by one or
|
---|
35 | * more `DecoratorHandler` objects.
|
---|
36 | *
|
---|
37 | * Each entry point to a package is identified by a `package.json` which contains properties that
|
---|
38 | * indicate what formatted bundles are accessible via this end-point.
|
---|
39 | *
|
---|
40 | * Each bundle is identified by a root `SourceFile` that can be parsed and analyzed to
|
---|
41 | * identify classes that need to be transformed; and then finally rendered and written to disk.
|
---|
42 | *
|
---|
43 | * Along with the source files, the corresponding source maps (either inline or external) and
|
---|
44 | * `.d.ts` files are transformed accordingly.
|
---|
45 | *
|
---|
46 | * - Flat file packages have all the classes in a single file.
|
---|
47 | * - Other packages may re-export classes from other non-entry point files.
|
---|
48 | * - Some formats may contain multiple "modules" in a single file.
|
---|
49 | */
|
---|
50 | export declare class Transformer {
|
---|
51 | private fs;
|
---|
52 | private logger;
|
---|
53 | private tsConfig;
|
---|
54 | constructor(fs: ReadonlyFileSystem, logger: Logger, tsConfig?: ParsedConfiguration | null);
|
---|
55 | /**
|
---|
56 | * Transform the source (and typings) files of a bundle.
|
---|
57 | * @param bundle the bundle to transform.
|
---|
58 | * @returns information about the files that were transformed.
|
---|
59 | */
|
---|
60 | transform(bundle: EntryPointBundle): TransformResult;
|
---|
61 | getHost(bundle: EntryPointBundle): NgccReflectionHost;
|
---|
62 | getRenderingFormatter(host: NgccReflectionHost, bundle: EntryPointBundle): RenderingFormatter;
|
---|
63 | analyzeProgram(reflectionHost: NgccReflectionHost, bundle: EntryPointBundle): ProgramAnalyses;
|
---|
64 | }
|
---|
65 | export declare function hasErrors(diagnostics: ts.Diagnostic[]): boolean;
|
---|
66 | interface ProgramAnalyses {
|
---|
67 | decorationAnalyses: Map<ts.SourceFile, CompiledFile>;
|
---|
68 | switchMarkerAnalyses: SwitchMarkerAnalyses;
|
---|
69 | privateDeclarationsAnalyses: ExportInfo[];
|
---|
70 | moduleWithProvidersAnalyses: ModuleWithProvidersAnalyses | null;
|
---|
71 | diagnostics: ts.Diagnostic[];
|
---|
72 | }
|
---|
73 | export {};
|
---|