mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
fix(nuxt): add runtime check to filter plugins in dependsOn
(#25409)
This commit is contained in:
parent
ca060288e6
commit
de0ceaa72a
@ -368,7 +368,7 @@ export async function applyPlugins (nuxtApp: NuxtApp, plugins: Array<Plugin & Ob
|
|||||||
let promiseDepth = 0
|
let promiseDepth = 0
|
||||||
|
|
||||||
async function executePlugin (plugin: Plugin & ObjectPlugin<any>) {
|
async function executePlugin (plugin: Plugin & ObjectPlugin<any>) {
|
||||||
const unresolvedPluginsForThisPlugin = plugin.dependsOn?.filter(name => !resolvedPlugins.includes(name)) ?? []
|
const unresolvedPluginsForThisPlugin = plugin.dependsOn?.filter(name => plugins.some(p => p._name === name) && !resolvedPlugins.includes(name)) ?? []
|
||||||
if (unresolvedPluginsForThisPlugin.length > 0) {
|
if (unresolvedPluginsForThisPlugin.length > 0) {
|
||||||
unresolvedPlugins.push([new Set(unresolvedPluginsForThisPlugin), plugin])
|
unresolvedPlugins.push([new Set(unresolvedPluginsForThisPlugin), plugin])
|
||||||
} else {
|
} else {
|
||||||
|
@ -264,4 +264,21 @@ describe('plugin dependsOn', () => {
|
|||||||
'end B',
|
'end B',
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('expect to execute plugins if a plugin depends on a plugin that does not exist', async () => {
|
||||||
|
const nuxtApp = useNuxtApp()
|
||||||
|
const sequence: string[] = []
|
||||||
|
const plugins = [
|
||||||
|
pluginFactory('B', undefined, sequence,),
|
||||||
|
pluginFactory('C', ['A', 'B'], sequence,),
|
||||||
|
]
|
||||||
|
await applyPlugins(nuxtApp, plugins)
|
||||||
|
|
||||||
|
expect(sequence).toMatchObject([
|
||||||
|
'start B',
|
||||||
|
'end B',
|
||||||
|
'start C',
|
||||||
|
'end C',
|
||||||
|
])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user