Skip to content
This repository was 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

@TonyBogdanov

Description

@TonyBogdanov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions