Skip to content

Duplicate module on Windows if build.rollupOptions.input is relative path #15153

@sapphi-red

Description

@sapphi-red

Describe the bug

If build.rollupOptions.input is relative path, like below,

import { defineConfig } from 'vite';

export default defineConfig({
  build: {
    rollupOptions: {
      input: {
        main: 'src/main.js',
        'lib/example': 'src/lib/example.js',
      },
    },
  },
});

the module is duplicated only on Windows. (In this example, src/lib/example.js is bundled twice. (This doesn't happen with rollup)

The workaround is to call path.resolve() (e.g. path.resolve('src/lib/example.js').

Reproduction

https://stackblitz.com/edit/rollup-repro-kizyn2?file=vite.config.js

Steps to reproduce

No response

System Info

System:
    OS: Windows 11 10.0.22621
    CPU: (16) x64 13th Gen Intel(R) Core(TM) i7-1360P
    Memory: 16.73 GB / 31.62 GB
  Binaries:
    Node: 20.9.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
    npm: 10.1.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.3.1 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Edge: Chromium (119.0.2151.72)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    rollup: ^4.5.0 => 4.6.0
    vite: ^5.0.2 => 5.0.2

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions