Skip to content

Commit 2c2a86b

Browse files
authored
fix: always remove temp config (#8782)
1 parent 8b77695 commit 2c2a86b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

packages/vite/src/node/config.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -887,9 +887,12 @@ export async function loadConfigFromFile(
887887
// bundle the config file w/ ts transforms first, write it to disk,
888888
// load it with native Node ESM, then delete the file.
889889
fs.writeFileSync(resolvedPath + '.mjs', bundled.code)
890-
userConfig = (await dynamicImport(`${fileUrl}.mjs?t=${Date.now()}`))
891-
.default
892-
fs.unlinkSync(resolvedPath + '.mjs')
890+
try {
891+
userConfig = (await dynamicImport(`${fileUrl}.mjs?t=${Date.now()}`))
892+
.default
893+
} finally {
894+
fs.unlinkSync(resolvedPath + '.mjs')
895+
}
893896
debug(`TS + native esm config loaded in ${getTime()}`, fileUrl)
894897
} else {
895898
// using Function to avoid this from being compiled away by TS/Rollup

0 commit comments

Comments
 (0)