Skip to content

Commit

Permalink
perf: avoid fsp.unlink if we don't use the promise (#12589)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Mar 26, 2023
1 parent 4215e22 commit 19d1980
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions packages/vite/src/node/config.ts
Expand Up @@ -1093,11 +1093,7 @@ async function loadConfigFromBundledFile(
try {
return (await dynamicImport(fileUrl)).default
} finally {
try {
await fsp.unlink(fileNameTmp)
} catch {
// already removed if this function is called twice simultaneously
}
fs.unlink(fileNameTmp, () => {}) // Ignore errors
}
}
// for cjs, we can register a custom loader via `_require.extensions`
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/optimizer/index.ts
Expand Up @@ -626,7 +626,7 @@ export function runOptimizeDeps(

// Clean up old files in the background
for (const filePath of oldFilesPaths)
if (!newFilesPaths.has(filePath)) fsp.unlink(filePath)
if (!newFilesPaths.has(filePath)) fs.unlink(filePath, () => {}) // ignore errors

await Promise.all(files)
},
Expand Down

0 comments on commit 19d1980

Please sign in to comment.