diff --git a/src/index.ts b/src/index.ts index 7048be0..ad7f203 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ import { promises as fs } from 'node:fs' import { basename, dirname, join } from 'node:path' +import { interopDefault } from 'mlly' import jiti from 'jiti' import { notNullish, toArray } from '@antfu/utils' import defu from 'defu' @@ -131,14 +132,19 @@ async function loadConfigFile(filepath: string, source: LoadConfigSource): config = await parser(filepath) } else if (parser === 'require') { - config = await jiti(filepath, { - interopDefault: true, - cache: false, - v8cache: false, - esmResolve: true, - // FIXME: https://github.com/unjs/jiti/pull/141 - requireCache: false, - })(bundleFilepath) + if (process.versions.bun) { + const defaultImport = await import(filepath) + config = interopDefault(defaultImport) + } else { + config = await jiti(filepath, { + interopDefault: true, + cache: false, + v8cache: false, + esmResolve: true, + // FIXME: https://github.com/unjs/jiti/pull/141 + requireCache: false, + })(bundleFilepath) + } } else if (parser === 'json') { config = JSON.parse(await read())