migrate to hotUpdate

pull/4525/head
Divyansh Singh 7 months ago
parent de2ce4e8fb
commit 08fab8aca5

@ -3,7 +3,6 @@ import c from 'picocolors'
import {
mergeConfig,
searchForWorkspaceRoot,
type ModuleNode,
type Plugin,
type ResolvedConfig,
type Rollup,
@ -424,16 +423,16 @@ export async function createVitePressPlugin(
const hmrFix: Plugin = {
name: 'vitepress:hmr-fix',
async handleHotUpdate({ file, server, modules }) {
async hotUpdate({ file, server, modules }) {
const importers = [...(importerMap[slash(file)] || [])]
if (importers.length > 0) {
return [
...modules,
...importers.map((id) => {
clearCache(slash(path.relative(srcDir, id)))
return server.moduleGraph.getModuleById(id)
return this.environment.moduleGraph.getModuleById(id)
})
].filter(Boolean) as ModuleNode[]
].filter((mod) => mod !== undefined)
}
}
}

@ -3,9 +3,9 @@ import path from 'node:path'
import c from 'picocolors'
import { glob } from 'tinyglobby'
import {
EnvironmentModuleNode,
loadConfigFromFile,
normalizePath,
type EnvironmentModuleNode,
type Logger,
type Plugin
} from 'vite'

@ -198,7 +198,7 @@ export async function localSearchPlugin(
}
},
async handleHotUpdate({ file }) {
async hotUpdate({ file }) {
if (file.endsWith('.md')) {
await indexFile(file)
debug('🔍️ Updated', file)

Loading…
Cancel
Save