0

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:

  1. Use simple optimizations only (probably a non-starter)
  2. Rewrite code to prevent this situation so the optimizer won't do it (very reluctant to do this because it's code in the Dojo library and it's unclear to me how many places this will be)
  3. Change the Closure activity somehow? (without a configuration option I probably have no idea how/ability to do this)

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.

1 Answer 1

1

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.