paulmillr / ostio

Your open-source talks place.
http://ost.io
247 stars 44 forks source link

"not a function" error in vendor.js? #13

Closed DallanQ closed 12 years ago

DallanQ commented 12 years ago

I followed the instructions in the readme to run the application (using brunch w -s option), but I'm getting a "not a function" error at line 1455 in vendor.js. Specifically, in chrome the error is "Uncaught TypeError: undefined is not a function"; in Firefox, firebug highlights the last snippet of Zepto code from line 1366-1446 and complains that it is not a function.

It appears to have something to do with an interaction between javascript's semicolon placement, zepto use of semicolons, and how the vendor.js file is generated by brunch (I have version 1.2.2). I notice that the function definitions in zepto all use the style:

})(Zepto)
;(function($){

where the ; is at the beginning of the following function definition.  But the zepto-1.0.0rc1.js file does not end in a semicolon. When zepto-1.0.0rc1.js is catenated with underscore-1.3.3.js in vendor.js, the result is:

})(Zepto)
//     Underscore.js 1.3.3
//     (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
//     Underscore is freely distributable under the MIT license.
//     Portions of Underscore are inspired or borrowed from Prototype,
//     Oliver Steele's Functional, and John Resig's Micro-Templating.
//     For all details and documentation:
//     http://documentcloud.github.com/underscore

(function() {

Notice there is no semicolon between the last line in zepto and the first line in underscore. If I manually add a semicolon to the beginning of the underscore "(function() {" line above in vendor.js, everything works.

paulmillr commented 12 years ago

right. this bullshit is because of zepto maintainers somehow don't like semicolons (lol wat?).

I've modified brunch to auto-add semicolons after every vendor file. New version wasn't released yet but you can get it via npm install -g git://github.com/brunch/brunch.git. Or you can append semicolon after zepto.js.

DallanQ commented 12 years ago

That did it! Good idea about auto-adding semicolons. Thanks.