Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add bun support #24

Merged
merged 2 commits into from
Jul 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.env.npm_execpath.includes('bun')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (process.env.npm_execpath.includes('bun')) {
if (process.versions.bun) {

vitejs/vite#13901

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