vite icon indicating copy to clipboard operation
vite copied to clipboard

Vite 3.0 generate different code between development and production

Open IWANABETHATGUY opened this issue 2 years ago • 1 comments

Describe the bug

  1. run pnpm dev and open the browser render below image
  2. run pnpm build and live-server dist render below: image

Reproduction

https://github.com/IWANABETHATGUY/vite-codegen-issue

System Info

Binaries:
    Node: 18.2.0 - /tmp/fnm_multishells/188949_1658144339703/bin/node
    Yarn: 1.22.19 - ~/.local/share/pnpm/yarn
    npm: 8.9.0 - /tmp/fnm_multishells/188949_1658144339703/bin/npm
  Browsers:
    Chrome: 103.0.5060.114
    Firefox: 102.0.1
  npmPackages:
    vite: ^3.0.0 => 3.0.1

Used Package Manager

pnpm

Logs

No response

Validations

IWANABETHATGUY avatar Jul 18 '22 13:07 IWANABETHATGUY

It worked correctly when you opt-in esbuild deps optimization at build time. https://vitejs.dev/guide/migration.html#using-esbuild-deps-optimization-at-build-time

Also it worked with 3.0.0-beta.2 but didn't work with 3.0.0-beta.3. https://stackblitz.com/edit/github-rfkfeg?file=package.json,main.js,vite.config.js Maybe @rollup/plugin-commonjs v22 is affecting this (https://github.com/vitejs/vite/pull/8743).

sapphi-red avatar Jul 18 '22 13:07 sapphi-red

Closing as I confirmed this is already fixed in 3.0.9.

sapphi-red avatar Oct 21 '22 03:10 sapphi-red

Thanks

IWANABETHATGUY avatar Oct 21 '22 03:10 IWANABETHATGUY