uglifier 2.2.1 → 2.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 93cb2441ef4a95a1bb409fa2d9c47acf7e18117a
4
+ data.tar.gz: 6e6265967cb909387d5e621262a84246f49b44a2
5
+ SHA512:
6
+ metadata.gz: c2524b95360adb6557e70e2a6354b6d969ed04a8981374187b27a4930c5d04885d112d4e70891baf5d7c6279652aac890772dac6c8972290ffb3a62cf8838631
7
+ data.tar.gz: ada6b5d1036f83ef1a236a62056b49947c9c583deb5c81fc66ac38b656eac367f25abc2f964ed05b492313d235603b4b789d21c761f97504fcefe3f9e613a5f4
data/.gitignore ADDED
@@ -0,0 +1,44 @@
1
+ # rcov generated
2
+ coverage
3
+
4
+ # rdoc generated
5
+ rdoc
6
+
7
+ # yard generated
8
+ doc
9
+ .yardoc
10
+
11
+ # bundler
12
+ .bundle
13
+ Gemfile.lock
14
+ gemfiles/*.lock
15
+
16
+ # jeweler generated
17
+ pkg
18
+
19
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
20
+ #
21
+ # * Create a file at ~/.gitignore
22
+ # * Include files you want ignored
23
+ # * Run: git config --global core.excludesfile ~/.gitignore
24
+ #
25
+ # After doing this, these files will be ignored in all your git projects,
26
+ # saving you from having to 'pollute' every project you touch with them
27
+ #
28
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
29
+ #
30
+ # For MacOS:
31
+ #
32
+ #.DS_Store
33
+ #
34
+ # For TextMate
35
+ #*.tmproj
36
+ #tmtags
37
+ #
38
+ # For emacs:
39
+ #*~
40
+ #\#*
41
+ #.\#*
42
+ #
43
+ # For vim:
44
+ #*.swp
data/.rubocop.yml ADDED
@@ -0,0 +1,27 @@
1
+ AllCops:
2
+ Exclude:
3
+ - uglifier.gemspec
4
+ - lib/uglifier/version.rb
5
+ - "vendor/**/*"
6
+ - "gemfiles/vendor/**/*"
7
+
8
+ Metrics/ClassLength:
9
+ Enabled: false
10
+
11
+ Metrics/LineLength:
12
+ Max: 100
13
+
14
+ Metrics/MethodLength:
15
+ Max: 20
16
+
17
+ Style/DeprecatedHashMethods:
18
+ Enabled: false
19
+
20
+ Style/HashSyntax:
21
+ EnforcedStyle: hash_rockets
22
+
23
+ Style/SignalException:
24
+ Enabled: false
25
+
26
+ Style/StringLiterals:
27
+ Enabled: false
data/.travis.yml CHANGED
@@ -1,22 +1,30 @@
1
+ sudo: false
1
2
  language: ruby
3
+ cache: bundler
2
4
  rvm:
3
5
  - 1.8.7
4
- - 1.9.2
5
6
  - 1.9.3
6
7
  - 2.0.0
7
- - jruby-18mode
8
- env:
9
- - EXECJS_RUNTIME=RubyRacer
10
- - EXECJS_RUNTIME=RubyRhino
8
+ - 2.1.5
9
+ - 2.2.0
10
+ - jruby
11
+ - rbx-2
12
+ git:
13
+ submodules: false
14
+ gemfile:
15
+ - Gemfile
11
16
  matrix:
12
- exclude:
13
- - rvm: 1.8.7
14
- env: EXECJS_RUNTIME=RubyRhino
15
- - rvm: 1.9.2
16
- env: EXECJS_RUNTIME=RubyRhino
17
- - rvm: 1.9.3
18
- env: EXECJS_RUNTIME=RubyRhino
19
- - rvm: 2.0.0
20
- env: EXECJS_RUNTIME=RubyRhino
21
- - rvm: jruby-18mode
22
- env: EXECJS_RUNTIME=RubyRacer
17
+ include:
18
+ - rvm: 2.2.0
19
+ gemfile: gemfiles/rubyracer
20
+ - rvm: 2.1.5
21
+ gemfile: gemfiles/rubyracer
22
+ - rvm: jruby-19mode
23
+ gemfile: gemfiles/rubyrhino
24
+ - rvm: 2.2.0
25
+ gemfile: gemfiles/alaska
26
+ env: ALASKA=1
27
+ allow_failures:
28
+ - rvm: 2.2.0
29
+ gemfile: gemfiles/alaska
30
+ env: ALASKA=1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,66 @@
1
+ ## 2.7.2 (26 August 2015)
2
+
3
+ - update UglifyJS to 2.4.24
4
+
5
+ ## 2.7.1 (27 February 2015)
6
+
7
+ - fix compatibility with experimental Alaska ExecJS runtime
8
+
9
+ ## 2.7.0 (8 January 2015)
10
+
11
+ - copyright comment preservation also includes comments starting with a bang (!)
12
+
13
+ ## 2.6.1 (1 January 2015)
14
+
15
+ - update UglifyJS to 2.4.16
16
+
17
+ ## 2.6.0 (8 December 2014)
18
+
19
+ - allow metadata to be appended to minified code
20
+
21
+ ## 2.5.3 (18 July 2014)
22
+
23
+ - no changes
24
+
25
+ ## 2.5.2 (18 July 2014)
26
+
27
+ - update UglifyJS to 2.4.15
28
+
29
+ ## 2.5.1 (13 June 2014)
30
+
31
+ - update UglifyJS to 2.4.14
32
+
33
+ ## 2.5.0 (15 March 2014)
34
+
35
+ - update UglifyJS to 2.4.13
36
+ - process Angular @ngInject annotations
37
+ - add keep_fargs option
38
+ - change `ascii_only` default to true
39
+
40
+ ## 2.4.0 (19 December 2013)
41
+
42
+ - update UglifyJS to 2.4.8
43
+ - add drop_console compress option
44
+
45
+ ## 2.3.3 (12 December 2013)
46
+
47
+ - update UglifyJS to 2.4.7
48
+
49
+ ## 2.3.2 (1 December 2013)
50
+
51
+ - update UglifyJS to 2.4.6
52
+ - document missing mangler and output options
53
+
54
+ ## 2.3.1 (8 November 2013)
55
+
56
+ - update UglifyJS to 2.4.3
57
+
58
+ ## 2.3.0 (26 October 2013)
59
+
60
+ - use JSON gem instead of multi_json
61
+ - update UglifyJS to 2.4.1
62
+ - fix issues with some Unicode JS identifiers (#47, #58)
63
+
1
64
  ## 2.2.1 (28 August 2013)
2
65
 
3
66
  - fix IE8 compatibility
data/CONTRIBUTING.md CHANGED
@@ -1,17 +1,42 @@
1
1
  # Contributing to Uglifier
2
2
 
3
- Any contributions to Uglifier are welcome, whether they are feedback, bug reports, or - even better - pull requests.
3
+ Any contributions to Uglifier are welcome, whether they are feedback, bug reports, or - even better - pull requests.
4
4
 
5
- ## Reporting issues
5
+ ## Development
6
+
7
+ To start working on Uglifier, fork the repo to your own account. [Ruby](https://www.ruby-lang.org), [bundler](http://bundler.io) and [Node.js](http://nodejs.org) are required as dependencies.
8
+
9
+ Ensure that your local copy is up-to-date before you start working on a feature or a bug fix. You should write any new code in a topic branch.
10
+
11
+ ### Tests
12
+
13
+ Try to write a test case that reproduces the problem you're trying to fix or describes a feature that you want to build. Tests are located in `spec/` directory.
14
+
15
+ Tests as a pull request are appreciated even without a fix to highlight or reproduce a problem.
16
+
17
+ To run tests, first install all project dependencies:
18
+
19
+ bundle install
20
+
21
+ Then run tests using rake:
6
22
 
7
- Uglifier uses the [GitHub issue tracker](https://github.com/lautis/uglifier/issues) to track bugs and features. Before submitting a bug report or feature request, check to make sure it hasn't already been submitted. You can indicate support for an existing issuse by voting it up. When submitting a bug report, please include a Gist that includes a stack trace and any details that may be necessary to reproduce the bug, including your gem version, Ruby version, **MultiJSON engine** and **ExecJS runtime**. Ideally, a bug report should include a pull request with failing specs.
23
+ bundle exec rake
8
24
 
9
- ## Contributing to uglifier
25
+ ### Updating UglifyJS and source-map
26
+
27
+ [UglifyJS](https://github.com/mishoo/UglifyJS2) and [source-map](https://github.com/mozilla/source-map/) are included in the project as Git submodules. To install submodules, run in your terminal
28
+
29
+ git submodule update --init
30
+
31
+ After that, UglifyJS and source-map are checked out under `vendor/uglifyjs` and `vendor/source-map`.
32
+
33
+ Use Git commands (e.g. git checkout master) to change the included version. You can even write custom code to yourself. After changing the dependencies, compile new version of the bundled JS file using
34
+
35
+ rake js
36
+
37
+ After this, the new JS is used in your development version.
38
+
39
+
40
+ ## Reporting issues
10
41
 
11
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
12
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
13
- * Fork the project
14
- * Start a feature/bugfix branch
15
- * Commit and push until you are happy with your contribution
16
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
17
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
42
+ Uglifier uses the [GitHub issue tracker](https://github.com/lautis/uglifier/issues) to track bugs and features. Before submitting a bug report or feature request, check to make sure it hasn't already been submitted. When submitting a bug report, please include a Gist that includes a stack trace and any details that may be necessary to reproduce the bug, including your gem version, Ruby version, and **ExecJS runtime**. Ideally, a bug report should include a pull request with failing specs.
data/Gemfile CHANGED
@@ -1,26 +1,9 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "execjs", ">=0.3.0"
4
- gem "multi_json", "~> 1.0", ">= 1.0.2"
3
+ gemspec
5
4
 
6
- # Depend on defined ExecJS runtime
7
- execjs_runtimes = {
8
- "RubyRacer" => "therubyracer",
9
- "RubyRhino" => "therubyrhino",
10
- "Mustang" => "mustang"
11
- }
12
-
13
- if ENV["EXECJS_RUNTIME"] && execjs_runtimes[ENV["EXECJS_RUNTIME"]]
14
- gem execjs_runtimes[ENV["EXECJS_RUNTIME"]], :group => :development
15
- end
16
-
17
- # Engine
18
- gem ENV["MULTI_JSON_ENGINE"], :group => :development if ENV["MULTI_JSON_ENGINE"]
19
-
20
- group :development do
21
- gem "rspec", "~> 2.7"
22
- gem "bundler", "~> 1.0"
23
- gem "jeweler", "~> 1.8.3"
24
- gem "rdoc", ">= 3.11"
25
- gem "source_map"
5
+ if RUBY_VERSION >= '1.9'
6
+ gem 'rubocop', '~> 0.28.0', :group => [:development]
7
+ else
8
+ gem 'execjs', '~> 2.0.2'
26
9
  end
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Uglifier [![Build Status](https://secure.travis-ci.org/lautis/uglifier.png?branch=master)](http://travis-ci.org/lautis/uglifier) [![Dependency Status](https://gemnasium.com/lautis/uglifier.png?travis)](https://gemnasium.com/lautis/uglifier)
1
+ # Uglifier [![Build Status](https://travis-ci.org/lautis/uglifier.svg?branch=master)](https://travis-ci.org/lautis/uglifier) [![Dependency Status](https://gemnasium.com/lautis/uglifier.svg)](https://gemnasium.com/lautis/uglifier)
2
2
 
3
3
  Ruby wrapper for [UglifyJS](https://github.com/mishoo/UglifyJS2) JavaScript compressor.
4
4
 
@@ -44,8 +44,8 @@ Available options and their defaults are
44
44
  ```ruby
45
45
  {
46
46
  :output => {
47
- :ascii_only => false, # Escape non-ASCII characters
48
- :comments => :copyright, # Preserve comments (:all, :jsdoc, :copyright, :none)
47
+ :ascii_only => true, # Escape non-ASCII characters
48
+ :comments => :copyright, # Preserve comments (:all, :jsdoc, :copyright, :none, Regexp (see below))
49
49
  :inline_script => false, # Escape occurrences of </script in strings
50
50
  :quote_keys => false, # Quote keys in object literals
51
51
  :max_line_len => 32 * 1024, # Maximum line length in minified code
@@ -56,10 +56,14 @@ Available options and their defaults are
56
56
  :indent_level => 4, # Indent level in spaces
57
57
  :indent_start => 0, # Starting indent level
58
58
  :space_colon => false, # Insert space before colons (only with beautifier)
59
- :width => 80 # Specify line width when beautifier is used (only with beautifier)
59
+ :width => 80, # Specify line width when beautifier is used (only with beautifier)
60
+ :preamble => nil # Preamble for the generated JS file. Can be used to insert any code or comment.
60
61
  },
61
62
  :mangle => {
62
- :except => ["$super"] # Argument names to be excluded from mangling
63
+ :eval => false, # Mangle names when eval of when is used in scope
64
+ :except => ["$super"], # Argument names to be excluded from mangling
65
+ :sort => false, # Assign shorter names to most frequently used variables. Often results in bigger output after gzip.
66
+ :toplevel => false # Mangle names declared in the toplevel scope
63
67
  }, # Mangle variable and function names, set to false to skip mangling
64
68
  :compress => {
65
69
  :sequences => true, # Allow statements to be joined by commas
@@ -71,13 +75,19 @@ Available options and their defaults are
71
75
  :comparisons => true, # Apply binary node optimizations for comparisons
72
76
  :evaluate => true, # Attempt to evaluate constant expressions
73
77
  :booleans => true, # Various optimizations to boolean contexts
74
- :loops => true, # Optimize lops when condition can be statically determined
78
+ :loops => true, # Optimize loops when condition can be statically determined
75
79
  :unused => true, # Drop unreferenced functions and variables
76
80
  :hoist_funs => true, # Hoist function declarations
77
81
  :hoist_vars => false, # Hoist var declarations
78
82
  :if_return => true, # Optimizations for if/return and if/continue
79
83
  :join_vars => true, # Join consecutive var statements
80
- :cascade => true # Cascade sequences
84
+ :cascade => true, # Cascade sequences
85
+ :negate_iife => true, # Negate immediately invoked function expressions to avoid extra parens
86
+ :pure_getters => false, # Assume that object property access does not have any side-effects
87
+ :pure_funcs => nil, # List of functions without side-effects. Can safely discard function calls when the result value is not used
88
+ :drop_console => false, # Drop calls to console.* functions
89
+ :angular => false # Process @ngInject annotations
90
+ :keep_fargs => false # Preserve unused function arguments
81
91
  }, # Apply transformations to code, set to false to skip
82
92
  :define => {}, # Define values for symbol replacement
83
93
  :enclose => false, # Enclose in output function wrapper, define replacements as key-value pairs
@@ -85,15 +95,31 @@ Available options and their defaults are
85
95
  :source_root => nil, # The URL of the directory which contains :source_filename
86
96
  :output_filename => nil, # The filename or URL where the minified output can be found
87
97
  :input_source_map => nil, # The contents of the source map describing the input
88
- :screw_ie8 => false # Generate safe code for IE8
98
+ :screw_ie8 => false, # Don't bother to generate safe code for IE8
99
+ :source_map_url => false, # Url for source mapping to be appended in minified source
100
+ :source_url => false # Url to original source to be appended in minified source
89
101
  }
90
102
  ```
91
103
 
104
+ When passing a regular expression to the output => comments option, be sure to pass a valid Ruby Regexp.
105
+ The beginning and ending of comments are removed and cannot be matched (/*, */, //). For example:
106
+ When matching
107
+
108
+ ```
109
+ /*!
110
+ * comment
111
+ */
112
+ ```
113
+
114
+ use `Uglifier.new(output: {comments: /^!/})`.
115
+
92
116
  ## Development
93
117
 
94
- Uglifier bundles its javascript dependencies using git submodules. If you want to rebuild the javascript you will first need to get the latest version of the code with `git submodule update --init`. After you have the git submodules at the desired versions, run `rake js` to recreate `lib/uglify.js`.
118
+ Tests are run using
119
+
120
+ bundle exec rake
95
121
 
96
- See [CONTRIBUTING](https://github.com/lautis/uglifier/blob/master/CONTRIBUTING.md) for details about contributing to Uglifier.
122
+ See [CONTRIBUTING](https://github.com/lautis/uglifier/blob/master/CONTRIBUTING.md) for details about working on and contributing to Uglifier.
97
123
 
98
124
  ## Copyright
99
125
 
data/Rakefile CHANGED
@@ -1,5 +1,9 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'rubygems'
2
4
  require 'bundler'
5
+ require 'bundler/gem_tasks'
6
+
3
7
  begin
4
8
  Bundler.setup(:default, :development)
5
9
  rescue Bundler::BundlerError => e
@@ -7,19 +11,8 @@ rescue Bundler::BundlerError => e
7
11
  $stderr.puts "Run `bundle install` to install missing gems"
8
12
  exit e.status_code
9
13
  end
10
- require 'rake'
11
14
 
12
- require 'jeweler'
13
- Jeweler::Tasks.new do |gem|
14
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
- gem.name = "uglifier"
16
- gem.summary = %Q{Ruby wrapper for UglifyJS JavaScript compressor}
17
- gem.email = "lautis@gmail.com"
18
- gem.homepage = "http://github.com/lautis/uglifier"
19
- gem.authors = ["Ville Lautanala"]
20
- gem.license = "MIT"
21
- end
22
- Jeweler::RubygemsDotOrgTasks.new
15
+ require 'rake'
23
16
 
24
17
  require 'rspec/core'
25
18
  require 'rspec/core/rake_task'
@@ -27,8 +20,6 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
27
20
  spec.pattern = FileList['spec/**/*_spec.rb']
28
21
  end
29
22
 
30
- task :default => :spec
31
-
32
23
  require 'rdoc/task'
33
24
  Rake::RDocTask.new do |rdoc|
34
25
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
@@ -41,7 +32,6 @@ end
41
32
 
42
33
  desc "Rebuild lib/uglify.js"
43
34
  task :js do
44
-
45
35
  cd 'vendor/source-map/' do
46
36
  `npm install`
47
37
  `node Makefile.dryice.js`
@@ -60,3 +50,11 @@ task :js do
60
50
 
61
51
  File.write("lib/uglify.js", source)
62
52
  end
53
+
54
+ begin
55
+ require 'rubocop/rake_task'
56
+ RuboCop::RakeTask.new(:rubocop)
57
+ task :default => [:spec]
58
+ rescue LoadError
59
+ task :default => [:spec]
60
+ end
data/gemfiles/alaska ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec :path=> "../"
4
+ gem "alaska", github: "mavenlink/alaska"
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec :path=> "../"
4
+ gem 'therubyracer'
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec :path => "../"
4
+ gem 'therubyrhino'
data/lib/es5.js CHANGED
@@ -307,7 +307,7 @@ if(!String.prototype.trim) {
307
307
  function definePropertyWorks() {
308
308
  try {
309
309
  Object.defineProperty({}, "property", {});
310
- return "property" in object;
310
+ return true;
311
311
  } catch (exception) {
312
312
  return false;
313
313
  }
@@ -0,0 +1,4 @@
1
+ class Uglifier
2
+ # Current version of Uglifier.
3
+ VERSION = "2.7.2"
4
+ end