mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-13 09:33:54 +00:00
fix: add deprecated warn for tapables + simple backward compatibility
This commit is contained in:
parent
e5017c5e2a
commit
711e6a916e
@ -58,6 +58,26 @@ export default class Nuxt {
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugin(name, fn) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.error(`[warn] nuxt.plugin('${name}',..) is deprecated. Please use new hooks system.`)
|
||||||
|
|
||||||
|
// A tiny backward compatibility util
|
||||||
|
const hookMap = {
|
||||||
|
'ready': 'ready',
|
||||||
|
'close': 'close',
|
||||||
|
'listen': 'listen',
|
||||||
|
'built': 'build:done'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hookMap[name]) {
|
||||||
|
this.hook(hookMap[name], fn)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Always return nuxt class which has plugin() for two level hooks
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
hook(name, fn) {
|
hook(name, fn) {
|
||||||
if (!name || typeof fn !== 'function') {
|
if (!name || typeof fn !== 'function') {
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user