Skip to content

Commit

Permalink
fix: adding a public file with the same path as a module
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Jan 18, 2024
1 parent c5820eb commit e9a6011
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,17 @@ export async function _createServer(

if (publicDir && publicFiles) {
if (file.startsWith(publicDir)) {
publicFiles[isUnlink ? 'delete' : 'add'](file.slice(publicDir.length))
const path = file.slice(publicDir.length)
publicFiles[isUnlink ? 'delete' : 'add'](path)
if (!isUnlink) {
const moduleWithSamePath = await moduleGraph.getModuleByUrl(path)
const etag = moduleWithSamePath?.transformResult?.etag
if (etag) {
// The public file should win on the next request over a module with the
// same path. Prevent the transform etag fast path from serving the module
moduleGraph.etagToModuleMap.delete(etag)
}
}
}
}
await handleFileAddUnlink(file, server, isUnlink)
Expand Down

0 comments on commit e9a6011

Please sign in to comment.