Closed ekb1zh closed 2 years ago
- If not, so how would such code work in older browsers?
Per https://github.com/jaredpalmer/tsdx/issues/968#issuecomment-791817207 , polyfills are currently out-of-scope for TSDX. They were planned per that answer but were never a part of TSDX outside of regenerator/async/await. That answer also mentions how polyfills in libraries are still a topic of discussion in the JS community.
Adding the .browserslistrc
as such will effectively tell @babel/preset-env
to transform your code to as old as possible, but it won't insert polyfills for behavior that can't be transpiled down to an earlier environment.
The "suggested solution" in https://github.com/jaredpalmer/tsdx/issues/968#issuecomment-791817207 is still the suggested solution in this case, that would make corejs
polyfills added. usage-pure
means it won't pollute the consumer environment and many consumers already have corejs
installed anyway, so that is my suggestion when it comes to the topic of polyfills in libraries.
(Side note: babel-polyfills
is also now a very stable collection of packages and is actually used under-the-hood of preset-env
nowadays. I've also contributed a good bit to it and recently migrated it to TS)
My algorithm:
Result - polyfills are absent. But they are need for execute code in
dead
browsers ))These questions have been discussed in these threads
.browserslistrc
https://github.com/jaredpalmer/tsdx/issues/951,Object.fromEntries
https://github.com/jaredpalmer/tsdx/issues/968,tslib
https://github.com/jaredpalmer/tsdx/issues/412, but I didn't find an answer to the question - if targeting.browserslist
file to the old browsers, should TSDX add polyfills?