Global this
can be incorrect depending on input code context
#353
Labels
bug
Something isn't working
this
can be incorrect depending on input code context
#353
The value of global
this
depends on the code context.this
isundefined
.this
ismodule.exports
.this
isglobalThis
.(0,eval)(...)
,this
isglobalThis
.this
which has no local binding is currently treated as a global, so() => this
is output unchanged as() => this
.This is mostly correct as long as output format is same as input format. But:
this
in output will refer to the wrongmodule.exports
.this
in output will be different from what it was in input.@babel/plugin-transform-modules-commonjs which is used to transform ESM to CommonJS does substitute
void 0
forthis
, so output is correct for ESM input. But the other cases don't work correctly.The text was updated successfully, but these errors were encountered: