Skip to content

Ambiguous import "..." has multiple matching exports #16211

@maantje

Description

@maantje

Describe the bug

I have a component (A) with a default export of the component and a named export in the same file. This component also contains an import.meta.glob and imports a directory (B).

Subsequently, Component A is imported into another component, C, which also contains an import.meta.glob of the same directory.

This results in:

Error:   Failed to scan for dependencies from entries:
  /home/projects/vue3-vite-starter-w2qd5j/index.html

  ✘ [ERROR] Ambiguous import "something" has multiple matching exports

    script:/home/projects/vue3-vite-starter-w2qd5j/src/App.vue?id=0:2:21:
      2 │ import HelloWorld, { something } from '@/components/HelloWorld.vue'
        ╵                      ~~~~~~~~~

  One matching export is here:

    script:/home/projects/vue3-vite-starter-w2qd5j/src/components/HelloWorld.vue?id=0:19:13:
      19 │ export const something = 'something'
         ╵              ~~~~~~~~~

  Another matching export is here:

    script:/home/projects/vue3-vite-starter-w2qd5j/src/components/HelloWorld.vue?id=1:19:13:
      19 │ export const something = 'something'

This issue arises only when the directory imported with import.meta.glob contains multiple files.

Overview:

Untitled-2024-01-25-1600

Reproduction

https://stackblitz.com/edit/vue3-vite-starter-w2qd5j

Steps to reproduce

Run yarn dev --force

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.3 - /usr/local/bin/pnpm
  npmPackages:
    @vitejs/plugin-vue: ^5.0.4 => 5.0.4 
    vite: ^5.1.5 => 5.1.6

Used Package Manager

yarn

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: deps optimizerEsbuild Dependencies Optimizationp3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions