jimsynz / faye-rails

Simple Rails glue for the Faye messaging protocol.
MIT License
435 stars 79 forks source link

'use strict' in faye.js causes problems on production #48

Open ghost opened 11 years ago

ghost commented 11 years ago

faye.js and other related files should be enclosed in (function(){ })(); blocks to avoid leaking this definition into other scripts when sprockets concatenates the files.

jimsynz commented 11 years ago

Doesn't Sprockets do this automatically?

ghost commented 11 years ago

It seems to be doing it for everything but faye.js, so, either sprockets is trolling me or it's assuming that it's already done for builtin libraries.

jimsynz commented 11 years ago

It's not just you :(

curl -s http://localhost:3000/assets/faye.js | head -1 | cut -c 1-100
'use strict';var Faye={VERSION:'0.8.9',BAYEUX_VERSION:'1.0',ID_LENGTH:160,JSONP_CALLBACK:'jsonpcallb
jimsynz commented 11 years ago

Can you try using version 1.0.10 and get back to me?

ghost commented 11 years ago

It still seems to be broken for me, but I'm going to play around with it and make sure that it's not a problem on my side. The file is wrapped in the closure, so, it should work.

ghost commented 11 years ago

Okay, so, update: for whatever reason, faye-rails 1.0.10 breaks everything, but I've separated faye from the assets and loaded version 1.0.8 separately and it works (this doesn't work for v1.0.10).

So, this is still broken, but for now, this should at least be posted as a workaround.

jimsynz commented 11 years ago

Okay, I've updated the closure to pass in this in e859e56. How did that go?

ghost commented 11 years ago

I still seem to be getting a TypeError: this is undefined. Although, I'm having trouble determining where the this is because the source map is missing. I think that it's in Faye.