fix(compiler): make `.ngsummary.json` files idempotent (#21448)

Fixes: #21432

PR Close #21448
This commit is contained in:
Chuck Jazdzewski 2018-01-10 09:55:03 -08:00 committed by Alex Eagle
parent 6be9c0466c
commit e64b1e99c2
5 changed files with 18 additions and 1 deletions

View File

@ -488,6 +488,10 @@ export class TsCompilerAotCompilerTypeCheckHostAdapter implements ts.CompilerHos
return assert(this.context.readFile(filePath));
}
getOutputName(filePath: string): string {
return path.relative(this.getCurrentDirectory(), filePath);
}
private hasBundleIndex(filePath: string): boolean {
const checkBundleIndex = (directory: string): boolean => {
let result = this.flatModuleIndexCache.get(directory);

View File

@ -39,6 +39,12 @@ export interface StaticSymbolResolverHost {
* `path/to/containingFile.ts` containing `import {...} from 'module-name'`.
*/
moduleNameToFileName(moduleName: string, containingFile?: string): string|null;
/**
* Get a file suitable for display to the user that should be relative to the project directory
* or the current directory.
*/
getOutputName(filePath: string): string;
}
const SUPPORTED_SCHEMA_VERSION = 4;
@ -382,7 +388,8 @@ export class StaticSymbolResolver {
// .ts or .d.ts, append `.ts'. Also, if it is in `node_modules`, trim the `node_module`
// location as it is not important to finding the file.
_originalFileMemo =
topLevelPath.replace(/((\.ts)|(\.d\.ts)|)$/, '.ts').replace(/^.*node_modules[/\\]/, '');
this.host.getOutputName(topLevelPath.replace(/((\.ts)|(\.d\.ts)|)$/, '.ts')
.replace(/^.*node_modules[/\\]/, ''));
}
return _originalFileMemo;
};

View File

@ -496,6 +496,8 @@ export class MockStaticSymbolResolverHost implements StaticSymbolResolverHost {
getMetadataFor(moduleId: string): any { return this._getMetadataFor(moduleId); }
getOutputName(filePath: string): string { return filePath; }
private _getMetadataFor(filePath: string): any {
if (this.data[filePath] && filePath.match(TS_EXT)) {
const text = this.data[filePath];

View File

@ -386,6 +386,8 @@ export class MockAotCompilerHost implements AotCompilerHost {
return resolved ? resolved.resolvedFileName : null;
}
getOutputName(filePath: string) { return filePath; }
resourceNameToFileName(resourceName: string, containingFile: string) {
// Note: we convert package paths into relative paths to be compatible with the the
// previous implementation of UrlResolver.

View File

@ -76,4 +76,6 @@ export class ReflectorHost implements StaticSymbolResolverHost {
.resolvedModule;
return resolved ? resolved.resolvedFileName : null;
}
getOutputName(filePath: string) { return filePath; }
}