Skip to content

Commit 35bb58c

Browse files
authored
feat: add bun support (#24)
1 parent c0b45c7 commit 35bb58c

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/index.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { promises as fs } from 'node:fs'
22
import { basename, dirname, join } from 'node:path'
3+
import { interopDefault } from 'mlly'
34
import jiti from 'jiti'
45
import { notNullish, toArray } from '@antfu/utils'
56
import defu from 'defu'
@@ -131,14 +132,19 @@ async function loadConfigFile<T>(filepath: string, source: LoadConfigSource<T>):
131132
config = await parser(filepath)
132133
}
133134
else if (parser === 'require') {
134-
config = await jiti(filepath, {
135-
interopDefault: true,
136-
cache: false,
137-
v8cache: false,
138-
esmResolve: true,
139-
// FIXME: https://github.com/unjs/jiti/pull/141
140-
requireCache: false,
141-
})(bundleFilepath)
135+
if (process.versions.bun) {
136+
const defaultImport = await import(filepath)
137+
config = interopDefault(defaultImport)
138+
} else {
139+
config = await jiti(filepath, {
140+
interopDefault: true,
141+
cache: false,
142+
v8cache: false,
143+
esmResolve: true,
144+
// FIXME: https://github.com/unjs/jiti/pull/141
145+
requireCache: false,
146+
})(bundleFilepath)
147+
}
142148
}
143149
else if (parser === 'json') {
144150
config = JSON.parse(await read())

0 commit comments

Comments
 (0)