From b450eb19fdf83357334ac841eeffbb1efd992e91 Mon Sep 17 00:00:00 2001 From: Mikhail Bodrov Date: Sun, 27 Aug 2023 19:55:30 +0300 Subject: [PATCH 1/2] fix: optimize getGlobalCacheKey --- packages/jest-create-cache-key-function/src/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/jest-create-cache-key-function/src/index.ts b/packages/jest-create-cache-key-function/src/index.ts index 215a3f4cc2ac..b51583f6f28a 100644 --- a/packages/jest-create-cache-key-function/src/index.ts +++ b/packages/jest-create-cache-key-function/src/index.ts @@ -40,14 +40,16 @@ type NewGetCacheKeyFunction = ( type GetCacheKeyFunction = OldGetCacheKeyFunction | NewGetCacheKeyFunction; +const {NODE_ENV, BABEL_ENV} = process.env; + function getGlobalCacheKey( files: Array, values: Array, length: number, ) { return [ - process.env.NODE_ENV, - process.env.BABEL_ENV, + NODE_ENV, + BABEL_ENV, ...values, ...files.map((file: string) => readFileSync(file)), ] From 920bb754c2bdf962d41ad1d871caa8a250878c62 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Tue, 29 Aug 2023 08:11:45 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cbc3a0b9fc3..c7c34ab955b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ ### Fixes +### Performance + +- `[@jest/create-cache-key-function]` Cache access of `NODE_ENV` and `BABEL_ENV` ([#14455](https://github.com/jestjs/jest/pull/14455)) + ### Chore & Maintenance ## 29.6.4