Skip to content

Commit 36dbff7

Browse files
committed
perf: use native loader for bun
1 parent 8cb63cd commit 36dbff7

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

pnpm-lock.yaml

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ catalogs:
5555
cac: ^6.7.14
5656
empathic: ^2.0.0
5757
hookable: ^5.5.3
58-
import-without-cache: ^0.1.3
58+
import-without-cache: ^0.2.0
5959
is-in-ci: ^2.0.0
6060
obug: ^2.1.1
6161
package-manager-detector: ^1.6.0

src/config/file.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,15 @@ export async function loadConfigFile(
142142

143143
type Parser = 'native' | 'unrun'
144144

145+
const isBun = !!process.versions.bun
146+
const nativeTS = process.features.typescript || process.versions.deno
147+
const autoLoader = isBun || (nativeTS && isSupported) ? 'native' : 'unrun'
148+
145149
function resolveConfigLoader(
146150
configLoader: InlineConfig['configLoader'] = 'auto',
147151
): Parser {
148152
if (configLoader === 'auto') {
149-
const nativeTS = !!(
150-
process.features.typescript ||
151-
process.versions.bun ||
152-
process.versions.deno
153-
)
154-
return nativeTS && isSupported ? 'native' : 'unrun'
153+
return autoLoader
155154
} else {
156155
return configLoader === 'native' ? 'native' : 'unrun'
157156
}
@@ -186,7 +185,7 @@ async function nativeImport(id: string) {
186185
if (isSupported) {
187186
importAttributes.cache = 'no'
188187
init()
189-
} else {
188+
} else if (!isBun) {
190189
url.searchParams.set('no-cache', crypto.randomUUID())
191190
}
192191

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'node:path'
22
import { fileURLToPath } from 'node:url'
33
import { bold, green } from 'ansis'
4-
import { clearCJSCache } from 'import-without-cache'
4+
import { clearRequireCache } from 'import-without-cache'
55
import {
66
build as rolldownBuild,
77
watch as rolldownWatch,
@@ -62,7 +62,7 @@ export async function build(
6262
restarting = true
6363

6464
await Promise.all(disposeCbs.map((cb) => cb()))
65-
clearCJSCache()
65+
clearRequireCache()
6666
build(userOptions)
6767
}
6868

0 commit comments

Comments
 (0)