fix(nuxt3): allows plugins without default export (#1618)

This commit is contained in:
Anthony Fu 2021-11-02 17:49:45 +08:00 committed by GitHub
parent 5aa33b807c
commit e58270a50f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -137,6 +137,9 @@ export function normalizePlugins (_plugins: Array<Plugin | LegacyPlugin>) {
let needsLegacyContext = false let needsLegacyContext = false
const plugins = _plugins.map((plugin) => { const plugins = _plugins.map((plugin) => {
if (typeof plugin !== 'function') {
return () => {}
}
if (isLegacyPlugin(plugin)) { if (isLegacyPlugin(plugin)) {
needsLegacyContext = true needsLegacyContext = true
return (nuxtApp: NuxtApp) => plugin(nuxtApp._legacyContext!, nuxtApp.provide) return (nuxtApp: NuxtApp) => plugin(nuxtApp._legacyContext!, nuxtApp.provide)