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

[v5] Use ts loader and ts-jest for typescript transpilation #11247

Open
raix opened this issue Jul 26, 2021 · 12 comments
Open

[v5] Use ts loader and ts-jest for typescript transpilation #11247

raix opened this issue Jul 26, 2021 · 12 comments

Comments

@raix
Copy link
Contributor

raix commented Jul 26, 2021

Is your proposal related to a problem?

When developing typescript applications it would be great to use typescript compiler instead of babel transform etc. to better respect the tsconfig.

A similar aspect is the missing typechecking of test / jest files again moving to ts-jest would greatly improve the DX in this area for TypeScript developers
(ts-jest loaders configured with the same babel presets as the actual build...)

Describe the solution you'd like

  1. use ts-loader for transformation (keeping fork-ts-checker for the typechecking)
  2. use ts-jest for transformation and type checking in tests (with babel configured)
  3. Reduce babel for typescript files to do babel env/react and for now fast-refresh

Describe alternatives you've considered

We already use babel as the alternative, would only consider those two

Additional context

@raix
Copy link
Contributor Author

raix commented Jul 26, 2021

cc. @arogozine added this issue for tracking better support for typescript in CRA

@raix raix added this to the 5.0 milestone Aug 2, 2021
@raix
Copy link
Contributor Author

raix commented Aug 2, 2021

(or use the swc-loader to replace both babel and typescript loaders)

@Nedlinin
Copy link

Nedlinin commented Aug 4, 2021

I'm not sure swc-loader respects tsconfig at all though the switch would probably improve compilation speeds a good bit.

@keropodium
Copy link

I'm not sure swc-loader respects tsconfig at all though the switch would probably improve compilation speeds a good bit.

No, currently it doesn't. See this.

@InSuperposition
Copy link

InSuperposition commented Aug 26, 2021

This comment lists a few more options for using SWC with a tsconfig file.
swc-project/swc#1348 (comment)

Parcel's v2 branch uses swc (along with babel) and has a few plugins to replace their babel plugin counterparts

Babel v SWC features
SWC vs babel vs tsc benchmarks

@Bnaya
Copy link

Bnaya commented Oct 6, 2021

TL; DR;
What are you missing from the tsconfig? :)

I haven't benchmarked it, but i feel it will make typescript transpilation slower as you will pass it through 2 loaders and not only babel.

Also, using ts-loader + transpileOnly still does not support 100% of possible tsconfig settings (no const enums etc).
You might get projects references support.

What other parts of the tsconfig you have in mind?

And a general note regarding typescript performance:
While the DX is not ideal, running TSC in a separate terminal tab/process will be faster and more regressions proof than even using fork-ts-checker

tsc is the reference implementation of all of the new stuff and it's performance are beaning monitored directly by the typescript team as part of their workflow,
while tools like ts-loader & fork-ts-checker are maybe using the same apis internally, it took them long time to get a PR from someone in the typescript team to get incremental builds ,project references, and still they had issues compare to tsc.

@raix
Copy link
Contributor Author

raix commented Oct 6, 2021

@Bnaya in babel you have to add certain plugins rather than just using the tsconfig...
Regarding jest having the same transpilation and typechecking is great for consistency and DX

@Bnaya
Copy link

Bnaya commented Oct 12, 2021

But CRA abstracts that away from you
All of babel is made of plugins, and it's preconfigured for you.

Regarding DX I tend to agree, but due to performance reasons and toolchain complexity I wound't go there

@osddeitf
Copy link

osddeitf commented Nov 7, 2021

Is that issue preventing v5 to be released?

@raix
Copy link
Contributor Author

raix commented Nov 7, 2021

Nope - v5 is very close for a release, just some hickup with node 17 and latest webpack breaking tests afaik

@raix raix modified the milestones: 5.0, 5.x Nov 27, 2021
@dima-vakatsiienko
Copy link

Do not use babel, use SWC in V5.

@marcandrews
Copy link

Support for project references would be really nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants