diff --git a/packages/nuxt/src/app/nuxt.ts b/packages/nuxt/src/app/nuxt.ts index ba82373afb..e688b87ba0 100644 --- a/packages/nuxt/src/app/nuxt.ts +++ b/packages/nuxt/src/app/nuxt.ts @@ -368,7 +368,7 @@ export async function applyPlugins (nuxtApp: NuxtApp, plugins: Array) { - 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) { unresolvedPlugins.push([new Set(unresolvedPluginsForThisPlugin), plugin]) } else { diff --git a/test/nuxt/plugin.test.ts b/test/nuxt/plugin.test.ts index 0fcb7ed82c..3426da520c 100644 --- a/test/nuxt/plugin.test.ts +++ b/test/nuxt/plugin.test.ts @@ -264,4 +264,21 @@ describe('plugin dependsOn', () => { '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', + ]) + }) })