Code Monkey home page Code Monkey logo

Comments (14)

lautis avatar lautis commented on May 25, 2024

I hope this will be eventually addressed by either therubyracer or Heroku. In the meantime, the gemspec could be fixed by either removing dependency on therubyracer as suggested or by creating a separate version for Heroku compatibility. I'll look at this issue.

Supporting other JS runtimes doesn't sound very pleasant. The main reason for existence of this gem was to avoid bugging our sysadmin to get node.js installed. therubyrhino would be nice to have though, as it'd allow minifying JS on jruby.

from uglifier.

yfeldblum avatar yfeldblum commented on May 25, 2024

The uglifier project can support just one (therubyracer) or two (therubyrhino) JS runtimes. The example was of abstracting out the implementation detail of the choice of runtime so that you just need to define another class to correspond to another runtime and the rest of the project will just work. If I need another runtime in my project (eg suppose I have Node.js installed but I cannot use therubyracer), I can use simply define that class in my own project and uglifier will hook in and use it. In all cases, though, uglifier shouldn't have a gemspec dependency on any one implementation - it should simply detect which implementations are available (including a class I define in my own project) and go from there.

from uglifier.

yfeldblum avatar yfeldblum commented on May 25, 2024

There's a pull request on jammit to add uglifier as a JS compressor.

My concern is that merging the pull request into jammit should be delayed until uglifier removes the explicit .gemspec dependency on therubyracer and all other JavaScript runtimes (the gems could still be required and used, so long as they are not in the gemspec dependencies list). This is because if the pull request were merged in now, then projects using jammit master could no longer be deployed to Heroku because therubyracer does not compile on Heroku.

from uglifier.

lautis avatar lautis commented on May 25, 2024

Uglifier 0.4.0 seems to work with Heroku. Dependency on therubyracer is now conditional, if therubyracer-heroku is installed, it is used.

If there is working implementation with some other JS interpreter than therubyracer, this dependency could be removed.

from uglifier.

yfeldblum avatar yfeldblum commented on May 25, 2024

I tried pushing again to Heroku, but no go.

Part of my Gemfile:

gem 'therubyracer', '0.8.1.pre2', :group => [:development, :test]
gem 'therubyracer-heroku', '0.8.1.pre3', :group => :production
gem 'jammit'
gem 'uglifier'

I am building my Gemfile.lock on a box in the development environment, which means:

GEM
  remote: http://rubygems.org/
  specs:
    #...
    therubyracer (0.8.1.pre2)
    therubyracer-heroku (0.8.1.pre3)
    uglifier (0.4.0)
      therubyracer (~> 0.8.0)

So even when I have

$ heroku config:add BUNDLE_WITHOUT="development:test"

Bundler is still forced to try to install therubyracer because the Gemfile.lock says uglifier explicitly depends on therubyracer.

I would also recommend against conditional dependencies in the .gemspec:

Gem::Specification.new do |s|
  if Gem.available?("therubyracer-heroku")
    s.add_runtime_dependency(%q<therubyracer-heroku>, ["~> 0.8.0"])
  else
    s.add_runtime_dependency(%q<therubyracer>, ["~> 0.8.0"])
  end
end

The best strategy is still to remove therubyracer from the .gemspec and add it as a note to the documentation (and as a check when the gem loads).

Cheers!

from uglifier.

lautis avatar lautis commented on May 25, 2024

Conditional dependencies are not ideal, but then again neither is need to add dependencies manually.

therubyracer-heroku can be used also on your local development machine.

from uglifier.

yfeldblum avatar yfeldblum commented on May 25, 2024

You can use the execjs gem (https://github.com/sstephenson/execjs | https://rubygems.org/gems/execjs) to run JavaScript from Ruby. Uglifier doesn't need to maintain any adapters of its own - ExecJS contains all the adapters. It knows about various JavaScript runtimes (including TheRubyRacer and TheRubyRhino) and will automatically select the best available runtime to run whatever JavaScript you throw at it.

from uglifier.

jashkenas avatar jashkenas commented on May 25, 2024

+1 for using execjs.

from uglifier.

jimmycuadra avatar jimmycuadra commented on May 25, 2024

+1 for execjs as well. I'm really wanting uglifier + Jammit + Heroku to play nice with each other: documentcloud/jammit#130

from uglifier.

rubiii avatar rubiii commented on May 25, 2024

+1 for execjs. seriously!

from uglifier.

heikki avatar heikki commented on May 25, 2024

+1 for execjs if it solves the issues with Jammit + Heroku cleanly.

from uglifier.

lautis avatar lautis commented on May 25, 2024

Uglifier with ExecJS has been released, kudos to @josh.

Heroku should work with therubyracer-heroku gem. Your Gemfile would have the following lines:

gem "therubyracer-heroku", "~>0.8.0"
gem "uglifier", "~>0.5.0"

from uglifier.

rubiii avatar rubiii commented on May 25, 2024

awesome. thank you so much!

from uglifier.

yfeldblum avatar yfeldblum commented on May 25, 2024

Uglifier now installs on Heroku, thanks for fixing it!

from uglifier.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.