Skip to content

Commit

Permalink
feat: add bun support (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer authored Jul 30, 2023
1 parent c0b45c7 commit 35bb58c
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -131,14 +132,19 @@ async function loadConfigFile<T>(filepath: string, source: LoadConfigSource<T>):
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())
Expand Down

0 comments on commit 35bb58c

Please sign in to comment.