Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

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

Open
TonyBogdanov opened this issue Apr 7, 2017 · 0 comments

Comments

@TonyBogdanov
Copy link

TonyBogdanov commented Apr 7, 2017

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant