sproutcore / build-tools

SproutCore Build Tools
12 stars 7 forks source link

Fixes a bug in combined scripts when js files don't use semicolons #64

Closed xogg closed 8 years ago

nicolasbadia commented 8 years ago

LGTM

mauritslamers commented 8 years ago

It is not entirely clear what the cause of the problem is, except the missing semicolons. In what way is the missing semicolon causing issues?

xogg commented 8 years ago

The missing semicolon is not itself a problem at all, because JavaScript permits code without semicolons.

However, a special care should be taken with code without semicolons. Let's assume, there's a file with the following content:

SC.Class.create({
...
})

and there's another file defined as:

(function()
{
...
})()

Obviously, when both files are combined in one, the resulting code will take a created object as a function and will try to call it, passing an anonymous function as a parameter. The result of this operation will be called again without parameters.

Also, there's no any problem at all with spurious semicolons, because the code ;;;;; is an absolutely correct JavaScript code consisting of various empty operators.

So, the original fix is still correct.

mauritslamers commented 8 years ago

Ok, clear.