Skip to content

Commit a931a41

Browse files
chuckjazalexeagle
authored andcommitted
fix(compiler): make .ngsummary.json files idempotent (#21448)
Fixes: #21432 PR Close #21448
1 parent 6a97b5b commit a931a41

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

packages/compiler-cli/src/transformers/compiler_host.ts

+4
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,10 @@ export class TsCompilerAotCompilerTypeCheckHostAdapter implements ts.CompilerHos
488488
return assert(this.context.readFile(filePath));
489489
}
490490

491+
getOutputName(filePath: string): string {
492+
return path.relative(this.getCurrentDirectory(), filePath);
493+
}
494+
491495
private hasBundleIndex(filePath: string): boolean {
492496
const checkBundleIndex = (directory: string): boolean => {
493497
let result = this.flatModuleIndexCache.get(directory);

packages/compiler/src/aot/static_symbol_resolver.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ export interface StaticSymbolResolverHost {
3939
* `path/to/containingFile.ts` containing `import {...} from 'module-name'`.
4040
*/
4141
moduleNameToFileName(moduleName: string, containingFile?: string): string|null;
42+
43+
/**
44+
* Get a file suitable for display to the user that should be relative to the project directory
45+
* or the current directory.
46+
*/
47+
getOutputName(filePath: string): string;
4248
}
4349

4450
const SUPPORTED_SCHEMA_VERSION = 4;
@@ -382,7 +388,8 @@ export class StaticSymbolResolver {
382388
// .ts or .d.ts, append `.ts'. Also, if it is in `node_modules`, trim the `node_module`
383389
// location as it is not important to finding the file.
384390
_originalFileMemo =
385-
topLevelPath.replace(/((\.ts)|(\.d\.ts)|)$/, '.ts').replace(/^.*node_modules[/\\]/, '');
391+
this.host.getOutputName(topLevelPath.replace(/((\.ts)|(\.d\.ts)|)$/, '.ts')
392+
.replace(/^.*node_modules[/\\]/, ''));
386393
}
387394
return _originalFileMemo;
388395
};

packages/compiler/test/aot/static_symbol_resolver_spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,8 @@ export class MockStaticSymbolResolverHost implements StaticSymbolResolverHost {
496496

497497
getMetadataFor(moduleId: string): any { return this._getMetadataFor(moduleId); }
498498

499+
getOutputName(filePath: string): string { return filePath; }
500+
499501
private _getMetadataFor(filePath: string): any {
500502
if (this.data[filePath] && filePath.match(TS_EXT)) {
501503
const text = this.data[filePath];

packages/compiler/test/aot/test_util.ts

+2
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,8 @@ export class MockAotCompilerHost implements AotCompilerHost {
386386
return resolved ? resolved.resolvedFileName : null;
387387
}
388388

389+
getOutputName(filePath: string) { return filePath; }
390+
389391
resourceNameToFileName(resourceName: string, containingFile: string) {
390392
// Note: we convert package paths into relative paths to be compatible with the the
391393
// previous implementation of UrlResolver.

packages/language-service/src/reflector_host.ts

+2
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,6 @@ export class ReflectorHost implements StaticSymbolResolverHost {
7676
.resolvedModule;
7777
return resolved ? resolved.resolvedFileName : null;
7878
}
79+
80+
getOutputName(filePath: string) { return filePath; }
7981
}

0 commit comments

Comments
 (0)