We've recently upgraded from Dojo 1.10 to Dojo 1.16. (yes, recently.) With this is a newer version of the Closure compiler, which is great, because our builds were often ruined by otherwise acceptable trailing commas in arrays. But now that the business has given us permission to only support IE in version 11, we were able to upgrade.
I'm very happy we'll be able to use more ES6, as the previous Closure didn't allow let, const, etc. However, when given this construction:
return {l: l, t: t, w: node.offsetWidth + me.w, h: node.offsetHeight + me.h};
the compiler will (may?) reduce it to this:
return{l,t:g,w:a.offsetWidth+c.w,h:a.offsetHeight+c.h}};
The problem is that it uses valid ES6 shorthand to reduce l: l
to just l
, but IE11 doesn't recognize this, so our code gives a syntax error there.
I've done a lot of searching on this and can't see if there's any configuration that could be applied to Closure to stop this specifically. At the moment the only solutions I see are:
Looking through the existing configuration I found these and tried adding them to my optimizer options:
optimizeOptions: {
'coalesceVariableNames': false,
'collapseProperties': false,
'collapseVariableDeclarations': false,
'removeDeadCode': false,
'rewriteFunctionExpressions': false,
'smartNameRemoval': false
},
This did seem to make a difference but only in the sense that it transformed the code this time as return{l:t,t:q,w:a.offsetWidth+m.w,h:a.offsetHeight+m.h}};
, so I don't know if I've actually fixed it, or this time around it decided to change the variable l
to t
, and it's just deferred the problem to some unknown point in the future.
IE11 doesn't support EcmaScript 6*, be sure you are using the appropriate "language_out", which would be "ECMASCRIPT5" and the compiler will translate it to something IE11 does understand.
*What ES6 syntax and library IE11 does understand like let
and const
it does so in a way that doesn't comply with the spec.