Skip to content

Commit

Permalink
fix: make resolveConfig() concurrent safe
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Jul 19, 2022
1 parent 3e510ab commit afc9d99
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/vite/src/node/config.ts
Expand Up @@ -1020,12 +1020,13 @@ async function loadConfigFromBundledFile(
// with --experimental-loader themselves, we have to do a hack here:
// write it to disk, load it with native Node ESM, then delete the file.
if (isESM) {
const fileUrl = pathToFileURL(fileName)
fs.writeFileSync(fileName + '.mjs', bundledCode)
const fileNameTmp = `${fileName}.timestamp-${Date.now()}.mjs`
const fileUrl = pathToFileURL(fileNameTmp)
fs.writeFileSync(fileNameTmp, bundledCode)
try {
return (await dynamicImport(`${fileUrl}.mjs?t=${Date.now()}`)).default
return (await dynamicImport(`${fileUrl}.mjs`)).default
} finally {
fs.unlinkSync(fileName + '.mjs')
fs.unlinkSync(fileNameTmp)
}
}
// for cjs, we can register a custom loader via `_require.extensions`
Expand Down

0 comments on commit afc9d99

Please sign in to comment.