Comments (14)
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.
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.
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 require
d 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.
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.
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.
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.
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.
+1 for using execjs.
from uglifier.
+1 for execjs as well. I'm really wanting uglifier + Jammit + Heroku to play nice with each other: documentcloud/jammit#130
from uglifier.
+1 for execjs. seriously!
from uglifier.
+1 for execjs if it solves the issues with Jammit + Heroku cleanly.
from uglifier.
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.
awesome. thank you so much!
from uglifier.
Uglifier now installs on Heroku, thanks for fixing it!
from uglifier.
Related Issues (20)
- Uglifier mangle properties has a start_with? undefined error on nil:NilClass HOT 1
- Example for harmony in readme is very dangerous HOT 4
- inlining dependencies HOT 2
- Jekyll configuration to use ES6
- Different versions between `VERSION` and published HOT 2
- Uglifier::Error: Unexpected token: name (package)
- Uglifier::Error: HOT 6
- Uglifier Cannot Precompile JS Optional Chaining HOT 3
- Uglifier runs into problems with certain combination of modern JS syntax (await, destructuring, Promise.all) HOT 1
- Uglifier complains about field declaration syntax HOT 1
- NoMethodError: undefined method `start_with?' for nil:NilClass HOT 1
- jekyll 3.8.7 | Error: Unexpected token: keyword (const). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true).
- Changing Uglifier.new parameters does nothing if I dont clean manually the assets files first HOT 2
- Documentation for :define => {} ?
- Custom replacements
- Uglifier::Error: - Solution: Switch to terser HOT 15
- Uglifier::Error: Unexpected token: punc (.) HOT 4
- Uglifier error in production mode on RoR 7.0.3.1 with Bootstrap 5.2 HOT 16
- Uglifier assets compiling error HOT 1
- XHTML style script tag within comment breaks parsing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uglifier.