mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 17:37:14 +00:00
Fix Module Require
This commit is contained in:
parent
497d673727
commit
a8d681af3f
@ -60,21 +60,21 @@ class Module {
|
|||||||
}
|
}
|
||||||
// Allows passing runtime options to each module
|
// Allows passing runtime options to each module
|
||||||
const options = moduleOpts.options || {}
|
const options = moduleOpts.options || {}
|
||||||
const src = moduleOpts.src || moduleOpts
|
let src = moduleOpts.src || moduleOpts
|
||||||
// Resolve module
|
// Resolve module
|
||||||
let module
|
let module
|
||||||
try {
|
try {
|
||||||
if (typeof src === 'string') {
|
if (typeof src === 'string') {
|
||||||
// Using ~ shorthand modules are resolved from project srcDir
|
// Using ~ shorthand modules are resolved from project srcDir
|
||||||
if (src.indexOf('~') === 0) {
|
if (src.indexOf('~') === 0) {
|
||||||
module = require(path.resolve(this.options.srcDir, src.substr(1)))
|
src = path.resolve(this.options.srcDir, src.substr(1))
|
||||||
} else {
|
|
||||||
module = require(src)
|
|
||||||
}
|
}
|
||||||
|
// eslint-disable-next-line no-eval
|
||||||
|
module = eval('require')(src)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// eslint-disable-next-line no-console
|
// 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
|
// eslint-disable-next-line no-console
|
||||||
console.error(e)
|
console.error(e)
|
||||||
return
|
return
|
||||||
@ -86,7 +86,7 @@ class Module {
|
|||||||
}
|
}
|
||||||
// Call module with `this` context and pass options
|
// Call module with `this` context and pass options
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
return module.apply(this, options, err => {
|
return module.call(this, options, err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return reject(err)
|
return reject(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user