mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 16:12:12 +00:00
Update extendRoutes modules API
This commit is contained in:
parent
8cf5a21752
commit
416b84ccae
@ -74,7 +74,25 @@ export default class ModuleContainer extends Tapable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extendRoutes (fn) {
|
extendRoutes (fn) {
|
||||||
this.options.router.extendRoutes = chainFn(this.options.router.extendRoutes, fn)
|
const extendRoutesFromConfig = this.options.router.extendRoutes
|
||||||
|
this.options.router.extendRoutes = function (routes, resolve) {
|
||||||
|
/* istanbul ignore if */
|
||||||
|
if (!(fn instanceof Function)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (typeof extendRoutesFromConfig !== 'function') {
|
||||||
|
return fn.call(this, routes, resolve)
|
||||||
|
}
|
||||||
|
let extendedRoutes = extendRoutesFromConfig.call(this, routes, resolve)
|
||||||
|
if (extendedRoutes === undefined) {
|
||||||
|
extendedRoutes = routes
|
||||||
|
}
|
||||||
|
let moduleExtendedRoutes = fn.call(this, extendedRoutes, resolve)
|
||||||
|
if (moduleExtendedRoutes === undefined) {
|
||||||
|
return extendedRoutes
|
||||||
|
}
|
||||||
|
return moduleExtendedRoutes
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
requireModule (moduleOpts) {
|
requireModule (moduleOpts) {
|
||||||
|
1
test/fixtures/module/modules/basic/index.js
vendored
1
test/fixtures/module/modules/basic/index.js
vendored
@ -20,6 +20,7 @@ module.exports = function basicModule (options, resolve) {
|
|||||||
// Extend routes
|
// Extend routes
|
||||||
this.extendRoutes((routes, resolve) => {
|
this.extendRoutes((routes, resolve) => {
|
||||||
// Do nothing!
|
// Do nothing!
|
||||||
|
return routes
|
||||||
})
|
})
|
||||||
|
|
||||||
// Require same module twice
|
// Require same module twice
|
||||||
|
Loading…
Reference in New Issue
Block a user