Skip to content

Commit 7e51ac1

Browse files
authored
fix: revert usage of Escalade and yargs@16 as they breaks Node 13 (#10599)
1 parent 75bf038 commit 7e51ac1

File tree

7 files changed

+18
-88
lines changed

7 files changed

+18
-88
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Fixes
66

7+
- `[*]` Revert usage of Escalade and rollback Yargs to v15 as it breaks Node 13 ([#10599](https://github.com/facebook/jest/pull/10599))
78
- `[jest-circus]` Setup globals before emitting `setup`, and include Jest globals in the `setup` payload ([#10598](https://github.com/facebook/jest/pull/10598))
89
- `[jest-mock]` Fix typings for `mockResolvedValue`, `mockResolvedValueOnce`, `mockRejectedValue` and `mockRejectedValueOnce` ([#10600](https://github.com/facebook/jest/pull/10600))
910

packages/jest-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"jest-util": "^26.5.0",
1818
"jest-validate": "^26.5.0",
1919
"prompts": "^2.0.1",
20-
"yargs": "^16.0.3"
20+
"yargs": "^15.4.1"
2121
},
2222
"devDependencies": {
2323
"@jest/test-utils": "^26.5.0",

packages/jest-repl/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"jest-runtime": "^26.5.0",
1717
"jest-validate": "^26.5.0",
1818
"repl": "^0.1.3",
19-
"yargs": "^16.0.3"
19+
"yargs": "^15.4.1"
2020
},
2121
"devDependencies": {
2222
"@jest/test-utils": "^26.5.0",

packages/jest-resolve/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
"dependencies": {
1313
"@jest/types": "^26.5.0",
1414
"chalk": "^4.0.0",
15-
"escalade": "^3.1.0",
1615
"graceful-fs": "^4.2.4",
1716
"jest-pnp-resolver": "^1.2.2",
1817
"jest-util": "^26.5.0",
18+
"read-pkg-up": "^7.0.1",
1919
"resolve": "^1.17.0",
2020
"slash": "^3.0.0"
2121
},

packages/jest-resolve/src/shouldLoadAsEsm.ts

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,17 @@
88
import {dirname, extname} from 'path';
99
// @ts-expect-error: experimental, not added to the types
1010
import {SyntheticModule} from 'vm';
11-
import {readFileSync} from 'graceful-fs';
12-
import escalade from 'escalade/sync';
1311
import type {Config} from '@jest/types';
12+
import readPkgUp = require('read-pkg-up');
1413

1514
const runtimeSupportsVmModules = typeof SyntheticModule === 'function';
1615

1716
const cachedFileLookups = new Map<string, boolean>();
1817
const cachedDirLookups = new Map<string, boolean>();
19-
const cachedChecks = new Map<string, boolean>();
2018

2119
export function clearCachedLookups(): void {
2220
cachedFileLookups.clear();
2321
cachedDirLookups.clear();
24-
cachedChecks.clear();
2522
}
2623

2724
export default function cachedShouldLoadAsEsm(path: Config.Path): boolean {
@@ -70,29 +67,12 @@ function shouldLoadAsEsm(path: Config.Path): boolean {
7067
}
7168

7269
function cachedPkgCheck(cwd: Config.Path): boolean {
73-
const pkgPath = escalade(cwd, (_dir, names) => {
74-
if (names.includes('package.json')) {
75-
// will be resolved into absolute
76-
return 'package.json';
77-
}
78-
return false;
79-
});
80-
if (!pkgPath) {
81-
return false;
82-
}
70+
// TODO: can we cache lookups somehow?
71+
const pkg = readPkgUp.sync({cwd, normalize: false});
8372

84-
let hasModuleField = cachedChecks.get(pkgPath);
85-
if (hasModuleField != null) {
86-
return hasModuleField;
87-
}
88-
89-
try {
90-
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
91-
hasModuleField = pkg.type === 'module';
92-
} catch {
93-
hasModuleField = false;
73+
if (!pkg) {
74+
return false;
9475
}
9576

96-
cachedChecks.set(pkgPath, hasModuleField);
97-
return hasModuleField;
77+
return pkg.packageJson.type === 'module';
9878
}

packages/jest-runtime/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"jest-validate": "^26.5.0",
3636
"slash": "^3.0.0",
3737
"strip-bom": "^4.0.0",
38-
"yargs": "^16.0.3"
38+
"yargs": "^15.4.1"
3939
},
4040
"devDependencies": {
4141
"@jest/test-utils": "^26.5.0",

yarn.lock

Lines changed: 7 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -5860,17 +5860,6 @@ __metadata:
58605860
languageName: node
58615861
linkType: hard
58625862

5863-
"cliui@npm:^7.0.0":
5864-
version: 7.0.1
5865-
resolution: "cliui@npm:7.0.1"
5866-
dependencies:
5867-
string-width: ^4.2.0
5868-
strip-ansi: ^6.0.0
5869-
wrap-ansi: ^7.0.0
5870-
checksum: 9c1433067a5860f9b8df76e5e0186a86992a180b8f8dd316357e19aa65b68d46964d448d18991fb598ab638a6c24218ce1331344fa4eec6767fcab40232b19fa
5871-
languageName: node
5872-
linkType: hard
5873-
58745863
"clone-deep@npm:^4.0.1":
58755864
version: 4.0.1
58765865
resolution: "clone-deep@npm:4.0.1"
@@ -7758,7 +7747,7 @@ __metadata:
77587747
languageName: node
77597748
linkType: hard
77607749

7761-
"escalade@npm:^3.0.2, escalade@npm:^3.1.0":
7750+
"escalade@npm:^3.1.0":
77627751
version: 3.1.0
77637752
resolution: "escalade@npm:3.1.0"
77647753
checksum: 437c5b2619a412c0b075fb33e590e3516f187f7da8b20035685e08f346e27842722e5740a3398535d7d590ae4fb70068374ed59190d4eb4f9bb06d052e2fc92f
@@ -9360,7 +9349,7 @@ fsevents@^1.2.7:
93609349
languageName: node
93619350
linkType: hard
93629351

9363-
"get-caller-file@npm:^2.0.1, get-caller-file@npm:^2.0.5":
9352+
"get-caller-file@npm:^2.0.1":
93649353
version: 2.0.5
93659354
resolution: "get-caller-file@npm:2.0.5"
93669355
checksum: 9dd9e1e2591039ee4c38c897365b904f66f1e650a8c1cb7b7db8ce667fa63e88cc8b13282b74df9d93de481114b3304a0487880d31cd926dfda6efe71455855d
@@ -11428,7 +11417,7 @@ fsevents@^1.2.7:
1142811417
jest-util: ^26.5.0
1142911418
jest-validate: ^26.5.0
1143011419
prompts: ^2.0.1
11431-
yargs: ^16.0.3
11420+
yargs: ^15.4.1
1143211421
bin:
1143311422
jest: ./bin/jest.js
1143411423
languageName: unknown
@@ -11746,7 +11735,7 @@ fsevents@^1.2.7:
1174611735
jest-runtime: ^26.5.0
1174711736
jest-validate: ^26.5.0
1174811737
repl: ^0.1.3
11749-
yargs: ^16.0.3
11738+
yargs: ^15.4.1
1175011739
bin:
1175111740
jest-repl: ./bin/jest-repl.js
1175211741
languageName: unknown
@@ -11773,11 +11762,11 @@ fsevents@^1.2.7:
1177311762
"@types/graceful-fs": ^4.1.3
1177411763
"@types/resolve": ^1.17.0
1177511764
chalk: ^4.0.0
11776-
escalade: ^3.1.0
1177711765
graceful-fs: ^4.2.4
1177811766
jest-haste-map: ^26.5.0
1177911767
jest-pnp-resolver: ^1.2.2
1178011768
jest-util: ^26.5.0
11769+
read-pkg-up: ^7.0.1
1178111770
resolve: ^1.17.0
1178211771
slash: ^3.0.0
1178311772
languageName: unknown
@@ -11862,7 +11851,7 @@ fsevents@^1.2.7:
1186211851
jest-validate: ^26.5.0
1186311852
slash: ^3.0.0
1186411853
strip-bom: ^4.0.0
11865-
yargs: ^16.0.3
11854+
yargs: ^15.4.1
1186611855
bin:
1186711856
jest-runtime: ./bin/jest-runtime.js
1186811857
languageName: unknown
@@ -19861,17 +19850,6 @@ fsevents@^1.2.7:
1986119850
languageName: node
1986219851
linkType: hard
1986319852

19864-
"wrap-ansi@npm:^7.0.0":
19865-
version: 7.0.0
19866-
resolution: "wrap-ansi@npm:7.0.0"
19867-
dependencies:
19868-
ansi-styles: ^4.0.0
19869-
string-width: ^4.1.0
19870-
strip-ansi: ^6.0.0
19871-
checksum: 09939dd775ae565bb99a25a6c072fe3775a95fa71751b5533c94265fe986ba3e3ab071a027ab76cf26876bd9afd10ac3c2d06d7c4bcce148bf7d2d9514e3a0df
19872-
languageName: node
19873-
linkType: hard
19874-
1987519853
"wrappy@npm:1":
1987619854
version: 1.0.2
1987719855
resolution: "wrappy@npm:1.0.2"
@@ -20092,13 +20070,6 @@ fsevents@^1.2.7:
2009220070
languageName: node
2009320071
linkType: hard
2009420072

20095-
"y18n@npm:^5.0.1":
20096-
version: 5.0.2
20097-
resolution: "y18n@npm:5.0.2"
20098-
checksum: ba6106061c8ef612d888fa3fca61d094027200c4792275886eca2f82e92b1f24120011cc878d808a38be98c2ed1e3f831117691bf4d526a084e339cbd7c9f587
20099-
languageName: node
20100-
linkType: hard
20101-
2010220073
"yallist@npm:^2.1.2":
2010320074
version: 2.1.2
2010420075
resolution: "yallist@npm:2.1.2"
@@ -20153,13 +20124,6 @@ fsevents@^1.2.7:
2015320124
languageName: node
2015420125
linkType: hard
2015520126

20156-
"yargs-parser@npm:^20.0.0":
20157-
version: 20.2.1
20158-
resolution: "yargs-parser@npm:20.2.1"
20159-
checksum: c4945ade7d792bde00e3f68930f56f1fdd531e501c4ecf944c524c1541c5fe2468c27b4f76b0b459009ef09e338750d01810732f99f0a1fa061af4126cf5f53e
20160-
languageName: node
20161-
linkType: hard
20162-
2016320127
"yargs@npm:^14.2.0, yargs@npm:^14.2.2":
2016420128
version: 14.2.3
2016520129
resolution: "yargs@npm:14.2.3"
@@ -20179,7 +20143,7 @@ fsevents@^1.2.7:
2017920143
languageName: node
2018020144
linkType: hard
2018120145

20182-
"yargs@npm:^15.1.0":
20146+
"yargs@npm:^15.1.0, yargs@npm:^15.4.1":
2018320147
version: 15.4.1
2018420148
resolution: "yargs@npm:15.4.1"
2018520149
dependencies:
@@ -20198,21 +20162,6 @@ fsevents@^1.2.7:
2019820162
languageName: node
2019920163
linkType: hard
2020020164

20201-
"yargs@npm:^16.0.3":
20202-
version: 16.0.3
20203-
resolution: "yargs@npm:16.0.3"
20204-
dependencies:
20205-
cliui: ^7.0.0
20206-
escalade: ^3.0.2
20207-
get-caller-file: ^2.0.5
20208-
require-directory: ^2.1.1
20209-
string-width: ^4.2.0
20210-
y18n: ^5.0.1
20211-
yargs-parser: ^20.0.0
20212-
checksum: 39490963e02bceb73ffff285cd9b241e5b019acbedef456586c97027cc18d0cadb743ad1340ccdc9340d0a21e18176c63b9f8bd90eee64c7e1f512c147aab1c2
20213-
languageName: node
20214-
linkType: hard
20215-
2021620165
"yargs@npm:^2.3.0":
2021720166
version: 2.3.0
2021820167
resolution: "yargs@npm:2.3.0"

0 commit comments

Comments
 (0)