mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 06:05:11 +00:00
refactor: consistent behavior for resolveModule
- always prefer explicit paths config - avoid implicitly depending on pwd
This commit is contained in:
parent
4295c6ca26
commit
d4461a56e4
@ -28,7 +28,7 @@ export default class Resolver {
|
||||
resolveModule (path, { paths } = {}) {
|
||||
try {
|
||||
return this._require.resolve(path, {
|
||||
paths: [].concat(paths || [], this.options.modulesDir)
|
||||
paths: [].concat(paths || [], this.options.modulesDir, global.__NUXT_PATHS__ || [])
|
||||
})
|
||||
} catch (error) {
|
||||
if (error.code !== 'MODULE_NOT_FOUND') {
|
||||
|
@ -68,11 +68,7 @@ export function resolveModule (id, paths) {
|
||||
paths = [paths]
|
||||
}
|
||||
return _require.resolve(id, {
|
||||
paths: [
|
||||
process.cwd(),
|
||||
...(paths || []),
|
||||
...(global.__NUXT_PATHS__ || [])
|
||||
]
|
||||
paths: [].concat(paths || [], global.__NUXT_PATHS__ || [])
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user