pull/4903/head
Divyansh Singh 1 month ago
parent fc267ae6b7
commit d5094f86d6

@ -1,3 +1,11 @@
<!-- @content --> <!-- @content -->
<pre class="params">{{ $params }}</pre> <pre class="params">{{ $params }}</pre>
<style scoped>
pre {
/* try changing this, saving once won't update the color,
saving twice will change the color to the first saved color */
color: lime;
}
</style>

@ -5,6 +5,7 @@ import pm from 'picomatch'
import { import {
loadConfigFromFile, loadConfigFromFile,
normalizePath, normalizePath,
type EnvironmentModuleGraph,
type EnvironmentModuleNode, type EnvironmentModuleNode,
type Logger, type Logger,
type Plugin type Plugin
@ -177,11 +178,7 @@ export const dynamicRoutesPlugin = async (
const normalizedFile = normalizePath(file) const normalizedFile = normalizePath(file)
// Trigger update if a module or its dependencies changed. // Trigger update if a module or its dependencies changed.
for (const id of moduleGraph.delete(normalizedFile)) { modules.push(...getModules(normalizedFile, this.environment.moduleGraph))
routeModuleCache.delete(id)
const mod = this.environment.moduleGraph.getModuleById(id)
if (mod) modules.push(mod)
}
// Also check if the file matches any custom watch patterns. // Also check if the file matches any custom watch patterns.
let watchedFileChanged = false let watchedFileChanged = false
@ -192,11 +189,7 @@ export const dynamicRoutesPlugin = async (
) { ) {
route.routes = undefined route.routes = undefined
watchedFileChanged = true watchedFileChanged = true
modules.push(...getModules(file, this.environment.moduleGraph, false))
for (const id of moduleGraph.delete(file)) {
const mod = this.environment.moduleGraph.getModuleById(id)
if (mod) modules.push(mod)
}
} }
} }
@ -355,3 +348,16 @@ async function resolveDynamicRoutes(
return resolvedRoutes return resolvedRoutes
} }
function getModules(
id: string,
envModuleGraph: EnvironmentModuleGraph,
deleteFromRouteModuleCache = true
) {
const modules: EnvironmentModuleNode[] = []
for (const file of moduleGraph.delete(id)) {
deleteFromRouteModuleCache && routeModuleCache.delete(file)
modules.push(...(envModuleGraph.getModulesByFile(file)?.values() ?? []))
}
return modules
}

Loading…
Cancel
Save