Revert "feat(compiler-cli): add watch mode to ngc (#18818)"

This reverts commit 06d01b2287.
This commit is contained in:
Jason Aden
2017-08-30 19:02:03 -07:00
parent c2136d18bd
commit 3a6d270bb8
18 changed files with 54 additions and 539 deletions

View File

@ -42,8 +42,8 @@ export class AotCompiler {
analyzeModulesSync(rootFiles: string[]): NgAnalyzedModules {
const programSymbols = extractProgramSymbols(this._symbolResolver, rootFiles, this._host);
const analyzeResult = analyzeAndValidateNgModules(
programSymbols, this._host, this._symbolResolver, this._metadataResolver);
const analyzeResult =
analyzeAndValidateNgModules(programSymbols, this._host, this._metadataResolver);
analyzeResult.ngModules.forEach(
ngModule => this._metadataResolver.loadNgModuleDirectiveAndPipeMetadata(
ngModule.type.reference, true));
@ -52,8 +52,8 @@ export class AotCompiler {
analyzeModulesAsync(rootFiles: string[]): Promise<NgAnalyzedModules> {
const programSymbols = extractProgramSymbols(this._symbolResolver, rootFiles, this._host);
const analyzeResult = analyzeAndValidateNgModules(
programSymbols, this._host, this._symbolResolver, this._metadataResolver);
const analyzeResult =
analyzeAndValidateNgModules(programSymbols, this._host, this._metadataResolver);
return Promise
.all(analyzeResult.ngModules.map(
ngModule => this._metadataResolver.loadNgModuleDirectiveAndPipeMetadata(
@ -400,24 +400,16 @@ export interface NgAnalyzeModulesHost { isSourceFile(filePath: string): boolean;
// Returns all the source files and a mapping from modules to directives
export function analyzeNgModules(
programStaticSymbols: StaticSymbol[], host: NgAnalyzeModulesHost,
staticSymbolResolver: StaticSymbolResolver,
metadataResolver: CompileMetadataResolver): NgAnalyzedModules {
const programStaticSymbolsWithDecorators = programStaticSymbols.filter(
symbol => !symbol.filePath.endsWith('.d.ts') ||
staticSymbolResolver.hasDecorators(symbol.filePath));
const {ngModules, symbolsMissingModule} =
_createNgModules(programStaticSymbolsWithDecorators, host, metadataResolver);
return _analyzeNgModules(
programStaticSymbols, programStaticSymbolsWithDecorators, ngModules, symbolsMissingModule,
metadataResolver);
_createNgModules(programStaticSymbols, host, metadataResolver);
return _analyzeNgModules(programStaticSymbols, ngModules, symbolsMissingModule, metadataResolver);
}
export function analyzeAndValidateNgModules(
programStaticSymbols: StaticSymbol[], host: NgAnalyzeModulesHost,
staticSymbolResolver: StaticSymbolResolver,
metadataResolver: CompileMetadataResolver): NgAnalyzedModules {
const result =
analyzeNgModules(programStaticSymbols, host, staticSymbolResolver, metadataResolver);
const result = analyzeNgModules(programStaticSymbols, host, metadataResolver);
if (result.symbolsMissingModule && result.symbolsMissingModule.length) {
const messages = result.symbolsMissingModule.map(
s =>
@ -428,8 +420,8 @@ export function analyzeAndValidateNgModules(
}
function _analyzeNgModules(
programSymbols: StaticSymbol[], programSymbolsWithDecorators: StaticSymbol[],
ngModuleMetas: CompileNgModuleMetadata[], symbolsMissingModule: StaticSymbol[],
programSymbols: StaticSymbol[], ngModuleMetas: CompileNgModuleMetadata[],
symbolsMissingModule: StaticSymbol[],
metadataResolver: CompileMetadataResolver): NgAnalyzedModules {
const moduleMetasByRef = new Map<any, CompileNgModuleMetadata>();
ngModuleMetas.forEach((ngModule) => moduleMetasByRef.set(ngModule.type.reference, ngModule));
@ -444,10 +436,7 @@ function _analyzeNgModules(
programSymbols.forEach((symbol) => {
const filePath = symbol.filePath;
filePaths.add(filePath);
});
programSymbolsWithDecorators.forEach((symbol) => {
if (metadataResolver.isInjectable(symbol)) {
const filePath = symbol.filePath;
ngInjectablesByFile.set(filePath, (ngInjectablesByFile.get(filePath) || []).concat(symbol));
}
});

View File

@ -250,24 +250,6 @@ export class StaticSymbolResolver {
return this.staticSymbolCache.get(declarationFile, name, members);
}
/**
* hasDecorators checks a file's metadata for the presense of decorators without evalutating the
* metada.
*
* @param filePath the absolute path to examine for decorators.
* @returns true if any class in the file has a decorator.
*/
hasDecorators(filePath: string): boolean {
const metadata = this.getModuleMetadata(filePath);
if (metadata['metadata']) {
return Object.keys(metadata['metadata']).some((metadataKey) => {
const entry = metadata['metadata'][metadataKey];
return entry && entry.__symbolic === 'class' && entry.decorators;
});
}
return false;
}
getSymbolsOf(filePath: string): StaticSymbol[] {
// Note: Some users use libraries that were not compiled with ngc, i.e. they don't
// have summaries, only .d.ts files. So we always need to check both, the summary

View File

@ -57,8 +57,8 @@ export class Extractor {
extract(rootFiles: string[]): Promise<MessageBundle> {
const programSymbols = extractProgramSymbols(this.staticSymbolResolver, rootFiles, this.host);
const {files, ngModules} = analyzeAndValidateNgModules(
programSymbols, this.host, this.staticSymbolResolver, this.metadataResolver);
const {files, ngModules} =
analyzeAndValidateNgModules(programSymbols, this.host, this.metadataResolver);
return Promise
.all(ngModules.map(
ngModule => this.metadataResolver.loadNgModuleDirectiveAndPipeMetadata(