From a8d681af3f619f2a60438ceb795676076de98a5a Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 11 May 2017 16:28:20 +0430 Subject: [PATCH] Fix Module Require --- lib/module.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/module.js b/lib/module.js index b2303eb36a..05305d5313 100755 --- a/lib/module.js +++ b/lib/module.js @@ -60,21 +60,21 @@ class Module { } // Allows passing runtime options to each module const options = moduleOpts.options || {} - const src = moduleOpts.src || moduleOpts + let src = moduleOpts.src || moduleOpts // Resolve module let module try { if (typeof src === 'string') { // Using ~ shorthand modules are resolved from project srcDir if (src.indexOf('~') === 0) { - module = require(path.resolve(this.options.srcDir, src.substr(1))) - } else { - module = require(src) + src = path.resolve(this.options.srcDir, src.substr(1)) } + // eslint-disable-next-line no-eval + module = eval('require')(src) } } catch (e) { // eslint-disable-next-line no-console - console.error('[Nuxt] Unable to resolve module', module) + console.error('[Nuxt] Unable to resolve module', src) // eslint-disable-next-line no-console console.error(e) return @@ -86,7 +86,7 @@ class Module { } // Call module with `this` context and pass options return new Promise((resolve, reject) => { - return module.apply(this, options, err => { + return module.call(this, options, err => { if (err) { return reject(err) }