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

@ -1,3 +1,11 @@
<!-- @content -->
<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 {
loadConfigFromFile,
normalizePath,
type EnvironmentModuleGraph,
type EnvironmentModuleNode,
type Logger,
type Plugin
@ -177,11 +178,7 @@ export const dynamicRoutesPlugin = async (
const normalizedFile = normalizePath(file)
// Trigger update if a module or its dependencies changed.
for (const id of moduleGraph.delete(normalizedFile)) {
routeModuleCache.delete(id)
const mod = this.environment.moduleGraph.getModuleById(id)
if (mod) modules.push(mod)
}
modules.push(...getModules(normalizedFile, this.environment.moduleGraph))
// Also check if the file matches any custom watch patterns.
let watchedFileChanged = false
@ -192,11 +189,7 @@ export const dynamicRoutesPlugin = async (
) {
route.routes = undefined
watchedFileChanged = true
for (const id of moduleGraph.delete(file)) {
const mod = this.environment.moduleGraph.getModuleById(id)
if (mod) modules.push(mod)
}
modules.push(...getModules(file, this.environment.moduleGraph, false))
}
}
@ -355,3 +348,16 @@ async function resolveDynamicRoutes(
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