From f3168d923bcecb3783e59bb572b8b14fb3c89dba Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Tue, 22 Mar 2022 10:35:16 +0000 Subject: [PATCH] fix(nuxt3): respect `srcDir` and normalize string in component dirs (#3815) Co-authored-by: pooya parsa --- packages/nuxt3/src/components/module.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/packages/nuxt3/src/components/module.ts b/packages/nuxt3/src/components/module.ts index 99d3d358ec..33c6ec2e66 100644 --- a/packages/nuxt3/src/components/module.ts +++ b/packages/nuxt3/src/components/module.ts @@ -33,22 +33,16 @@ export default defineNuxtModule({ } if (typeof dir === 'string') { return { - path: resolve(cwd, resolveAlias(dir, { - ...nuxt.options.alias, - '~': cwd - })) + path: resolve(cwd, resolveAlias(dir)) } } if (!dir) { return [] } - const dirs = (dir.dirs || [dir]).filter(_dir => _dir.path) + const dirs = (dir.dirs || [dir]).map(dir => typeof dir === 'string' ? { path: dir } : dir).filter(_dir => _dir.path) return dirs.map(_dir => ({ ..._dir, - path: resolve(cwd, resolveAlias(_dir.path, { - ...nuxt.options.alias, - '~': cwd - })) + path: resolve(cwd, resolveAlias(_dir.path)) })) } @@ -56,7 +50,7 @@ export default defineNuxtModule({ nuxt.hook('app:resolve', async () => { // components/ dirs from all layers const allDirs = nuxt.options._layers - .map(layer => normalizeDirs(layer.config.components, layer.cwd)) + .map(layer => normalizeDirs(layer.config.components, layer.config.srcDir)) .flat() await nuxt.callHook('components:dirs', allDirs)