Skip to content

Commit ae57969

Browse files
authored
chore: consolidate upwards traversal to empathic (#18030)
1 parent 827d003 commit ae57969

5 files changed

Lines changed: 17 additions & 36 deletions

File tree

‎packages/babel-core/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@babel/types": "workspace:^",
4949
"@types/gensync": "^1.0.5",
5050
"convert-source-map": "^2.0.0",
51-
"find-up-simple": "^1.0.1",
51+
"empathic": "^2.0.1",
5252
"gensync": "^1.0.0-beta.2",
5353
"import-meta-resolve": "^4.2.0",
5454
"json5": "^2.2.3",

‎packages/babel-core/src/transformation/read-input-source-map-file.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fs from "node:fs";
22
import path from "node:path";
3-
import { findUpSync } from "find-up-simple";
3+
import { up as findPackageUp } from "empathic/package";
44
import { createDebug } from "obug";
55
import convertSourceMap from "convert-source-map";
66
import type { SourceMapConverter } from "convert-source-map";
@@ -20,9 +20,9 @@ function getInputMapPath(
2020
relativeToInputFileDir.startsWith("..") ||
2121
path.isAbsolute(relativeToInputFileDir)
2222
) {
23-
const inputPackageJSONPath = findUpSync("package.json", {
23+
const inputPackageJSONPath = findPackageUp({
2424
cwd: inputFileDir,
25-
stopAt: root,
25+
last: root,
2626
});
2727
const inputFileRoot = inputPackageJSONPath
2828
? path.dirname(inputPackageJSONPath)

‎packages/babel-register/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@cspotcode/source-map-support": "^0.8.1",
1919
"cacache": "20.0.3",
2020
"clone-deep": "^4.0.1",
21-
"find-cache-directory": "^6.0.0",
21+
"empathic": "^2.0.1",
2222
"pirates": "^4.0.6"
2323
},
2424
"peerDependencies": {

‎packages/babel-register/src/worker/cache.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from "node:path";
22
import fs from "node:fs";
33
import os from "node:os";
4-
import findCacheDirectory from "find-cache-directory";
4+
import { cache as findCacheDirectory } from "empathic/package";
55
import cacache from "cacache";
66
import { gzipSync, unzipSync } from "node:zlib";
77

@@ -11,7 +11,7 @@ export default class Cache {
1111
enabled = false;
1212
cacheDir =
1313
process.env.BABEL_CACHE_PATH ||
14-
findCacheDirectory({ name: "@babel/register" }) ||
14+
findCacheDirectory("@babel/register") ||
1515
path.join(os.tmpdir() || os.homedir(), `.babel-register`);
1616
batched: { key: string; data: unknown }[] = [];
1717
batchedSize = 0;

‎yarn.lock‎

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ __metadata:
469469
"@types/resolve": "npm:^1.3.2"
470470
"@types/semver": "npm:^5.4.0"
471471
convert-source-map: "npm:^2.0.0"
472-
find-up-simple: "npm:^1.0.1"
472+
empathic: "npm:^2.0.1"
473473
gensync: "npm:^1.0.0-beta.2"
474474
import-meta-resolve: "npm:^4.2.0"
475475
json5: "npm:^2.2.3"
@@ -3842,7 +3842,7 @@ __metadata:
38423842
"@types/cacache": "npm:^20.0.0"
38433843
cacache: "npm:20.0.3"
38443844
clone-deep: "npm:^4.0.1"
3845-
find-cache-directory: "npm:^6.0.0"
3845+
empathic: "npm:^2.0.1"
38463846
pirates: "npm:^4.0.6"
38473847
peerDependencies:
38483848
"@babel/core": "workspace:^"
@@ -8541,13 +8541,6 @@ __metadata:
85418541
languageName: node
85428542
linkType: hard
85438543

8544-
"common-path-prefix@npm:^3.0.0":
8545-
version: 3.0.0
8546-
resolution: "common-path-prefix@npm:3.0.0"
8547-
checksum: 10/09c180e8d8495d42990d617f4d4b7522b5da20f6b236afe310192d401d1da8147a7835ae1ea37797ba0c2238ef3d06f3492151591451df34539fdb4b2630f2b3
8548-
languageName: node
8549-
linkType: hard
8550-
85518544
"commondir@npm:^1.0.1":
85528545
version: 1.0.1
85538546
resolution: "commondir@npm:1.0.1"
@@ -9183,6 +9176,13 @@ __metadata:
91839176
languageName: node
91849177
linkType: hard
91859178

9179+
"empathic@npm:^2.0.1":
9180+
version: 2.0.1
9181+
resolution: "empathic@npm:2.0.1"
9182+
checksum: 10/c5a37b78926e722c38779e5026342350098771fa1cacb52cb808e5329896ab39abb88cd2f1374671d6e5c98aa24cba2534f00da2938d04f11de1a2d012ee75c3
9183+
languageName: node
9184+
linkType: hard
9185+
91869186
"end-of-stream@npm:^1.0.0, end-of-stream@npm:^1.1.0, end-of-stream@npm:^1.4.4":
91879187
version: 1.4.5
91889188
resolution: "end-of-stream@npm:1.4.5"
@@ -10372,17 +10372,7 @@ __metadata:
1037210372
languageName: node
1037310373
linkType: hard
1037410374

10375-
"find-cache-directory@npm:^6.0.0":
10376-
version: 6.0.0
10377-
resolution: "find-cache-directory@npm:6.0.0"
10378-
dependencies:
10379-
common-path-prefix: "npm:^3.0.0"
10380-
pkg-dir: "npm:^8.0.0"
10381-
checksum: 10/d0864b74ac556e21b1b4dc09d37f0b85ba8620f8cecc08727e8b2348e94828595d7368095deb79e804234629db56900c0f953beecf3cf2373e615fb809cc2033
10382-
languageName: node
10383-
linkType: hard
10384-
10385-
"find-up-simple@npm:^1.0.0, find-up-simple@npm:^1.0.1":
10375+
"find-up-simple@npm:^1.0.1":
1038610376
version: 1.0.1
1038710377
resolution: "find-up-simple@npm:1.0.1"
1038810378
checksum: 10/6e374bffda9f8425314eab47ef79752b6e77dcc95c0ad17d257aef48c32fe07bbc41bcafbd22941c25bb94fffaaaa8e178d928867d844c58100c7fe19ec82f72
@@ -14688,15 +14678,6 @@ __metadata:
1468814678
languageName: node
1468914679
linkType: hard
1469014680

14691-
"pkg-dir@npm:^8.0.0":
14692-
version: 8.0.0
14693-
resolution: "pkg-dir@npm:8.0.0"
14694-
dependencies:
14695-
find-up-simple: "npm:^1.0.0"
14696-
checksum: 10/e589abebd1b76cbc3669a45df64f63cc1b041fd3a6588b45d4c692207df126f2a67478a804e5beeb729e75efea06cd405fb84445c879e7af346ba46a4a30b1ff
14697-
languageName: node
14698-
linkType: hard
14699-
1470014681
"pkg-pr-new@npm:^0.0.54":
1470114682
version: 0.0.54
1470214683
resolution: "pkg-pr-new@npm:0.0.54"

0 commit comments

Comments
 (0)