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

tsconfig target is not ignored for both dev and build #10167

Closed
7 tasks done
htmnk opened this issue Sep 19, 2022 · 3 comments · Fixed by #10207
Closed
7 tasks done

tsconfig target is not ignored for both dev and build #10167

htmnk opened this issue Sep 19, 2022 · 3 comments · Fixed by #10207
Labels
has workaround p4-important Violate documented behavior or significantly improves performance (priority)

Comments

@htmnk
Copy link

htmnk commented Sep 19, 2022

Describe the bug

When target: es5 is set in tsconfig.json and vite.config.ts exists, Vite fails to start

with esbuild errors

ERROR: Transforming const to the configured target environment ("ES5") is not supported yet

Seems to be an issue with 3.1.0 and up

working example with 3.0.9:

https://stackblitz.com/edit/vitejs-vite-p9qdrs?file=package.json&terminal=dev

very likely related to

#9457

Reproduction

https://stackblitz.com/edit/vitejs-vite-wrp8cb?file=package.json&terminal=dev

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.1.0 => 3.1.0

Used Package Manager

npm

Logs

No response

Validations

@htmnk htmnk changed the title tsconfig target is not ignored tsconfig target with es5 is not ignored when building and causing errors Sep 19, 2022
@sapphi-red
Copy link
Member

It seems there's a change in esbuild that is affecting this.

Transforming const a = 7 with --tsconfig-raw='{"compilerOptions": { "target": "ES5" }}' works with esbuild 0.15.7 but does not work with 0.15.8.

esbuild repl 0.15.7
esbuild repl 0.15.8

For a workaround, you could set esbuild.target: 'esnext'.

@sapphi-red sapphi-red added p2-edge-case Bug, but has workaround or limited in scope (priority) and removed pending triage labels Sep 21, 2022
@htmnk
Copy link
Author

htmnk commented Sep 21, 2022

@sapphi-red 's workaround to change the esbuild.target worked for me

@sapphi-red sapphi-red added has workaround p4-important Violate documented behavior or significantly improves performance (priority) and removed p2-edge-case Bug, but has workaround or limited in scope (priority) labels Sep 22, 2022
@sapphi-red sapphi-red changed the title tsconfig target with es5 is not ignored when building and causing errors tsconfig target is not ignored for both dev and build Sep 22, 2022
@brillout
Copy link
Contributor

Another related bug: https://github.com/brillout/vps-vite3.1-bug. For this bug setting vite.config.js#esbuild.target to esnext doesn't work (see the vite.config.js of the reproduction). However, setting tsconfig.json#compilerOptions.target to ES2020 does work.

I would have expected vite.config.js#esbuild.target to override tsconfig.json#compilerOptions.target?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has workaround p4-important Violate documented behavior or significantly improves performance (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants