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)), ]