Skip to content

Vue SFC generates duplicate files with numeric suffixes during library build #632

@lhz960904

Description

@lhz960904

Describe the bug

When building a Vue library with npm run build, a single button.vue component generates two files with the same base name, resulting in button.js and button2.js. The button2.js file contains only a simple re-export that imports from button.js, expect only generate button.js

Reproduction

https://stackblitz.com/edit/vitejs-vite-g1wlnnnn?file=dist%2Fes%2Fbutton%2Fbutton2.js

Steps to reproduce

  1. Run pnpm run build
  2. Check the output in dist/es/button/ directory
  3. Observe that both button.js and button2.js are generated

System Info

System:
    OS: macOS 14.1
    CPU: (10) arm64 Apple M2 Pro
    Memory: 85.28 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.17.1 - ~/.nvm/versions/node/v22.17.1/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v20.10.0/bin/yarn
    npm: 10.9.2 - ~/.nvm/versions/node/v22.17.1/bin/npm
    pnpm: 10.13.1 - ~/.nvm/versions/node/v20.10.0/bin/pnpm
    bun: 1.1.8 - ~/.bun/bin/bun
  Browsers:
    Chrome: 138.0.7204.158
    Safari: 17.1
  npmPackages:
    @vitejs/plugin-vue: ^6.0.0 => 6.0.0 
    @vitejs/plugin-vue-jsx: ^5.0.1 => 5.0.1 
    vite: ^7.0.4 => 7.0.4

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions