javascriptminifyuglifyjsuglifyjs2

Why does UglifyJS transpile `someFunction` to `(0, v.someFunction)`?


I'm using UglifyJS to transpile a React web app, and I noticed that it seems to wrap a lot of function calls, specifically functions imported from another module/file, with (0, and ). What is the point of this?

Example: It transpiles this

var longVariableName = someFunction(some, arguments)

to this

var t = (0, v.someFunction)(some, arguments)

Solution

  • It ensures that the this context in someFunction is undefined just like in the original call, not v, as it would be in the method call v.someFunction(some, arguments).