diff --git a/build/azure-pipelines/common/computeNodeModulesCacheKey.js b/build/azure-pipelines/common/computeNodeModulesCacheKey.js index b471d5c84cc..d15ceb6ef08 100644 --- a/build/azure-pipelines/common/computeNodeModulesCacheKey.js +++ b/build/azure-pipelines/common/computeNodeModulesCacheKey.js @@ -13,8 +13,17 @@ const shasum = crypto.createHash('sha1'); shasum.update(fs.readFileSync(path.join(ROOT, 'build/.cachesalt'))); shasum.update(fs.readFileSync(path.join(ROOT, '.yarnrc'))); shasum.update(fs.readFileSync(path.join(ROOT, 'remote/.yarnrc'))); -// Add `yarn.lock` files +// Add `package.json` and `yarn.lock` files for (let dir of dirs) { + const packageJsonPath = path.join(ROOT, dir, 'package.json'); + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString()); + const relevantPackageJsonSections = { + dependencies: packageJson.dependencies, + devDependencies: packageJson.devDependencies, + optionalDependencies: packageJson.optionalDependencies, + resolutions: packageJson.resolutions + }; + shasum.update(JSON.stringify(relevantPackageJsonSections)); const yarnLockPath = path.join(ROOT, dir, 'yarn.lock'); shasum.update(fs.readFileSync(yarnLockPath)); }