vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.43k stars 6.17k forks source link

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

Open sapphi-red opened 11 months ago

sapphi-red commented 11 months ago

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

HawtinZeng commented 8 months ago

Can't find the difference between vite bundles and rollup bundles in the reproduction project, nor the duplicate module. image

sapphi-red commented 8 months ago

This only happens on Windows. Did you try it on Windows? image

HawtinZeng commented 8 months ago

I ran it on stackblitz, i will try it locally later.

---Original--- From: @.> Date: Tue, Feb 27, 2024 13:09 PM To: @.>; Cc: "Hawtin @.**@.>; Subject: Re: [vitejs/vite] Duplicate module on Windows ifbuild.rollupOptions.input is relative path (Issue #15153)

This only happens on Windows. Did you try it on Windows? image.png (view on web)

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>