From d4461a56e42ca575de3a8d6f58efba0d298a7190 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 23 Dec 2020 00:29:50 +0100 Subject: [PATCH] refactor: consistent behavior for resolveModule - always prefer explicit paths config - avoid implicitly depending on pwd --- packages/core/src/resolver.js | 2 +- packages/utils/src/cjs.js | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/core/src/resolver.js b/packages/core/src/resolver.js index b3c7ebcb70..78c83b5873 100644 --- a/packages/core/src/resolver.js +++ b/packages/core/src/resolver.js @@ -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') { diff --git a/packages/utils/src/cjs.js b/packages/utils/src/cjs.js index 750030e353..491aae4113 100644 --- a/packages/utils/src/cjs.js +++ b/packages/utils/src/cjs.js @@ -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__ || []) }) }