Skip to content

Commit 304aa72

Browse files
authored
fix(RootScan): check for runtime config files when checking for CJS vs ESM (#476)
* fix(RootScan): check for deno config file when checking for CJS vs ESM * fix(RootScan): support Bun configuration file in root data parsing
1 parent 9c92dcc commit 304aa72

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/lib/internal/RootScan.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { readFileSync } from 'fs';
1+
import { existsSync, readFileSync } from 'fs';
22
import { dirname, join } from 'path';
33

44
/**
@@ -82,7 +82,9 @@ export function parseRootData(): RootData {
8282
try {
8383
file = JSON.parse(readFileSync(join(cwd, 'package.json'), 'utf8')) as PartialPackageJson;
8484
} catch (error) {
85-
return { root: cwd, type: 'CommonJS' };
85+
const hasDenoConfigFile = existsSync(join(cwd, 'deno.json'));
86+
const hasBunConfigFile = existsSync(join(cwd, 'bunfig.toml'));
87+
return hasDenoConfigFile || hasBunConfigFile ? { root: cwd, type: 'ESM' } : { root: cwd, type: 'CommonJS' };
8688
}
8789

8890
const { main: packageMain, module: packageModule, type: packageType } = file;

0 commit comments

Comments
 (0)