Coder Social home page Coder Social logo

closure-compiler's Introduction

This is the repository for the legacy DocumentCloud site, please see the current repository here:

https://github.com/muckrock/documentcloud

______                                      _   _____ _                 _
|  _  \                                    | | /  __ \ |               | |
| | | |___   ___ _   _ _ __ ___   ___ _ __ | |_| /  \/ | ___  _   _  __| |
| | | / _ \ / __| | | | '_ ` _ \ / _ \ '_ \| __| |   | |/ _ \| | | |/ _` |
| |/ / (_) | (__| |_| | | | | | |  __/ | | | |_| \__/\ | (_) | |_| | (_| |
|___/ \___/ \___|\__,_|_| |_| |_|\___|_| |_|\__|\____/_|\___/ \__,_|\__,_|

DocumentCloud is a catalog of primary source documents and a tool for annotating, organizing and publishing them on the web. Documents are contributed by journalists, researchers and archivists.

This codebase contains the entirety of DocumentCloud.org, and pulls together the rest of our open-source projects: Docsplit is used to extract data from incoming documents; that work is parallelized across CloudCrowd; data on the client-side is modeled by Backbone.js, which depends on Underscore.js for all of its abilities; Jammit concatenates and compresses the dozens of CSS and JS files into a single asset package; the NYTimes' Document Viewer displays the documents, while Pixel Ping records the traffic.

If you find a security issue while browsing the source, please email [email protected] to inform us of the problem.

Code contributed to this project is provided under the MIT license (see the LICENSE file). Some components of the project are subject to their own licenses as indicated (see /vendor and /public/javascripts/vendor directories).

closure-compiler's People

Contributors

alubbe avatar alunny avatar atambo avatar cmbankester avatar codegoalie avatar ghazel avatar international avatar jashkenas avatar jdeff avatar josh avatar kares avatar knowtheory avatar lapluviosilla avatar reefdog avatar robotblake avatar rykov avatar xiazek avatar yurysolovyov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

closure-compiler's Issues

Tag the last release

Hi,

can you please tag the last release (1.1.10)? And update the README also. :)

Thanks!

Option to use system installed closure-compiler.jar

Hi,
Right now this closure-compiler gem package is using fixed version: closure-compiler.jar which is bundled inside of the package.
However I would like to use system installed closure-compiler.jar from this gem package.

I am using Fedora 23. And there is a closure-compiler package.

# rpm -qa | grep closure-compiler
closure-compiler-20141215-3.fc24.noarch

# rpm -ql closure-compiler
...
/usr/share/java/closure-compiler/closure-compiler.jar
...

For example one of the popular gem package: nokogiri has the option to use system installed library.

https://github.com/sparklemotion/nokogiri

In Nokogiri 1.6.0 and later libxml2 and libxslt are bundled with the gem, but if you want to use the system versions
at install time, set the environment variable NOKOGIRI_USE_SYSTEM_LIBRARIES or else use the --use-system-libraries argument. (

I would be happy if this kind of option for the closure-compiler was implemented.

How do you think?

Thanks.

Popen.popen returns nil

I was stumped by this exception when trying to compile a dynamic js string.

undefined method `success?' for nil:NilClass

Turns out it was status.success? failed at line 42 of compiler.rb. The status is nil. The compile process itself succeed. When I change the condition to !status || status.success?, the result shows up.

My setup is Windows 7, Ruby 1.8.7 and Rails 3. I am not familiar with commands and threads (shame). Is this a bug or just my own problem?

closure-compiler hangs on some javascript

I'm trying to compile a js blob (which is mostly already compressed, but ignore that) but compiler.compile(blob) never returns. It does work on most blobs, but not this particular one: http://codepad.org/Jwn3rPbM

The problem seems to happen on any platform. However! This problem is fun because:

  • running java directly and passing the file in with --js works
  • running java directly and piping the data it (cat blob | java ...) works

Here's the really fun bit:

  • closing stderr before trying to read from stdout works (but POpen4 crashes when it tries to rewind stderr)

This doesn't seem to be a POpen4 bug exactly, since the same behavior is true of Ruby's popen3, or even Python's subprocess.Popen!

1.1.14 breaks compatibility with Java 7

Upgrading from 1.1.13 to 1.1.14 broke our asset pipeline because we were running Java 7 (which is the version in default-jre in Ubuntu 14.04). Our stacktrace starts with:

Closure::Error: Exception in thread "main" java.lang.UnsupportedClassVersionError: com/google/javascript/jscomp/CommandLineRunner : Unsupported major.minor version 52.0

After doing a bit of digging it looks like the compiler is now getting built with a newer version of Java: https://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-versi

I believe the actual closure-compiler project switched to Java 8 towards the end of 2017: google/closure-compiler#2672.

Assuming this isn't just a silly mistake I'm making, I propose that 1.1.14 should be yanked (perhaps release 1.1.15 that just reverts back to 1.1.13 functionality) and a 2.0.0 should be released with the contents of 1.1.14.

nailgun usage

is there any interest in merging my fork https://github.com/lypanov/closure-compiler which provides nail gun integration?
using nailgun speeds up precompile by 3x locally. the patch is, well, hacky, but does the job, if you're interested i could polish it a bit if you wouldn't mind reviewing it for gunk.

Alex

popen4 include problem - still exists

The fix that was pushed still breaks on certain systems.

The POpen4.rb file is still called popen4.rb and fails to load with require 'POpen4'
I created a symlink popen4.rb -> POpen4.rb and it loads, so there is a case issue at work.

problem compressing -webkit-transform-origin

I noticed that that this gem compresses the following

-webkit-transform-origin: 0 0;

into

-webkit-transform-origin: 0;

Which affects the display of html in firefox/chrome. Is there a reason it is? This
but might belong @ google also, if so let me know.

Ignore JVM warnings

I'm trying to compile some assets with sprockets (I'm the current maintainer) and i'm getting warnings about _JAVA_OPTIONS being picked up in my compiled output:

  1) Failure:
TestClosureCompressor#test_compress_javascript [test/test_closure_compressor.rb:15]:
--- expected
+++ actual
@@ -1,2 +1,3 @@
-"function foo(){return!0};
+"Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m
+function foo(){return!0};
 "

Have you seen this before? Any idea how to disable or seperate out that warning from the compiled output?

popen4 include problem

irb(main):001:0> require 'closure-compiler'
LoadError: no such file to load -- C:/Ruby/lib/ruby/gems/1.8/gems/popen4-0.1.2/lib/open3
    from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from C:/Ruby/lib/ruby/gems/1.8/gems/popen4-0.1.2/lib/popen4.rb:10
    from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from C:/Ruby/lib/ruby/gems/1.8/gems/closure-compiler-0.1.7/lib/closure/compiler.rb:2
    from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from C:/Ruby/lib/ruby/gems/1.8/gems/closure-compiler-0.1.7/lib/closure-compiler.rb:1
    from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
    from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
    from (irb):1

S:>gem list popen

*** LOCAL GEMS ***

POpen4 (0.1.4)
popen4 (0.1.2)

This is easily fixed if I change the dependency that closure-compiler specifies to:
s.add_dependency 'POpen4', ['>= 0.1.4']

Deprication warning

I tried using the gem. It is failing while building.

      01 DEPRECATION WARNING: You are using the a deprecated processor interface Closure::Compiler.
      01 Please update your processor interface:
      01 https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors
      01  (called from js_compressor= at /datadrive/websites/staging/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.0/lib/sprockets/compressing.rb:71)
      01 DEPRECATION WARNING: You are using the a deprecated processor interface Closure::Compiler.
      01 Please update your processor interface:
      01 https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors
      01  (called from js_compressor= at /datadrive/websites/staging/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.0/lib/sprockets/compressing.rb:71)
      01 DEPRECATION WARNING: You are using the a deprecated processor interface Closure::Compiler.
      01 Please update your processor interface:
      01 https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors
      01  (called from js_compressor= at /datadrive/websites/I staging/shared/bundle/ruby/2.3.0/gems/sprockets-3.7.0/lib/sprockets/compressing.rb:71)
      01 rake aborted!

char ' breaks the compilation

the charachter ' (html entity: & rsquo;) causes the compilation process to abort.

"\xE2" from ASCII-8BIT to UTF-8
/path/to/gems/closure-compiler-0.3.3/lib/closure/compiler.rb:28:in `write'
/path/to/gems/closure-compiler-0.3.3/lib/closure/compiler.rb:28:in `block in compile'
/path/to/gems/closure-compiler-0.3.3/lib/closure/popen.rb:56:in `popen'
/path/to/gems/closure-compiler-0.3.3/lib/closure/compiler.rb:22:in `compile'

I've found this character in Modernizr:

https://github.com/Modernizr/Modernizr/blob/master/modernizr.js#L541

by simply replacing it with the usual ' solves the problem.

1.8.7 on Windows

I know, I know, I'm a glutton for punishment. But it seems like there's a problem getting closure compiler to work on Windows with ruby < 1.9. In your gemspec you don't list any dependencies, but in lib/closure/popen.rb you require 'win32/open3' if on windows with ruby < 1.9. I have to add some funky logic to my Gemfile to manually require this gem in order for things to work on windows.

Any change you can update the gemspec?

Upgrade to more recent closure version

Hello,

I'm using the closure-compiler gem in one of my projects, and it is choking on an error about super class properties. I believe this was fixed in the google/closure-compiler repo in their v20170626 release. Would it be possible to upgrade the gem to point to a more recent version of Closure?

Thanks!

0.3.0 doesn't work on windows

I get the following error:
fork() function is unimplemented on this machine

at:
closure-compiler-0.3.0/lib/closure/popen.rb:11:in `fork'

fork() is a linux only function. Not sure what the alternative is on windows.

Java heap space

I use closure-compiler for js compressor.
My config:

  config.assets.js_compressor = :closure
  require 'closure-compiler'
  config.assets.js_compressor = Closure::Compiler.new(
    compilation_level: 'ADVANCED_OPTIMIZATIONS',
    language_in: 'ECMASCRIPT6',
    language_out: 'ES5'
  )

And my deploy failed:

rake aborted!
Closure::Error: java.lang.OutOfMemoryError: Java heap space
	at java.util.Arrays.copyOfRange(Arrays.java:3664)
	at java.lang.String.<init>(String.java:207)
	at java.lang.StringBuilder.toString(StringBuilder.java:407)
	at com.google.javascript.jscomp.parsing.IRFactory.normalizeString(IRFactory.java:2782)
	at com.google.javascript.jscomp.parsing.IRFactory.access$2200(IRFactory.java:161)
	at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processString(IRFactory.java:1334)
	at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processStringLiteral(IRFactory.java:1639)
	at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processLiteralExpression(IRFactory.java:2432)
	at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process(IRFactory.java:2526)
	at com.google.javascript.jscomp.parsing.IRFactory.justTransform(IRFactory.java:893)
	at com.google.javascript.jscomp.parsing.IRFactory.transform(IRFactory.java:696)
	at com.google.javascript.jscomp.parsing.IRFactory.access$300(IRFactory.java:161)
	at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processFunctionCall(IRFactory.java:1141)
	at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process(IRFactory.java:2466)
	at com.google.javascript.jscomp.parsing.IRFactory.justTransform(IRFactory.java:893)
	at com.google.javascript.jscomp.parsing.IRFactory.transform(IRFactory.java:696)
	at com.google.javascript.jscomp.parsing.IRFactory.access$300(IRFactory.java:161)
	at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processExpressionStatement(IRFactory.java:1074)
	at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process(IRFactory.java:2480)
	at com.google.javascript.jscomp.parsing.IRFactory.justTransform(IRFactory.java:893)
	at com.google.javascript.jscomp.parsing.IRFactory.transform(IRFactory.java:696)
	at com.google.javascript.jscomp.parsing.IRFactory.access$300(IRFactory.java:161)
	at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processBlock(IRFactory.java:1017)
	at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process(IRFactory.java:2462)
	at com.google.javascript.jscomp.parsing.IRFactory.justTransform(IRFactory.java:893)
	at com.google.javascript.jscomp.parsing.IRFactory.transform(IRFactory.java:696)
	at com.google.javascript.jscomp.parsing.IRFactory.access$300(IRFactory.java:161)
	at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processFunction(IRFactory.java:1202)
	at com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.process(IRFactory.java:2490)
	at com.google.javascript.jscomp.parsing.IRFactory.justTransform(IRFactory.java:893)
	at com.google.javascript.jscomp.parsing.IRFactory.transform(IRFactory.java:696)
	at com.google.javascript.jscomp.parsing.IRFactory.access$300(IRFactory.java:161)

dcodeIO/ClosureCompiler.js#19
I know the problem, but I do not know how and where to add these parameters

Use std streams instead of Tempfile?

Basically it should be possible to just write something into stdin via echo:

> f = `echo "const foo = () => { return 4 };" | java -jar lib/closure-compiler-20170521.jar`
...
> f
 => "var foo=function(){return 4};\n"

Compiler fails to start when temporary path contains whitespace

Tested on Windows. When I run a build with TeamCity $TEMP a path that contains whitespace. TempFile.new copies the compiler jar over there and then tries to run it. That fails because the jarfile path needs escaping.

I don't know if my fix would work in Linux, for Windows at least we need to quote paths.

Perhaps the best way is to let Ruby do the escaping and rather use system *[command, '--js', tempfile.path], check the exit code, or use popen.

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.