mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(compiler-cli): remove unused CLI private exports (#33242)
These exports are no longer used by the CLI since 7.1.0. Since major versions of the CLI are now locked to major versions of the framework, a CLI user will not be able to use FW 9.0+ on an outdated version (<7.1.0) of the CLI that uses these old APIs. PR Close #33242
This commit is contained in:
@@ -1,133 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a private API for the ngtools toolkit.
|
||||
*
|
||||
* This API should be stable for NG 2. It can be removed in NG 4..., but should be replaced by
|
||||
* something else.
|
||||
*/
|
||||
|
||||
/**
|
||||
*********************************************************************
|
||||
* Changes to this file need to be approved by the Angular CLI team. *
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
import * as ts from 'typescript';
|
||||
|
||||
import {CompilerOptions} from './transformers/api';
|
||||
import {getOriginalReferences} from './transformers/compiler_host';
|
||||
import {createProgram} from './transformers/entry_points';
|
||||
|
||||
export interface NgTools_InternalApi_NG2_CodeGen_Options {
|
||||
basePath: string;
|
||||
compilerOptions: ts.CompilerOptions;
|
||||
program: ts.Program;
|
||||
host: ts.CompilerHost;
|
||||
|
||||
angularCompilerOptions: CompilerOptions;
|
||||
|
||||
// i18n options.
|
||||
i18nFormat?: string;
|
||||
i18nFile?: string;
|
||||
locale?: string;
|
||||
missingTranslation?: string;
|
||||
|
||||
readResource: (fileName: string) => Promise<string>;
|
||||
|
||||
// Every new property under this line should be optional.
|
||||
}
|
||||
|
||||
export interface NgTools_InternalApi_NG2_ListLazyRoutes_Options {
|
||||
program: ts.Program;
|
||||
host: ts.CompilerHost;
|
||||
angularCompilerOptions: CompilerOptions;
|
||||
entryModule: string;
|
||||
|
||||
// Every new property under this line should be optional.
|
||||
}
|
||||
|
||||
export interface NgTools_InternalApi_NG_2_LazyRouteMap { [route: string]: string; }
|
||||
|
||||
export interface NgTools_InternalApi_NG2_ExtractI18n_Options {
|
||||
basePath: string;
|
||||
compilerOptions: ts.CompilerOptions;
|
||||
program: ts.Program;
|
||||
host: ts.CompilerHost;
|
||||
angularCompilerOptions: CompilerOptions;
|
||||
i18nFormat?: string;
|
||||
readResource: (fileName: string) => Promise<string>;
|
||||
// Every new property under this line should be optional.
|
||||
locale?: string;
|
||||
outFile?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @deprecatd Use ngtools_api2 instead!
|
||||
*/
|
||||
export class NgTools_InternalApi_NG_2 {
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
static codeGen(options: NgTools_InternalApi_NG2_CodeGen_Options): Promise<any> {
|
||||
throw throwNotSupportedError();
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
static listLazyRoutes(options: NgTools_InternalApi_NG2_ListLazyRoutes_Options):
|
||||
NgTools_InternalApi_NG_2_LazyRouteMap {
|
||||
// TODO(tbosch): Also throwNotSupportedError once Angular CLI 1.5.1 ships,
|
||||
// as we only needed this to support Angular CLI 1.5.0 rc.*
|
||||
const ngProgram = createProgram({
|
||||
rootNames: options.program.getRootFileNames(),
|
||||
options: {...options.angularCompilerOptions, collectAllErrors: true},
|
||||
host: options.host
|
||||
});
|
||||
const lazyRoutes = ngProgram.listLazyRoutes(options.entryModule);
|
||||
|
||||
// reset the referencedFiles that the ng.Program added to the SourceFiles
|
||||
// as the host might be caching the source files!
|
||||
for (const sourceFile of options.program.getSourceFiles()) {
|
||||
const originalReferences = getOriginalReferences(sourceFile);
|
||||
if (originalReferences) {
|
||||
sourceFile.referencedFiles = originalReferences;
|
||||
}
|
||||
}
|
||||
|
||||
const result: NgTools_InternalApi_NG_2_LazyRouteMap = {};
|
||||
lazyRoutes.forEach(lazyRoute => {
|
||||
const route = lazyRoute.route;
|
||||
const referencedFilePath = lazyRoute.referencedModule.filePath;
|
||||
if (result[route] && result[route] != referencedFilePath) {
|
||||
throw new Error(
|
||||
`Duplicated path in loadChildren detected: "${route}" is used in 2 loadChildren, ` +
|
||||
`but they point to different modules "(${result[route]} and ` +
|
||||
`"${referencedFilePath}"). Webpack cannot distinguish on context and would fail to ` +
|
||||
'load the proper one.');
|
||||
}
|
||||
result[route] = referencedFilePath;
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
static extractI18n(options: NgTools_InternalApi_NG2_ExtractI18n_Options): Promise<any> {
|
||||
throw throwNotSupportedError();
|
||||
}
|
||||
}
|
||||
|
||||
function throwNotSupportedError() {
|
||||
throw new Error(`Please update @angular/cli. Angular 5+ requires at least Angular CLI 1.5+`);
|
||||
}
|
||||
@@ -1,149 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a private API for @ngtools/webpack. This API should be stable for NG 5.
|
||||
*
|
||||
* It contains copies of the interfaces needed and wrapper functions to ensure that
|
||||
* they are not broken accidentally.
|
||||
*
|
||||
* Once the ngc api is public and stable, this can be removed.
|
||||
*/
|
||||
|
||||
/**
|
||||
*********************************************************************
|
||||
* Changes to this file need to be approved by the Angular CLI team. *
|
||||
*********************************************************************
|
||||
*/
|
||||
|
||||
import {ParseSourceSpan} from '@angular/compiler';
|
||||
import * as ts from 'typescript';
|
||||
|
||||
import {formatDiagnostics as formatDiagnosticsOrig} from './perform_compile';
|
||||
import {createCompilerHost as createCompilerOrig} from './transformers/compiler_host';
|
||||
import {createProgram as createProgramOrig} from './transformers/program';
|
||||
|
||||
|
||||
// Interfaces from ./transformers/api;
|
||||
export interface Diagnostic {
|
||||
messageText: string;
|
||||
span?: ParseSourceSpan;
|
||||
category: ts.DiagnosticCategory;
|
||||
code: number;
|
||||
source: 'angular';
|
||||
}
|
||||
|
||||
export interface CompilerOptions extends ts.CompilerOptions {
|
||||
basePath?: string;
|
||||
skipMetadataEmit?: boolean;
|
||||
strictMetadataEmit?: boolean;
|
||||
skipTemplateCodegen?: boolean;
|
||||
flatModuleOutFile?: string;
|
||||
flatModuleId?: string;
|
||||
generateCodeForLibraries?: boolean;
|
||||
annotateForClosureCompiler?: boolean;
|
||||
annotationsAs?: 'decorators'|'static fields';
|
||||
trace?: boolean;
|
||||
disableExpressionLowering?: boolean;
|
||||
i18nOutLocale?: string;
|
||||
i18nOutFormat?: string;
|
||||
i18nOutFile?: string;
|
||||
i18nInFormat?: string;
|
||||
i18nInLocale?: string;
|
||||
i18nInFile?: string;
|
||||
i18nInMissingTranslations?: 'error'|'warning'|'ignore';
|
||||
preserveWhitespaces?: boolean;
|
||||
disableTypeScriptVersionCheck?: boolean;
|
||||
}
|
||||
|
||||
export interface CompilerHost extends ts.CompilerHost {
|
||||
moduleNameToFileName?(moduleName: string, containingFile?: string): string|null;
|
||||
fileNameToModuleName?(importedFilePath: string, containingFilePath: string): string;
|
||||
resourceNameToFileName?(resourceName: string, containingFilePath: string): string|null;
|
||||
toSummaryFileName?(fileName: string, referringSrcFileName: string): string;
|
||||
fromSummaryFileName?(fileName: string, referringLibFileName: string): string;
|
||||
readResource?(fileName: string): Promise<string>|string;
|
||||
}
|
||||
|
||||
export enum EmitFlags {
|
||||
DTS = 1 << 0,
|
||||
JS = 1 << 1,
|
||||
Metadata = 1 << 2,
|
||||
I18nBundle = 1 << 3,
|
||||
Codegen = 1 << 4,
|
||||
|
||||
Default = DTS | JS | Codegen,
|
||||
All = DTS | JS | Metadata | I18nBundle | Codegen,
|
||||
}
|
||||
|
||||
export interface CustomTransformers {
|
||||
beforeTs?: ts.TransformerFactory<ts.SourceFile>[];
|
||||
afterTs?: ts.TransformerFactory<ts.SourceFile>[];
|
||||
}
|
||||
|
||||
export interface TsEmitArguments {
|
||||
program: ts.Program;
|
||||
host: CompilerHost;
|
||||
options: CompilerOptions;
|
||||
targetSourceFile?: ts.SourceFile;
|
||||
writeFile?: ts.WriteFileCallback;
|
||||
cancellationToken?: ts.CancellationToken;
|
||||
emitOnlyDtsFiles?: boolean;
|
||||
customTransformers?: ts.CustomTransformers;
|
||||
}
|
||||
|
||||
export interface TsEmitCallback { (args: TsEmitArguments): ts.EmitResult; }
|
||||
|
||||
export interface LazyRoute {
|
||||
module: {name: string, filePath: string};
|
||||
route: string;
|
||||
referencedModule: {name: string, filePath: string};
|
||||
}
|
||||
|
||||
export interface Program {
|
||||
getTsProgram(): ts.Program;
|
||||
getTsOptionDiagnostics(cancellationToken?: ts.CancellationToken): ReadonlyArray<ts.Diagnostic>;
|
||||
getNgOptionDiagnostics(cancellationToken?: ts.CancellationToken):
|
||||
ReadonlyArray<ts.Diagnostic|Diagnostic>;
|
||||
getTsSyntacticDiagnostics(sourceFile?: ts.SourceFile, cancellationToken?: ts.CancellationToken):
|
||||
ReadonlyArray<ts.Diagnostic>;
|
||||
getNgStructuralDiagnostics(cancellationToken?: ts.CancellationToken): ReadonlyArray<Diagnostic>;
|
||||
getTsSemanticDiagnostics(sourceFile?: ts.SourceFile, cancellationToken?: ts.CancellationToken):
|
||||
ReadonlyArray<ts.Diagnostic>;
|
||||
getNgSemanticDiagnostics(fileName?: string, cancellationToken?: ts.CancellationToken):
|
||||
ReadonlyArray<ts.Diagnostic|Diagnostic>;
|
||||
loadNgStructureAsync(): Promise<void>;
|
||||
listLazyRoutes(entryRoute?: string): LazyRoute[];
|
||||
emit({emitFlags, cancellationToken, customTransformers, emitCallback}: {
|
||||
emitFlags?: EmitFlags,
|
||||
cancellationToken?: ts.CancellationToken,
|
||||
customTransformers?: CustomTransformers,
|
||||
emitCallback?: TsEmitCallback
|
||||
}): ts.EmitResult;
|
||||
}
|
||||
|
||||
// Wrapper for createProgram.
|
||||
export function createProgram(
|
||||
{rootNames, options, host, oldProgram}:
|
||||
{rootNames: string[], options: CompilerOptions, host: CompilerHost, oldProgram?: Program}):
|
||||
Program {
|
||||
return createProgramOrig({rootNames, options, host, oldProgram: oldProgram as any});
|
||||
}
|
||||
|
||||
// Wrapper for createCompilerHost.
|
||||
export function createCompilerHost(
|
||||
{options, tsHost = ts.createCompilerHost(options, true)}:
|
||||
{options: CompilerOptions, tsHost?: ts.CompilerHost}): CompilerHost {
|
||||
return createCompilerOrig({options, tsHost});
|
||||
}
|
||||
|
||||
// Wrapper for formatDiagnostics.
|
||||
export type Diagnostics = ReadonlyArray<ts.Diagnostic|Diagnostic>;
|
||||
export function formatDiagnostics(diags: Diagnostics): string {
|
||||
return formatDiagnosticsOrig(diags);
|
||||
}
|
||||
Reference in New Issue
Block a user