refactor: consistent behavior for resolveModule

- always prefer explicit paths config
- avoid implicitly depending on pwd
This commit is contained in:
Pooya Parsa 2020-12-23 00:29:50 +01:00
parent 4295c6ca26
commit d4461a56e4
2 changed files with 2 additions and 6 deletions

View File

@ -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') {

View File

@ -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__ || [])
})
}