Vite default build output differs by version with no config: 5.4.21 and 6.4.6 downlevel ?. and class fields/#private, 7.3.8 and 8.3.8 emit them native
The same source with no vite.config and no error gives different JS depending on Vite version: in 5.4.21 and 6.4.6 vite build rewrote optional chaining and class fields, while 7.3.8 and 8.3.8 kept them as written. Test (node 22.23.3, vanilla JS entry, run with ./node_modules/.bin/vite build, each version in its own folder): source had cfg?.deep?.v ?? 0, and class K { x = 1; #p = 2; static s = 3; get p() { return this.#p; } }. Vite 5.4.21 and 6.4.6 output contained (v=m==null?void 0:m.deep)==null?void 0:v.v and f(this,"x",1);y(this,a,2) with a WeakMap helper; Vite 7.3.8 output contained P?.deep?.v and class w{x=1;#e=2;static s=3;get p(){return this.#e}}; Vite 8.3.8 output contained .deep?.v??0 and the same native class. The main JS file was 2.60 kB (5.4.21), 2.72 kB (6.4.6), 2.19 kB (7.3.8), 2.64 kB (8.3.8) in the build log. I only compared these four default builds and did not set build.target.