Skip to content

Commit 9b41a62

Browse files
committed
feat: support ESM config for bob
1 parent 0c5582b commit 9b41a62

File tree

3 files changed

+31
-35
lines changed

3 files changed

+31
-35
lines changed

packages/react-native-builder-bob/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"@babel/preset-react": "^7.17.12",
5151
"@babel/preset-typescript": "^7.17.12",
5252
"browserslist": "^4.20.4",
53-
"cosmiconfig": "^7.0.1",
53+
"cosmiconfig": "^9.0.0",
5454
"cross-spawn": "^7.0.3",
5555
"dedent": "^0.7.0",
5656
"del": "^6.1.1",

packages/react-native-builder-bob/src/index.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fs from 'fs-extra';
33
import kleur from 'kleur';
44
import dedent from 'dedent';
55
import yargs from 'yargs';
6-
import { cosmiconfigSync } from 'cosmiconfig';
6+
import { cosmiconfig } from 'cosmiconfig';
77
import isGitDirty from 'is-git-dirty';
88
import prompts, { type PromptObject } from './utils/prompts';
99
import * as logger from './utils/logger';
@@ -16,8 +16,14 @@ import type { Options } from './types';
1616
const { name, version } = require('../package.json');
1717

1818
const root = process.cwd();
19-
const explorer = cosmiconfigSync(name, {
20-
searchPlaces: ['package.json', `bob.config.js`, 'bob.config.cjs'],
19+
const explorer = cosmiconfig(name, {
20+
stopDir: root,
21+
searchPlaces: [
22+
'package.json',
23+
'bob.config.mjs',
24+
'bob.config.cjs',
25+
'bob.config.js',
26+
],
2127
});
2228

2329
const FLOW_PRGAMA_REGEX = /\*?\s*@(flow)\b/m;
@@ -46,7 +52,7 @@ yargs
4652
}
4753

4854
const pkg = JSON.parse(await fs.readFile(pak, 'utf-8'));
49-
const result = explorer.search();
55+
const result = await explorer.search();
5056

5157
if (result?.config && pkg.devDependencies && name in pkg.devDependencies) {
5258
const { shouldContinue } = await prompts({
@@ -413,7 +419,7 @@ yargs
413419
);
414420
})
415421
.command('build', 'build files for publishing', {}, async (argv) => {
416-
const result = explorer.search();
422+
const result = await explorer.search();
417423

418424
if (!result?.config) {
419425
logger.exit(

yarn.lock

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3876,13 +3876,6 @@ __metadata:
38763876
languageName: node
38773877
linkType: hard
38783878

3879-
"@types/parse-json@npm:^4.0.0":
3880-
version: 4.0.0
3881-
resolution: "@types/parse-json@npm:4.0.0"
3882-
checksum: fd6bce2b674b6efc3db4c7c3d336bd70c90838e8439de639b909ce22f3720d21344f52427f1d9e57b265fcb7f6c018699b99e5e0c208a1a4823014269a6bf35b
3883-
languageName: node
3884-
linkType: hard
3885-
38863879
"@types/prompts@npm:^2.0.14":
38873880
version: 2.4.4
38883881
resolution: "@types/prompts@npm:2.4.4"
@@ -5621,19 +5614,6 @@ __metadata:
56215614
languageName: node
56225615
linkType: hard
56235616

5624-
"cosmiconfig@npm:^7.0.1":
5625-
version: 7.1.0
5626-
resolution: "cosmiconfig@npm:7.1.0"
5627-
dependencies:
5628-
"@types/parse-json": ^4.0.0
5629-
import-fresh: ^3.2.1
5630-
parse-json: ^5.0.0
5631-
path-type: ^4.0.0
5632-
yaml: ^1.10.0
5633-
checksum: c53bf7befc1591b2651a22414a5e786cd5f2eeaa87f3678a3d49d6069835a9d8d1aef223728e98aa8fec9a95bf831120d245096db12abe019fecb51f5696c96f
5634-
languageName: node
5635-
linkType: hard
5636-
56375617
"cosmiconfig@npm:^8.0.0":
56385618
version: 8.3.6
56395619
resolution: "cosmiconfig@npm:8.3.6"
@@ -5651,6 +5631,23 @@ __metadata:
56515631
languageName: node
56525632
linkType: hard
56535633

5634+
"cosmiconfig@npm:^9.0.0":
5635+
version: 9.0.0
5636+
resolution: "cosmiconfig@npm:9.0.0"
5637+
dependencies:
5638+
env-paths: ^2.2.1
5639+
import-fresh: ^3.3.0
5640+
js-yaml: ^4.1.0
5641+
parse-json: ^5.2.0
5642+
peerDependencies:
5643+
typescript: ">=4.9.5"
5644+
peerDependenciesMeta:
5645+
typescript:
5646+
optional: true
5647+
checksum: a30c424b53d442ea0bdd24cb1b3d0d8687c8dda4a17ab6afcdc439f8964438801619cdb66e8e79f63b9caa3e6586b60d8bab9ce203e72df6c5e80179b971fe8f
5648+
languageName: node
5649+
linkType: hard
5650+
56545651
"create-jest@npm:^29.7.0":
56555652
version: 29.7.0
56565653
resolution: "create-jest@npm:29.7.0"
@@ -6589,7 +6586,7 @@ __metadata:
65896586
languageName: node
65906587
linkType: hard
65916588

6592-
"env-paths@npm:^2.2.0":
6589+
"env-paths@npm:^2.2.0, env-paths@npm:^2.2.1":
65936590
version: 2.2.1
65946591
resolution: "env-paths@npm:2.2.1"
65956592
checksum: 65b5df55a8bab92229ab2b40dad3b387fad24613263d103a97f91c9fe43ceb21965cd3392b1ccb5d77088021e525c4e0481adb309625d0cb94ade1d1fb8dc17e
@@ -12849,7 +12846,7 @@ __metadata:
1284912846
"@types/yargs": ^17.0.10
1285012847
browserslist: ^4.20.4
1285112848
concurrently: ^7.2.2
12852-
cosmiconfig: ^7.0.1
12849+
cosmiconfig: ^9.0.0
1285312850
cross-spawn: ^7.0.3
1285412851
dedent: ^0.7.0
1285512852
del: ^6.1.1
@@ -15438,13 +15435,6 @@ __metadata:
1543815435
languageName: node
1543915436
linkType: hard
1544015437

15441-
"yaml@npm:^1.10.0":
15442-
version: 1.10.2
15443-
resolution: "yaml@npm:1.10.2"
15444-
checksum: ce4ada136e8a78a0b08dc10b4b900936912d15de59905b2bf415b4d33c63df1d555d23acb2a41b23cf9fb5da41c256441afca3d6509de7247daa062fd2c5ea5f
15445-
languageName: node
15446-
linkType: hard
15447-
1544815438
"yargs-parser@npm:^20.2.2, yargs-parser@npm:^20.2.3":
1544915439
version: 20.2.9
1545015440
resolution: "yargs-parser@npm:20.2.9"

0 commit comments

Comments
 (0)