fix(compiler): make `.ngsummary.json` files idempotent (#21448)
Fixes: #21432 PR Close #21448
This commit is contained in:
parent
6be9c0466c
commit
e64b1e99c2
|
@ -488,6 +488,10 @@ export class TsCompilerAotCompilerTypeCheckHostAdapter implements ts.CompilerHos
|
||||||
return assert(this.context.readFile(filePath));
|
return assert(this.context.readFile(filePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getOutputName(filePath: string): string {
|
||||||
|
return path.relative(this.getCurrentDirectory(), filePath);
|
||||||
|
}
|
||||||
|
|
||||||
private hasBundleIndex(filePath: string): boolean {
|
private hasBundleIndex(filePath: string): boolean {
|
||||||
const checkBundleIndex = (directory: string): boolean => {
|
const checkBundleIndex = (directory: string): boolean => {
|
||||||
let result = this.flatModuleIndexCache.get(directory);
|
let result = this.flatModuleIndexCache.get(directory);
|
||||||
|
|
|
@ -39,6 +39,12 @@ export interface StaticSymbolResolverHost {
|
||||||
* `path/to/containingFile.ts` containing `import {...} from 'module-name'`.
|
* `path/to/containingFile.ts` containing `import {...} from 'module-name'`.
|
||||||
*/
|
*/
|
||||||
moduleNameToFileName(moduleName: string, containingFile?: string): string|null;
|
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;
|
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`
|
// .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.
|
// location as it is not important to finding the file.
|
||||||
_originalFileMemo =
|
_originalFileMemo =
|
||||||
topLevelPath.replace(/((\.ts)|(\.d\.ts)|)$/, '.ts').replace(/^.*node_modules[/\\]/, '');
|
this.host.getOutputName(topLevelPath.replace(/((\.ts)|(\.d\.ts)|)$/, '.ts')
|
||||||
|
.replace(/^.*node_modules[/\\]/, ''));
|
||||||
}
|
}
|
||||||
return _originalFileMemo;
|
return _originalFileMemo;
|
||||||
};
|
};
|
||||||
|
|
|
@ -496,6 +496,8 @@ export class MockStaticSymbolResolverHost implements StaticSymbolResolverHost {
|
||||||
|
|
||||||
getMetadataFor(moduleId: string): any { return this._getMetadataFor(moduleId); }
|
getMetadataFor(moduleId: string): any { return this._getMetadataFor(moduleId); }
|
||||||
|
|
||||||
|
getOutputName(filePath: string): string { return filePath; }
|
||||||
|
|
||||||
private _getMetadataFor(filePath: string): any {
|
private _getMetadataFor(filePath: string): any {
|
||||||
if (this.data[filePath] && filePath.match(TS_EXT)) {
|
if (this.data[filePath] && filePath.match(TS_EXT)) {
|
||||||
const text = this.data[filePath];
|
const text = this.data[filePath];
|
||||||
|
|
|
@ -386,6 +386,8 @@ export class MockAotCompilerHost implements AotCompilerHost {
|
||||||
return resolved ? resolved.resolvedFileName : null;
|
return resolved ? resolved.resolvedFileName : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getOutputName(filePath: string) { return filePath; }
|
||||||
|
|
||||||
resourceNameToFileName(resourceName: string, containingFile: string) {
|
resourceNameToFileName(resourceName: string, containingFile: string) {
|
||||||
// Note: we convert package paths into relative paths to be compatible with the the
|
// Note: we convert package paths into relative paths to be compatible with the the
|
||||||
// previous implementation of UrlResolver.
|
// previous implementation of UrlResolver.
|
||||||
|
|
|
@ -76,4 +76,6 @@ export class ReflectorHost implements StaticSymbolResolverHost {
|
||||||
.resolvedModule;
|
.resolvedModule;
|
||||||
return resolved ? resolved.resolvedFileName : null;
|
return resolved ? resolved.resolvedFileName : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getOutputName(filePath: string) { return filePath; }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue