diff --git a/packages/compiler-cli/src/ngtsc/compiler_host.ts b/packages/compiler-cli/src/ngtsc/compiler_host.ts deleted file mode 100644 index d8fef66138..0000000000 --- a/packages/compiler-cli/src/ngtsc/compiler_host.ts +++ /dev/null @@ -1,77 +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 - */ - -import * as ts from 'typescript'; - -/** - * The TypeScript compiler host used by `ngtsc`. - * - * It's mostly identical to the native `CompilerHost`, but also includes the ability to - * asynchronously resolve resources. - */ -export interface CompilerHost extends ts.CompilerHost { - /** - * Begin processing a resource file. - * - * When the returned Promise resolves, `loadResource` should be able to synchronously produce a - * `string` for the given file. - */ - preloadResource(file: string): Promise; - - /** - * Like `readFile`, but reads the contents of a resource file which may have been pre-processed - * by `preloadResource`. - */ - loadResource(file: string): string|undefined; -} - -/** - * Implementation of `CompilerHost` which delegates to a native TypeScript host in most cases. - */ -export class NgtscCompilerHost implements CompilerHost { - constructor(private delegate: ts.CompilerHost) {} - - getSourceFile( - fileName: string, languageVersion: ts.ScriptTarget, - onError?: ((message: string) => void)|undefined, - shouldCreateNewSourceFile?: boolean|undefined): ts.SourceFile|undefined { - return this.delegate.getSourceFile( - fileName, languageVersion, onError, shouldCreateNewSourceFile); - } - - getDefaultLibFileName(options: ts.CompilerOptions): string { - return this.delegate.getDefaultLibFileName(options); - } - - writeFile( - fileName: string, data: string, writeByteOrderMark: boolean, - onError: ((message: string) => void)|undefined, - sourceFiles: ReadonlyArray): void { - return this.delegate.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); - } - - getCurrentDirectory(): string { return this.delegate.getCurrentDirectory(); } - - getDirectories(path: string): string[] { return this.delegate.getDirectories(path); } - - getCanonicalFileName(fileName: string): string { - return this.delegate.getCanonicalFileName(fileName); - } - - useCaseSensitiveFileNames(): boolean { return this.delegate.useCaseSensitiveFileNames(); } - - getNewLine(): string { return this.delegate.getNewLine(); } - - fileExists(fileName: string): boolean { return this.delegate.fileExists(fileName); } - - readFile(fileName: string): string|undefined { return this.delegate.readFile(fileName); } - - loadResource(file: string): string|undefined { throw new Error('Method not implemented.'); } - - preloadResource(file: string): Promise { throw new Error('Method not implemented.'); } -} diff --git a/packages/compiler-cli/src/ngtsc/program.ts b/packages/compiler-cli/src/ngtsc/program.ts index d2e5731ab3..54ca39ea67 100644 --- a/packages/compiler-cli/src/ngtsc/program.ts +++ b/packages/compiler-cli/src/ngtsc/program.ts @@ -13,7 +13,6 @@ import * as ts from 'typescript'; import * as api from '../transformers/api'; import {ComponentDecoratorHandler, DirectiveDecoratorHandler, InjectableDecoratorHandler, NgModuleDecoratorHandler, PipeDecoratorHandler, ResourceLoader, SelectorScopeRegistry} from './annotations'; -import {CompilerHost} from './compiler_host'; import {TypeScriptReflectionHost} from './metadata'; import {FileResourceLoader, HostResourceLoader} from './resource_loader'; import {IvyCompilation, ivyTransformFactory} from './transform'; diff --git a/packages/compiler-cli/src/transformers/compiler_host.ts b/packages/compiler-cli/src/transformers/compiler_host.ts index 683d4a05c3..5472045d56 100644 --- a/packages/compiler-cli/src/transformers/compiler_host.ts +++ b/packages/compiler-cli/src/transformers/compiler_host.ts @@ -12,7 +12,6 @@ import * as ts from 'typescript'; import {TypeCheckHost} from '../diagnostics/translate_diagnostics'; import {METADATA_VERSION, ModuleMetadata} from '../metadata/index'; -import {NgtscCompilerHost} from '../ngtsc/compiler_host'; import {CompilerHost, CompilerOptions, LibrarySummary} from './api'; import {MetadataReaderHost, createMetadataReaderCache, readMetadata} from './metadata_reader'; @@ -24,9 +23,6 @@ const EXT = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/; export function createCompilerHost( {options, tsHost = ts.createCompilerHost(options, true)}: {options: CompilerOptions, tsHost?: ts.CompilerHost}): CompilerHost { - if (options.enableIvy === 'ngtsc' || options.enableIvy === 'tsc') { - return new NgtscCompilerHost(tsHost); - } return tsHost; }