From b8ef83b10f7b521fd998376b0cb33c68cc49f388 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Wed, 16 Jun 2021 12:25:13 +0100 Subject: [PATCH] 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 --- packages/compiler-cli/ngcc/src/packages/configuration.ts | 6 +++--- .../compiler-cli/ngcc/src/packages/entry_point_manifest.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/compiler-cli/ngcc/src/packages/configuration.ts b/packages/compiler-cli/ngcc/src/packages/configuration.ts index 1c1ef82b5e..033f1f77dd 100644 --- a/packages/compiler-cli/ngcc/src/packages/configuration.ts +++ b/packages/compiler-cli/ngcc/src/packages/configuration.ts @@ -236,10 +236,12 @@ export class NgccConfiguration { private projectConfig: PartiallyProcessedConfig; private cache = new Map(); 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'); } } diff --git a/packages/compiler-cli/ngcc/src/packages/entry_point_manifest.ts b/packages/compiler-cli/ngcc/src/packages/entry_point_manifest.ts index 3c951dd5b5..e689c5e756 100644 --- a/packages/compiler-cli/ngcc/src/packages/entry_point_manifest.ts +++ b/packages/compiler-cli/ngcc/src/packages/entry_point_manifest.ts @@ -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;