Skip to content

Commit be1b60c

Browse files
committed
fix: optional parseEnv
closes #707
1 parent 7d89d54 commit be1b60c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/config/options.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { readFile } from 'node:fs/promises'
22
import path from 'node:path'
33
import process from 'node:process'
4-
import { parseEnv } from 'node:util'
54
import { blue } from 'ansis'
65
import { createDefu } from 'defu'
76
import isInCi from 'is-in-ci'
@@ -33,6 +32,7 @@ import type {
3332
} from './types.ts'
3433

3534
const debug = createDebug('tsdown:config:options')
35+
const parseEnv = process.getBuiltinModule('node:util').parseEnv
3636

3737
/**
3838
* Resolve user config into resolved configs
@@ -187,6 +187,11 @@ export async function resolveUserConfig(
187187
}
188188
const envFromProcess = filterEnv(process.env, envPrefix)
189189
if (envFile) {
190+
if (!parseEnv) {
191+
throw new Error(
192+
`Your runtime does not support 'util.parseEnv()'. Please upgrade to Node.js v20.12.0 or later.`,
193+
)
194+
}
190195
const resolvedPath = path.resolve(cwd, envFile)
191196
logger.info(nameLabel, `env file: ${color(resolvedPath)}`)
192197

0 commit comments

Comments
 (0)