Recently delved into the world of TypeScript and experimenting with webpack ts-loader and babel-loader to compile and transpile TypeScript into ES5. However, I came across a compiler option in tsc that can target 'ES5', which made me question the need for using babel-loader.
Here are my inquiries:
- What exactly occurs internally when the TypeScript compiler targets ES5?
- Is it possible to achieve my goal by using ts-loader alone with the tsconfig target option?
- If so, which approach is more efficient? (ts-loader to ES6 then babel-loader to ES5, or ts-loader with target option set to ES5)
- How does tree-shaking (a feature of webpack2) work in both scenarios?