fix: hmr not working for watched files in path loaders

follow up on #4525
pull/4600/head
Divyansh Singh 7 months ago
parent 9f54714e7d
commit e271695d71

@ -307,7 +307,8 @@ export async function createVitePressPlugin(
if (url?.endsWith('.html')) {
res.statusCode = 200
res.setHeader('Content-Type', 'text/html')
let html = `<!DOCTYPE html>
let html = `\
<!DOCTYPE html>
<html>
<head>
<title></title>

@ -187,10 +187,17 @@ export const dynamicRoutesPlugin = async (
// Also check if the file matches any custom watch patterns.
let watchedFileChanged = false
for (const [, route] of routeModuleCache) {
for (const [file, route] of routeModuleCache) {
if (route.watch && isMatch(normalizedFile, route.watch)) {
route.routes = undefined
watchedFileChanged = true
for (const id of moduleGraph.delete(file)) {
const mod = this.environment.moduleGraph.getModuleById(id)
if (mod) {
modules.push(mod)
}
}
}
}

@ -150,7 +150,7 @@ export const staticDataPlugin: Plugin = {
const loader = idToLoaderModulesMap[id]
if (loader && loader.watch && isMatch(normalizedFile, loader.watch)) {
const mod = this.environment.moduleGraph.getModuleById(id)
if (mod && !modules.includes(mod)) {
if (mod) {
modules.push(mod)
}
}

Loading…
Cancel
Save