Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
fix(nuxt): allow auto-import component with same filename (#7713)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Oct 3, 2022
1 parent c116303 commit a3fd419
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/nuxt/src/components/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++}`
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/basic/components/Nested/SugarCounter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script setup lang="ts">
defineProps({
count: Number
})
</script>

<template>
<div>
<SugarCounter :count="count" />
</div>
</template>
2 changes: 1 addition & 1 deletion test/fixtures/basic/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<NuxtLink to="/">
Link
</NuxtLink>
<SugarCounter :count="12" />
<NestedSugarCounter :count="12" />
<CustomComponent />
<component :is="`test${'-'.toString()}global`" />
<component :is="`with${'-'.toString()}suffix`" />
Expand Down

0 comments on commit a3fd419

Please sign in to comment.