refactor(compiler-cli): ngcc entry-point manifest hash is now configurable (#42582)
The hash algorithm for the entry-point manifest was hardcoded to `md5`. This can now be configured by the `hashAlgorithm` property on the ngcc.config.js project configuration. PR Close #42582
This commit is contained in:
parent
a3b6d65580
commit
b8ef83b10f
@ -236,10 +236,12 @@ export class NgccConfiguration {
|
||||
private projectConfig: PartiallyProcessedConfig;
|
||||
private cache = new Map<string, VersionedPackageConfig>();
|
||||
readonly hash: string;
|
||||
readonly hashAlgorithm: string;
|
||||
|
||||
constructor(private fs: ReadonlyFileSystem, baseDir: AbsoluteFsPath) {
|
||||
this.defaultConfig = this.processProjectConfig(DEFAULT_NGCC_CONFIG);
|
||||
this.projectConfig = this.processProjectConfig(this.loadProjectConfig(baseDir));
|
||||
this.hashAlgorithm = this.projectConfig.hashAlgorithm;
|
||||
this.hash = this.computeHash();
|
||||
}
|
||||
|
||||
@ -390,9 +392,7 @@ export class NgccConfiguration {
|
||||
}
|
||||
|
||||
private computeHash(): string {
|
||||
return createHash(this.projectConfig.hashAlgorithm)
|
||||
.update(JSON.stringify(this.projectConfig))
|
||||
.digest('hex');
|
||||
return createHash(this.hashAlgorithm).update(JSON.stringify(this.projectConfig)).digest('hex');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ export class EntryPointManifest {
|
||||
const lockFilePath = this.fs.resolve(directory, lockFileName);
|
||||
if (this.fs.exists(lockFilePath)) {
|
||||
const lockFileContents = this.fs.readFile(lockFilePath);
|
||||
return createHash('md5').update(lockFileContents).digest('hex');
|
||||
return createHash(this.config.hashAlgorithm).update(lockFileContents).digest('hex');
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user