Skip to content

Commit

Permalink
fix: timestamp config dynamicImport (#13502)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev authored Jun 13, 2023
1 parent b70e783 commit 6a87c65
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1144,10 +1144,16 @@ async function loadConfigFromBundledFile(
// convert to base64, load it with native Node ESM.
if (isESM) {
try {
// Postfix the bundled code with a timestamp to avoid Node's ESM loader cache
const configTimestamp = `${fileName}.timestamp:${Date.now()}-${Math.random()
.toString(16)
.slice(2)}`
return (
await dynamicImport(
'data:text/javascript;base64,' +
Buffer.from(bundledCode).toString('base64'),
Buffer.from(`${bundledCode}\n//${configTimestamp}`).toString(
'base64',
),
)
).default
} catch (e) {
Expand Down

0 comments on commit 6a87c65

Please sign in to comment.