Open raix opened 3 years ago
cc. @arogozine added this issue for tracking better support for typescript in CRA
(or use the swc-loader to replace both babel and typescript loaders)
I'm not sure swc-loader respects tsconfig at all though the switch would probably improve compilation speeds a good bit.
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.
This comment lists a few more options for using SWC with a tsconfig file. https://github.com/swc-project/swc/issues/1348#issuecomment-902700083
Parcel's v2
branch uses swc
(along with babel
) and has a few plugins to replace their babel plugin counterparts
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
.
@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
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
Is that issue preventing v5 to be released?
Nope - v5 is very close for a release, just some hickup with node 17 and latest webpack breaking tests afaik
Do not use babel, use SWC in V5.
Support for project references would be really nice.
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
Describe alternatives you've considered
We already use babel as the alternative, would only consider those two
Additional context