Why use babel-loader with ts-loader?

前端 未结 1 720
自闭症患者
自闭症患者 2021-02-03 21:48

There is a TypeScript, Babel, React, and Karma Sample.

The Webpack config contains babel-loader with ts-loader for .tsx? files.

Please explain why i

相关标签:
1条回答
  • 2021-02-03 22:05

    ts-loader: convert typescript (es6) to javascript (es6)

    babel-loader: converts javascript (es6) to javascript (es5) and Typescript doesn't do polyfills, which babel does. If you write client-side code in es6 and want it to run on modern browsers, you'd probably need babel's polyfills.

    It is less justified with server-side code - just use the latest node version for es6 support. But babel still provides some goodies that tsc doesn't - like caching, or a huge range of plugins that can be very useful.

    It's not necessary but a practice for using them all together.

    0 讨论(0)
提交回复
热议问题