question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why not use tsc instead of esbuild for production build?

See original GitHub issue

The 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:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

5reactions
jods4commented, Jan 22, 2021

But for many, this is already done by the IDE

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.

2reactions
yyx990803commented, Jan 21, 2021

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 or npm-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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

FAQ - ESBuild
I'm running esbuild with --bundle --minify --sourcemap . I used the @rollup/plugin-terser plugin because Rollup itself doesn't support minification. Webpack 5 ...
Read more >
I looked at using ESbuild and I use Typescript. It was all ...
It's true that tsc on its own can replace a build step for some folks, but you'll quickly find it limiting both in...
Read more >
Setting up esbuild for TypeScript libraries - notes on software.
esbuild is a new build tool for JavaScript that claims to be 10-100x faster than similar projects (webpack, rollup, etc). I've started using...
Read more >
What tool do you use to bundle your node typescript ... - Reddit
Just use tsc for production and ts-node for development. You don't need to bundle your code for backend, just compile and run.
Read more >
esbuild-node-tsc - npm
Build your Typescript Node.js projects using blazing fast esbuild. Since esbuild can build large typescript node projects in subsecond speeds, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found