From f2c78d04ff35688571a66d66c8a2c7c17a095444 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Tue, 29 Aug 2023 09:12:28 +0300 Subject: [PATCH] fix: optimize getGlobalCacheKey (#14455) --- CHANGELOG.md | 4 ++++ packages/jest-create-cache-key-function/src/index.ts | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) 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 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)), ]