From a3fd4193ce8254bd83fba4399016dc4c6a5ae957 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Mon, 3 Oct 2022 14:38:43 +0100 Subject: [PATCH] fix(nuxt): allow auto-import component with same filename (#7713) --- packages/nuxt/src/components/loader.ts | 2 +- .../fixtures/basic/components/Nested/SugarCounter.vue | 11 +++++++++++ test/fixtures/basic/pages/index.vue | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/basic/components/Nested/SugarCounter.vue diff --git a/packages/nuxt/src/components/loader.ts b/packages/nuxt/src/components/loader.ts index ee0a86b5bf..517db352ac 100644 --- a/packages/nuxt/src/components/loader.ts +++ b/packages/nuxt/src/components/loader.ts @@ -65,7 +65,7 @@ export const loaderPlugin = createUnplugin((options: LoaderOptions) => { const s = new MagicString(code) // replace `_resolveComponent("...")` to direct import - s.replace(/(?<=[ (])_?resolveComponent\(\s*["'](lazy-|Lazy)?([^'"]*?)["'][\s,]*\)/g, (full, lazy, name) => { + s.replace(/(?<=[ (])_?resolveComponent\(\s*["'](lazy-|Lazy)?([^'"]*?)["'][\s,]*[^)]*\)/g, (full, lazy, name) => { const component = findComponent(components, name, options.mode) if (component) { let identifier = map.get(component) || `__nuxt_component_${num++}` diff --git a/test/fixtures/basic/components/Nested/SugarCounter.vue b/test/fixtures/basic/components/Nested/SugarCounter.vue new file mode 100644 index 0000000000..224dca4e5e --- /dev/null +++ b/test/fixtures/basic/components/Nested/SugarCounter.vue @@ -0,0 +1,11 @@ + + + diff --git a/test/fixtures/basic/pages/index.vue b/test/fixtures/basic/pages/index.vue index eb335bfca5..31a5cdae56 100644 --- a/test/fixtures/basic/pages/index.vue +++ b/test/fixtures/basic/pages/index.vue @@ -12,7 +12,7 @@ Link - +