Skip to content
This repository has been archived by the owner on Jul 28, 2018. It is now read-only.

Compile the CoffeeScript source to JavaScript before packaging the gem #11

Closed
wants to merge 2 commits into from

Conversation

jcoglan
Copy link

@jcoglan jcoglan commented Sep 26, 2012

To reduce users' dependency on the developer's toolchain, it helps to publish JavaScript functionality as JavaScipt, rather than as CoffeeScript. If and when CoffeeScript supports source maps, by all means bundle the source and the map with the compiled JS.

I would also advise publishing this as a single JS file, since that's all it really is it doesn't make a lot of sense to publish it as a Ruby gem. Still, I've changed things just enough so that the gem contains JS rather than CS.

@dhh
Copy link
Contributor

dhh commented Sep 26, 2012

It's packaged as a Rails gem to get all version control and dependency advantages of bundler. And since that's the case, it's imo fine to rely on coffee-script since that's part of the default stack. I'm happy with some integration vinegar for people opting out of those defaults.

The code is MIT, so if you want to maintain a JS-compiled, gem-free version, feel free.

On Sep 26, 2012, at 6:34 PM, James Coglan wrote:

To reduce users' dependency on the developer's toolchain, it helps to publish JavaScript functionality as JavaScipt, rather than as CoffeeScript. If and when CoffeeScript supports source maps, by all means bundle the source and the map with the compiled JS.

I would also advise publishing this as a single JS file, since that's all it really is it doesn't make a lot of sense to publish it as a Ruby gem. Still, I've changed things just enough so that the gem contains JS rather than CS.

You can merge this Pull Request by running:

git pull https://github.com/jcoglan/turbolinks publish-js
Or view, comment on, or merge it at:

#11

Commit Summary

• Compile the CoffeeScript source to JavaScript before packaging the gem.
File Changes

• A .gitignore (4)
• A Gemfile (3)
• A lib/assets/javascripts/turbolinks.coffee (0)
• M test/config.ru (1)
• M turbolinks.gemspec (6)
Patch Links

https://github.com/rails/turbolinks/pull/11.patch
https://github.com/rails/turbolinks/pull/11.diff

Reply to this email directly or view it on GitHub.

David Heinemeier Hansson

@dhh dhh closed this Sep 26, 2012
@jcoglan
Copy link
Author

jcoglan commented Sep 27, 2012

Seems like it would be plenty easy to develop this as a platform-agnostic JS project, which is what it is, and provide a gem for glueing it into Rails (which should not be necessary, but that's a different kettle of fish).

That way you still get to package it in a way that Bundler can understand, but the library is not locked up inside a Ruby project when JS users want to apply it to other environments. The 'vinegar' you mention only serves to harm reusability.

@jcoglan
Copy link
Author

jcoglan commented Sep 27, 2012

As a friend of mine has pointed out, the readme states that "Turbolinks is designed to be as light-weight as possible". Coupling the distribution of a single JavaScript file to a completely unrelated language runtime, web framework, compiler toolchain and package manager seems at odds with this statement.

@dhh
Copy link
Contributor

dhh commented Sep 27, 2012

Light-weight refers to the weight of the JavaScript itself. That it doesn't have any external dependencies and that it's not much code, so it's light enough to run even on low-powered mobile devices. It's not a statement about whether its wrapped in a gem or not.

I'd be happy to drop the gem-wrapping for this as soon as Rails gains the powers to have bundle-style vanilla-JS dependencies. Maybe through bower or something like that. But until that happens, this is how it's going to roll. It's not like it's exactly that hard for someone interested in using this outside of Rails to extract the 1 JS file and compile it.

@troyk
Copy link

troyk commented Apr 4, 2013

nope, not hard at all, just one more setup step before being able to get shit done. In case anyone happens to come across this because turbolinks.js.coffee errors it's probably because you need to add coffee-rails directly to your Gemfile if your running a threaded server, otherwise you'll run into WARN: tilt autoloading 'coffee_script' in a non thread-safe way; explicit require 'coffee_script' suggested.

However, bitching aside, thank you for Turbolinks! I just put it in and it is very cool!

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

Successfully merging this pull request may close these issues.

3 participants