k6
k6 copied to clipboard
Discussion about `global` and `experimental_enhanced`
What?
extended
apart from using babel (until recently) to add more ECMAScript support also adds global
as an alias to globalThis
https://github.com/grafana/k6/blob/111985bfe258f1b68cc8d19c8b8a21737a5b4f89/js/bundle.go#L387-L392
This was readded after the dropping of core-js
https://github.com/grafana/k6/pull/1845 and is currently the sole difference between extended
and base
.
experimental_enhanced
doesn't add this alias.
Proposal:
Keep it this way.
I would argue that we should drop it from extended
in the future as well, but this should be discussed separately.
experimental_enhanced
doesn't have a history of supporting this, and we have had in the past had problems with this being used by libraries to detect if they are running in nodejs. Which then fails as it goes down a code path that isn't actually supported.
Nodejs and every other known to me engine supports globalThis
and that is the standard way.
We could potentially revise this in the future if there are cases that come to light that this will be beneficial.