Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useDefineForClassFields value changed from 3.1 when it's derived from target #10296

Closed
7 tasks done
sapphi-red opened this issue Sep 30, 2022 · 0 comments · Fixed by #11301
Closed
7 tasks done

useDefineForClassFields value changed from 3.1 when it's derived from target #10296

sapphi-red opened this issue Sep 30, 2022 · 0 comments · Fixed by #11301
Labels
p4-important Violate documented behavior or significantly improves performance (priority)

Comments

@sapphi-red
Copy link
Member

sapphi-red commented Sep 30, 2022

Describe the bug

When useDefineForClassFields is not set in tsconfig, the value is derived from target.
When target is ES2022+ or ESNext, useDefineForClassFields is true otherwise it's false.

This is documented here as well.
But it seems this was not working and still not working in some cases.

related: #10167, #10292

tsconfig.compilerOptions.target = 'ESNext' && build.target = 'ESNext'

Vite esbuild command resolved useDefineForClassFields
3.0.9 0.14.47 dev false
3.0.9 0.14.47 build false
3.1.4 0.15.10 dev true
3.1.4 0.15.10 build true

The behavior changed but I think the new behavior is correct.

tsconfig.compilerOptions.target = 'ES2021' && build.target = 'ES2021'

Vite esbuild command resolved useDefineForClassFields
3.0.9 0.14.47 dev false
3.0.9 0.14.47 build false
3.1.4 0.15.10 dev true
3.1.4 0.15.10 build true

The behavior changed and I think the new behavior is not correct.

tsconfig.compilerOptions.target = 'ESNext' && build.target = 'ES2021'

Vite esbuild command resolved useDefineForClassFields
3.0.9 0.14.47 dev false
3.0.9 0.14.47 build false
3.1.4 0.15.10 dev true
3.1.4 0.15.10 build true

The behavior changed but I think the new behavior is correct.

tsconfig.compilerOptions.target = 'ES2021' && build.target = 'ESNext'

Vite esbuild command resolved useDefineForClassFields
3.0.9 0.14.47 dev false
3.0.9 0.14.47 build false
3.1.4 0.15.10 dev true
3.1.4 0.15.10 build true

The behavior changed and I think the new behavior is not correct.
I think useDefineForClassFields should be derived from tsconfig.compilerOptions.target and not from build.target.

related esbuild's behavior

Before esbuild 0.15.8, esbuild derived useDefineForClassFields from build.target and not from tsconfig.compilerOptions.target. But from 0.15.8, it seems the behavior changed.
When target = 'es2021' + tsconfig.compilerOptions.target = 'esnext', I think the new behavior is correct.
When target = 'esnext' + tsconfig.compilerOptions.target = 'es2021', I think the behavior might not be correct.

esbuild repl 0.15.7 target = 'es2021' + tsconfig.compilerOptions.target = 'esnext'
esbuild repl 0.15.8 target = 'es2021' + tsconfig.compilerOptions.target = 'esnext'

esbuild repl 0.15.7 target = 'esnext' + tsconfig.compilerOptions.target = 'es2021'
esbuild repl 0.15.8 target = 'esnext' + tsconfig.compilerOptions.target = 'es2021'

Reproduction

https://stackblitz.com/edit/vitejs-vite-tkrvzm (Vite 3.0.9 && tsconfig.compilerOptions.target = 'ESNext' && build.target = 'ES2021')

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    vite: ~3.0.0 => 3.0.9

Used Package Manager

npm

Logs

No response

Validations

@sapphi-red sapphi-red added the p4-important Violate documented behavior or significantly improves performance (priority) label Sep 30, 2022
sapphi-red added a commit to sapphi-red/vite that referenced this issue Dec 10, 2022
sapphi-red added a commit that referenced this issue Dec 11, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 26, 2022
futurGH pushed a commit to futurGH/vite that referenced this issue Feb 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p4-important Violate documented behavior or significantly improves performance (priority)
Projects
None yet
1 participant