Skip to content

Commit f2c78d0

Browse files
authored
fix: optimize getGlobalCacheKey (#14455)
1 parent 7ed8025 commit f2c78d0

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
### Fixes
66

7+
### Performance
8+
9+
- `[@jest/create-cache-key-function]` Cache access of `NODE_ENV` and `BABEL_ENV` ([#14455](https://github.com/jestjs/jest/pull/14455))
10+
711
### Chore & Maintenance
812

913
## 29.6.4

packages/jest-create-cache-key-function/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@ type NewGetCacheKeyFunction = (
4040

4141
type GetCacheKeyFunction = OldGetCacheKeyFunction | NewGetCacheKeyFunction;
4242

43+
const {NODE_ENV, BABEL_ENV} = process.env;
44+
4345
function getGlobalCacheKey(
4446
files: Array<string>,
4547
values: Array<string>,
4648
length: number,
4749
) {
4850
return [
49-
process.env.NODE_ENV,
50-
process.env.BABEL_ENV,
51+
NODE_ENV,
52+
BABEL_ENV,
5153
...values,
5254
...files.map((file: string) => readFileSync(file)),
5355
]

0 commit comments

Comments
 (0)