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 df26684
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
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()
const fileUrl = pathToFileURL(fileNameTmp)
fs.writeFileSync(fileNameTmp + '.mjs', 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 + '.mjs')
}
}
// for cjs, we can register a custom loader via `_require.extensions`
Expand Down

0 comments on commit df26684

Please # to comment.