fix(lib/plugins): only run dependencies in runPluginLate
This commit is contained in:
parent
7b4d566e4d
commit
b40e2f51ab
2 changed files with 21 additions and 7 deletions
|
|
@ -15,7 +15,7 @@ export const pRootNodes = new Set<AnyPlugin>()
|
|||
export const pLeafOrSingleNodes = new Set<AnyPlugin>()
|
||||
|
||||
// Visited non-leaf nodes
|
||||
const visited = new WeakSet<AnyPlugin>()
|
||||
const visited = new Set<AnyPlugin>()
|
||||
|
||||
// Ordered list of plugins to be started
|
||||
export const pListOrdered: AnyPlugin[] = []
|
||||
|
|
@ -48,6 +48,7 @@ export function computePendingNodes() {
|
|||
pPending.clear()
|
||||
pLeafOrSingleNodes.clear()
|
||||
pRootNodes.clear()
|
||||
visited.clear()
|
||||
}
|
||||
|
||||
export function resolvePluginGraph(plugin: AnyPlugin) {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,12 @@ import {
|
|||
pDecoratorsStart,
|
||||
pImplicitDeps,
|
||||
} from './decorators'
|
||||
import { pLeafOrSingleNodes, pPending } from './dependency-graph'
|
||||
import {
|
||||
computePendingNodes,
|
||||
pLeafOrSingleNodes,
|
||||
pListOrdered,
|
||||
pPending,
|
||||
} from './dependency-graph'
|
||||
import type {
|
||||
InitPluginApi,
|
||||
Plugin,
|
||||
|
|
@ -299,8 +304,7 @@ export async function enablePlugin(plugin: AnyPlugin) {
|
|||
|
||||
await Promise.all(
|
||||
getPluginDependencies(plugin).map(dep => {
|
||||
if (dep.flags & Flag.Enabled) return
|
||||
return runPluginLate(dep)
|
||||
if (!isPluginEnabled(dep)) return enablePlugin(dep)
|
||||
}),
|
||||
)
|
||||
|
||||
|
|
@ -318,9 +322,18 @@ export async function runPluginLate(plugin: AnyPlugin) {
|
|||
|
||||
plugin.flags |= Flag.EnabledLate
|
||||
|
||||
await preInitPlugin(plugin)
|
||||
await initPlugin(plugin)
|
||||
await startPlugin(plugin)
|
||||
// Reset previous computations
|
||||
pListOrdered.length = 0
|
||||
pPending.add(plugin)
|
||||
computePendingNodes()
|
||||
|
||||
await Promise.all(
|
||||
pListOrdered.map(async function runLate(plugin) {
|
||||
await preInitPlugin(plugin)
|
||||
await initPlugin(plugin)
|
||||
await startPlugin(plugin)
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue