Skip to content

Commit

Permalink
fix: always remove temp config (#8782)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Jun 25, 2022
1 parent 8b77695 commit 2c2a86b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/vite/src/node/config.ts
Expand Up @@ -887,9 +887,12 @@ export async function loadConfigFromFile(
// bundle the config file w/ ts transforms first, write it to disk,
// load it with native Node ESM, then delete the file.
fs.writeFileSync(resolvedPath + '.mjs', bundled.code)
userConfig = (await dynamicImport(`${fileUrl}.mjs?t=${Date.now()}`))
.default
fs.unlinkSync(resolvedPath + '.mjs')
try {
userConfig = (await dynamicImport(`${fileUrl}.mjs?t=${Date.now()}`))
.default
} finally {
fs.unlinkSync(resolvedPath + '.mjs')
}
debug(`TS + native esm config loaded in ${getTime()}`, fileUrl)
} else {
// using Function to avoid this from being compiled away by TS/Rollup
Expand Down

0 comments on commit 2c2a86b

Please sign in to comment.