diff --git a/lib/module.js b/lib/module.js index b0744ff54c..142c7b7b85 100755 --- a/lib/module.js +++ b/lib/module.js @@ -85,28 +85,27 @@ class Module { // Allows passing runtime options to each module const options = moduleOpts.options || {} const originalSrc = moduleOpts.src || moduleOpts - let src = originalSrc // Resolve module - let module + let module = originalSrc try { - if (typeof src === 'string') { + if (typeof module === 'string') { // Using ~ or ./ shorthand modules are resolved from project srcDir - if (src.indexOf('~') === 0 || src.indexOf('./') === 0) { - src = path.join(this.options.srcDir, src.substr(1)) + if (module.indexOf('~') === 0 || module.indexOf('./') === 0) { + module = path.join(this.options.srcDir, module.substr(1)) } // eslint-disable-next-line no-eval - module = eval('require')(src) + module = eval('require')(module) } } catch (e) /* istanbul ignore next */ { // eslint-disable-next-line no-console - console.error('[nuxt] Unable to resolve module', src) + console.error('[nuxt] Unable to resolve module', module) // eslint-disable-next-line no-console console.error(e) process.exit(0) } // Validate module /* istanbul ignore if */ - if (!(module instanceof Function)) { + if (typeof module !== 'function') { // eslint-disable-next-line no-console console.error(`[nuxt] Module [${originalSrc}] should export a function`) process.exit(1)