PolymerLabs / crisper

BSD 3-Clause "New" or "Revised" License
106 stars 22 forks source link

Semicolon not added when script ending with a comment causes issues when concatenating #49

Open TonyBogdanov opened 7 years ago

TonyBogdanov commented 7 years ago

Whenever there's a comment at the last line of a script, no final semicolon (;) will be added even if the script needs it. When concatenated with the next script, the lack of this final semicolon leads to fatal issues.

Consider the following two scripts:

(function() {
    console.log('ok1');
})()
// some comment
(function() {
    console.log('ok2');
})()

Since the last line of script 1 has a comment, no semicolon is added and the final resulting script is interpreted as:

(function(){console.log('ok1')})()(function(){console.log('ok2')})()

throwing a Uncaught TypeError: (intermediate value)(...) is not a function.

And before anyone says that this is most probably an issue with the source scripts, the actual case which led me to find this issue is a source map comment automatically added to the end of some scripts.

More specifically, for me, that was the shadycss shim required by the polymer 2.0 core.