I’ve tried using the ES6 template and the TypeScript template and these seem to work great to add in modern javascript language support.
However I notice that Object.fromEntries() (for example) doesn’t exist. I assumed that Babel would provide a polyfill for this and presumably other things via the @babel/env preset. I’m new to k6 and Babel and wondering if anyone can point me in the right direction. Are there other presets or plugins or something that would polyfill Object.fromEntries() and/or maybe other useful functions?
Hi @citrus , welcome to the forum and sorry for the late reply.
Some versions ago we dropped core-js v2.something from being added to each k6 VU by default. This was done without losing any “real” functionality - by real I mean such that is by the ECMAScript specification and was actually useful as we for example dropped Promise, which even now if you polyfill it won’t be useful due to lack of other functionality.
In doing the above we dropped the minimum memory per VU from over 2.7mb to under 0.6mb (exact numbers are bit hard as they also depend on all the code you have). This also significantly improved how fast VUs start as now they are pretty much instant if you don’t have a huge script.
Both of those (the mem reduction and initialization speed up) are directly because we removed something like 300kb of js that is loaded per VU by dropping core-js (and implementing them in goja). As such then adding a lot of polyfills for everything just so it’s there if somebody needs it will just creep this back even if it’s just in the ES6 or TypeScript template and that will affect every user of them even if they never actually use this.
As such I doubt we will ever just add any more polyfills by default. And as you have probably already done it’s pretty easy to polyfill what you want(or need) as is in this case.
Hope this helps you understand the reason behind it and good luck.