Why not use tsc instead of esbuild for production build?
See original GitHub issueThe default Vite + Typescript template uses vuedx-typecheck
before calling build to typecheck your whole project.
The official doc says you can call tsc --noEmit
to the same effect.
Which is good and I want full type checking during my final build. But it makes me wonder if it’s still worth using esbuild to compile Typescript after that.
The main benefit of esbuild is its speed. This is really great during development, but during build if you fully type-check your project, you’ve lost most of the speed as tsc had to parse and analyze your whole project. Is it really worth it to not just ask TS to do the last step of emitting code?
If esbuild had no drawback I wouldn’t care much. But using esbuild does come with a few drawbacks.
- Its downlevel codegen is not as complete as Typescript itself.
- It has a harder time than TS eliding implicit type-only imports.
- It can’t emit
const enum
properly (a PR is in the works for the non-namespaced case, hopefully that’ll work out. Namespaced const enums will never work without type checking). - It can’t create a
.d.ts
type definition file if you build a library.
Would it be interesting to make building with tsc an option?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (8 by maintainers)
Top GitHub Comments
Curious here what’s the recommended tools / plugins / workflow?
I would assume most Vue devs use VS Code. VS Code does not perform full project error reporting for TS by default. It’s hidden behind an obscure setting and I doubt most users turn it on.
Type checking is only more efficient when it’s done as an external system outside of Vite, because Vite is an on demand transform system during dev, shoe-horning typecheck into it just isn’t right in the first place.
Nothing prevents you from using something like
concurrently
ornpm-run-all
to run Vite and a type checking process in parallel, this can be done for either build or dev. But for many, this is already done by the IDE, so for Vite to do that by default can be wasteful in many cases.