Skip to content

Discussion about global and experimental_enhanced #3860

@mstoykov

Description

@mstoykov

What?

extended apart from using babel (until recently) to add more ECMAScript support also adds global as an alias to globalThis

k6/js/bundle.go

Lines 387 to 392 in 111985b

if b.CompatibilityMode == lib.CompatibilityModeExtended {
err = rt.Set("global", rt.GlobalObject())
if err != nil {
return err
}
}

This was readded after the dropping of core-js #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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions