uglifier 2.7.1 → 3.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +3 -0
- data/.rubocop.yml +20 -3
- data/.travis.yml +10 -11
- data/.yardopts +4 -0
- data/CHANGELOG.md +102 -0
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +1 -5
- data/README.md +35 -12
- data/Rakefile +6 -30
- data/lib/es5.js +1 -1
- data/lib/source-map.js +3055 -0
- data/lib/uglifier/version.rb +1 -1
- data/lib/uglifier.js +120 -0
- data/lib/uglifier.rb +161 -99
- data/lib/uglify.js +55 -1803
- data/uglifier.gemspec +8 -8
- metadata +20 -48
- data/gemfiles/alaska +0 -4
- data/gemfiles/rubyracer +0 -4
- data/gemfiles/rubyrhino +0 -4
- data/spec/source_map_spec.rb +0 -110
- data/spec/spec_helper.rb +0 -23
- data/spec/uglifier_spec.rb +0 -271
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e8310617674cbcf3ff30c2433d045ee6140c396
|
4
|
+
data.tar.gz: 92e074bb4be4948b9b6a25a9ef1ae57de99b46b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 762b0881f4d29a76664ac20dc615f00ee84d3ce87890e83808577bbd5c2bb3778ac18483f5c5ed5836446a821482b621290e95cc06b20faae24f257fb9d4eddd
|
7
|
+
data.tar.gz: ce9f17c6c0f2ef310394d98328babc50e4eb2886719336c5cad50c93d415cf6c1ee9c2a49476f052e54096851996dfd82ac027c24d772d2bde3e1e2fc360b6c0
|
data/.gitmodules
CHANGED
data/.rubocop.yml
CHANGED
@@ -5,6 +5,11 @@ AllCops:
|
|
5
5
|
- "vendor/**/*"
|
6
6
|
- "gemfiles/vendor/**/*"
|
7
7
|
|
8
|
+
Metrics/BlockLength:
|
9
|
+
Enabled: true
|
10
|
+
Exclude:
|
11
|
+
- "spec/**/*_spec.rb"
|
12
|
+
|
8
13
|
Metrics/ClassLength:
|
9
14
|
Enabled: false
|
10
15
|
|
@@ -14,14 +19,26 @@ Metrics/LineLength:
|
|
14
19
|
Metrics/MethodLength:
|
15
20
|
Max: 20
|
16
21
|
|
17
|
-
Style/DeprecatedHashMethods:
|
18
|
-
Enabled: false
|
19
|
-
|
20
22
|
Style/HashSyntax:
|
21
23
|
EnforcedStyle: hash_rockets
|
22
24
|
|
25
|
+
Style/PercentLiteralDelimiters:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
Style/PreferredHashMethods:
|
29
|
+
Enabled: false
|
30
|
+
|
23
31
|
Style/SignalException:
|
24
32
|
Enabled: false
|
25
33
|
|
26
34
|
Style/StringLiterals:
|
27
35
|
Enabled: false
|
36
|
+
|
37
|
+
Style/SymbolArray:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
Style/Alias:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
Style/MutableConstant:
|
44
|
+
Enabled: false
|
data/.travis.yml
CHANGED
@@ -2,29 +2,28 @@ sudo: false
|
|
2
2
|
language: ruby
|
3
3
|
cache: bundler
|
4
4
|
rvm:
|
5
|
-
- 1.8.7
|
6
5
|
- 1.9.3
|
7
6
|
- 2.0.0
|
8
|
-
- 2.1.
|
9
|
-
- 2.2.
|
10
|
-
-
|
11
|
-
-
|
7
|
+
- 2.1.10
|
8
|
+
- 2.2.6
|
9
|
+
- 2.3.3
|
10
|
+
- 2.4.1
|
11
|
+
- jruby-19mode
|
12
|
+
- jruby-9.1.8.0
|
12
13
|
git:
|
13
14
|
submodules: false
|
14
15
|
gemfile:
|
15
16
|
- Gemfile
|
16
17
|
matrix:
|
17
18
|
include:
|
18
|
-
- rvm: 2.
|
19
|
+
- rvm: 2.4.1
|
19
20
|
gemfile: gemfiles/rubyracer
|
20
|
-
- rvm:
|
21
|
-
gemfile: gemfiles/rubyracer
|
22
|
-
- rvm: jruby-19mode
|
21
|
+
- rvm: jruby-9.1.8.0
|
23
22
|
gemfile: gemfiles/rubyrhino
|
24
|
-
- rvm: 2.
|
23
|
+
- rvm: 2.4.1
|
25
24
|
gemfile: gemfiles/alaska
|
26
25
|
env: ALASKA=1
|
27
26
|
allow_failures:
|
28
|
-
- rvm: 2.
|
27
|
+
- rvm: 2.4.1
|
29
28
|
gemfile: gemfiles/alaska
|
30
29
|
env: ALASKA=1
|
data/.yardopts
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,105 @@
|
|
1
|
+
## 3.1.13 (3 April 2017)
|
2
|
+
|
3
|
+
- update UglifyJS to 2.8.21
|
4
|
+
|
5
|
+
## 3.1.12 (31 March 2017)
|
6
|
+
|
7
|
+
- update UglifyJS to 2.8.20
|
8
|
+
|
9
|
+
## 3.1.11 (28 March 2017)
|
10
|
+
|
11
|
+
- update UglifyJS to 2.8.17
|
12
|
+
|
13
|
+
## 3.1.10 (25 March 2017)
|
14
|
+
|
15
|
+
- update UglifyJS to 2.8.16
|
16
|
+
|
17
|
+
## 3.1.9 (19 March 2017)
|
18
|
+
|
19
|
+
- update UglifyJS to 2.8.14
|
20
|
+
|
21
|
+
## 3.1.8 (17 March 2017)
|
22
|
+
|
23
|
+
- update UglifyJS to 2.8.13
|
24
|
+
|
25
|
+
## 3.1.7 (11 March 2017)
|
26
|
+
|
27
|
+
- fix NoMethodError on `Uglifier.compile(source, source_map: false)` (#114)
|
28
|
+
- update UglifyJS to 2.8.12
|
29
|
+
|
30
|
+
## 3.1.6 (9 March 2017)
|
31
|
+
|
32
|
+
- update UglifyJS to 2.8.11
|
33
|
+
|
34
|
+
## 3.1.5 (8 March 2017)
|
35
|
+
|
36
|
+
- update UglifyJS to 2.8.9
|
37
|
+
|
38
|
+
## 3.1.4 (5 March 2017)
|
39
|
+
|
40
|
+
- Update UglifyJS to 2.8.7
|
41
|
+
|
42
|
+
## 3.1.3 (2 March 2017)
|
43
|
+
|
44
|
+
- update UglifyJS to 2.8.5
|
45
|
+
- default passes to 1
|
46
|
+
- allow source_map option to be `true` instead of a hash
|
47
|
+
|
48
|
+
## 3.1.2 (1 March 2017)
|
49
|
+
|
50
|
+
- fix `reduce_vars` compressor option
|
51
|
+
- add `passes` compressor option
|
52
|
+
- update UglifyJS to 2.8.4
|
53
|
+
|
54
|
+
## 3.1.1 (27 February 2017)
|
55
|
+
|
56
|
+
- disable `reduce_vars` by default as it causes JS errors (#110)
|
57
|
+
|
58
|
+
## 3.1.0 (27 February 2017)
|
59
|
+
|
60
|
+
- update UglifyJS to 2.8.0
|
61
|
+
- add reduce_vars compress option
|
62
|
+
- enable `reduce_vars` and `collapse_vars` compress options by default
|
63
|
+
- unused top-level function and variable removal with `toplevel` compress option
|
64
|
+
- add `top_retain` compress option to specify list of top-level variables to always retain
|
65
|
+
- add `unsafe_comps` and `unsafe_proto` options
|
66
|
+
|
67
|
+
## 3.0.4 (30 November 2016)
|
68
|
+
|
69
|
+
- update UglifyJS to 2.7.5
|
70
|
+
- implement ignore_quoted and debug options for mangle_properties
|
71
|
+
|
72
|
+
## 3.0.3 (24 October 2016)
|
73
|
+
|
74
|
+
- update UglifyJS to 2.7.4
|
75
|
+
- add wrap_iife output option to wrap IIFEs in parenthesis
|
76
|
+
|
77
|
+
## 3.0.2 (20 August 2016)
|
78
|
+
|
79
|
+
- add top-level keep_fnames option that implies both compressor and mangler keep_fnames
|
80
|
+
- update UglifyJS to 2.7.3
|
81
|
+
|
82
|
+
## 3.0.1 (28 July 2016)
|
83
|
+
|
84
|
+
- update UglifyJS to 2.7.0
|
85
|
+
- split JS dependencies to separate files
|
86
|
+
|
87
|
+
## 3.0.0 (22 March 2016)
|
88
|
+
|
89
|
+
- drop support for Ruby 1.8
|
90
|
+
- remove json as dependency
|
91
|
+
- discard unused function arguments only in unsafe mode
|
92
|
+
- add `keep_fnames` option to preserve function names in compressed code
|
93
|
+
- add `collapse_vars` option to collapse single-use variables
|
94
|
+
- backwards incompatible changes to source map options
|
95
|
+
- support for inline base64 encoded source maps
|
96
|
+
- mangle property names option (disabled by default)
|
97
|
+
- update UglifyJS to 2.6.2
|
98
|
+
|
99
|
+
## 2.7.2 (26 August 2015)
|
100
|
+
|
101
|
+
- update UglifyJS to 2.4.24
|
102
|
+
|
1
103
|
## 2.7.1 (27 February 2015)
|
2
104
|
|
3
105
|
- fix compatibility with experimental Alaska ExecJS runtime
|
data/CONTRIBUTING.md
CHANGED
@@ -32,7 +32,7 @@ After that, UglifyJS and source-map are checked out under `vendor/uglifyjs` and
|
|
32
32
|
|
33
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
34
|
|
35
|
-
rake js
|
35
|
+
bundle exec rake js
|
36
36
|
|
37
37
|
After this, the new JS is used in your development version.
|
38
38
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
-
# Uglifier
|
1
|
+
# Uglifier
|
2
2
|
|
3
3
|
Ruby wrapper for [UglifyJS](https://github.com/mishoo/UglifyJS2) JavaScript compressor.
|
4
4
|
|
5
|
+
Uglifier is able to process ES5 JavaScript, with very limited support for ES6. Uglifier should be only applied to ES6 code after transpiling to ES5 (with e.g. [babel-transpiler](https://github.com/babel/ruby-babel-transpiler)). For directly minifying ES6 code, [Closure Compiler](https://github.com/documentcloud/closure-compiler) is a more suitable option.
|
6
|
+
|
7
|
+
[![Build Status](https://travis-ci.org/lautis/uglifier.svg?branch=master)](https://travis-ci.org/lautis/uglifier)
|
8
|
+
|
5
9
|
## Installation
|
6
10
|
|
7
11
|
Uglifier is available as a ruby gem.
|
@@ -57,47 +61,66 @@ Available options and their defaults are
|
|
57
61
|
:indent_start => 0, # Starting indent level
|
58
62
|
:space_colon => false, # Insert space before colons (only with beautifier)
|
59
63
|
:width => 80, # Specify line width when beautifier is used (only with beautifier)
|
60
|
-
:preamble => nil
|
64
|
+
:preamble => nil, # Preamble for the generated JS file. Can be used to insert any code or comment.
|
65
|
+
:wrap_iife => false # Wrap IIFEs in parenthesis. Note: this disables the negate_iife compression option.
|
61
66
|
},
|
62
67
|
:mangle => {
|
63
68
|
:eval => false, # Mangle names when eval of when is used in scope
|
64
69
|
:except => ["$super"], # Argument names to be excluded from mangling
|
65
70
|
:sort => false, # Assign shorter names to most frequently used variables. Often results in bigger output after gzip.
|
66
|
-
:toplevel => false
|
71
|
+
:toplevel => false, # Mangle names declared in the toplevel scope
|
72
|
+
:properties => false, # Mangle property names
|
73
|
+
:keep_fnames => false # Do not modify function names
|
67
74
|
}, # Mangle variable and function names, set to false to skip mangling
|
75
|
+
:mangle_properties => {
|
76
|
+
:regex => nil, # A regular expression to filter property names to be mangled
|
77
|
+
:ignore_quoted => false, # Only mangle unquoted property names
|
78
|
+
:debug => false, # Mangle names with the original name still present
|
79
|
+
} # Mangle property names, disabled by default
|
68
80
|
:compress => {
|
69
81
|
:sequences => true, # Allow statements to be joined by commas
|
70
82
|
:properties => true, # Rewrite property access using the dot notation
|
71
83
|
:dead_code => true, # Remove unreachable code
|
72
84
|
:drop_debugger => true, # Remove debugger; statements
|
73
85
|
:unsafe => false, # Apply "unsafe" transformations
|
86
|
+
:unsafe_comps => false, # Reverse < and <= to > and >= to allow improved compression. This might be unsafe when an at least one of two operands is an object with computed values due the use of methods like get, or valueOf. This could cause change in execution order after operands in the comparison are switching. Compression only works if both comparisons and unsafe_comps are both set to true.
|
87
|
+
:unsafe_proto => false, # Optimize expressions like Array.prototype.slice.call(a) into [].slice.call(a)
|
74
88
|
:conditionals => true, # Optimize for if-s and conditional expressions
|
75
89
|
:comparisons => true, # Apply binary node optimizations for comparisons
|
76
90
|
:evaluate => true, # Attempt to evaluate constant expressions
|
77
91
|
:booleans => true, # Various optimizations to boolean contexts
|
78
92
|
:loops => true, # Optimize loops when condition can be statically determined
|
79
93
|
:unused => true, # Drop unreferenced functions and variables
|
94
|
+
:toplevel => false, # Drop unreferenced top-level functions and variables
|
95
|
+
:top_retain => [], # prevent specific toplevel functions and variables from `unused` removal
|
80
96
|
:hoist_funs => true, # Hoist function declarations
|
81
97
|
:hoist_vars => false, # Hoist var declarations
|
82
98
|
:if_return => true, # Optimizations for if/return and if/continue
|
83
99
|
:join_vars => true, # Join consecutive var statements
|
84
100
|
:cascade => true, # Cascade sequences
|
101
|
+
:collapse_vars => false, # Collapse single-use var and const definitions when possible.
|
102
|
+
:reduce_vars => false, # Collapse variables assigned with and used as constant values.
|
85
103
|
:negate_iife => true, # Negate immediately invoked function expressions to avoid extra parens
|
86
104
|
:pure_getters => false, # Assume that object property access does not have any side-effects
|
87
105
|
:pure_funcs => nil, # List of functions without side-effects. Can safely discard function calls when the result value is not used
|
88
106
|
:drop_console => false, # Drop calls to console.* functions
|
89
|
-
:angular => false
|
90
|
-
:keep_fargs => false
|
107
|
+
:angular => false, # Process @ngInject annotations
|
108
|
+
:keep_fargs => false, # Preserve unused function arguments
|
109
|
+
:keep_fnames => false # Do not drop names in function definitions
|
110
|
+
:passes => 1 # Number of times to run compress. Raising the number of passes will increase compress time, but can produce slightly smaller code.
|
91
111
|
}, # Apply transformations to code, set to false to skip
|
92
112
|
:define => {}, # Define values for symbol replacement
|
93
113
|
:enclose => false, # Enclose in output function wrapper, define replacements as key-value pairs
|
94
|
-
:
|
95
|
-
:
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
114
|
+
:keep_fnames => false, # Generate code safe for the poor souls relying on Function.prototype.name at run-time. Sets both compress and mangle keep_fanems to true.
|
115
|
+
:source_map => {
|
116
|
+
:map_url => false, # Url for source mapping to be appended in minified source
|
117
|
+
:url => false, # Url for original source to be appended in minified source
|
118
|
+
:sources_content => false, # Include original source content in map
|
119
|
+
:filename => nil, # The filename of the input file
|
120
|
+
:root => nil, # The URL of the directory which contains :filename
|
121
|
+
:output_filename => nil, # The filename or URL where the minified output can be found
|
122
|
+
:input_source_map => nil # The contents of the source map describing the input
|
123
|
+
}
|
101
124
|
}
|
102
125
|
```
|
103
126
|
|
data/Rakefile
CHANGED
@@ -1,40 +1,16 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'bundler'
|
3
|
+
require 'fileutils'
|
5
4
|
require 'bundler/gem_tasks'
|
6
|
-
|
7
|
-
begin
|
8
|
-
Bundler.setup(:default, :development)
|
9
|
-
rescue Bundler::BundlerError => e
|
10
|
-
$stderr.puts e.message
|
11
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
12
|
-
exit e.status_code
|
13
|
-
end
|
14
|
-
|
15
|
-
require 'rake'
|
16
|
-
|
17
|
-
require 'rspec/core'
|
18
5
|
require 'rspec/core/rake_task'
|
19
6
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
20
7
|
spec.pattern = FileList['spec/**/*_spec.rb']
|
21
8
|
end
|
22
9
|
|
23
|
-
require 'rdoc/task'
|
24
|
-
Rake::RDocTask.new do |rdoc|
|
25
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
26
|
-
|
27
|
-
rdoc.rdoc_dir = 'rdoc'
|
28
|
-
rdoc.title = "uglifier #{version}"
|
29
|
-
rdoc.rdoc_files.include('README*')
|
30
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
31
|
-
end
|
32
|
-
|
33
10
|
desc "Rebuild lib/uglify.js"
|
34
11
|
task :js do
|
35
12
|
cd 'vendor/source-map/' do
|
36
13
|
`npm install`
|
37
|
-
`node Makefile.dryice.js`
|
38
14
|
end
|
39
15
|
|
40
16
|
cd 'vendor/uglifyjs/' do
|
@@ -42,13 +18,13 @@ task :js do
|
|
42
18
|
`npm install`
|
43
19
|
end
|
44
20
|
|
45
|
-
source
|
46
|
-
source << "window = this;"
|
47
|
-
source << File.read("vendor/source-map/dist/source-map.js")
|
48
|
-
source << "MOZ_SourceMap = sourceMap;"
|
49
|
-
source << `./vendor/uglifyjs/bin/uglifyjs --self --comments /Copyright/`
|
21
|
+
FileUtils.cp("vendor/source-map/dist/source-map.js", "lib/source-map.js")
|
50
22
|
|
23
|
+
source = `./vendor/uglifyjs/bin/uglifyjs --self --comments /Copyright/`
|
51
24
|
File.write("lib/uglify.js", source)
|
25
|
+
|
26
|
+
FileUtils.cp("vendor/split/split.js", "lib/split.js")
|
27
|
+
`patch -p1 -i patches/es5-string-split.patch`
|
52
28
|
end
|
53
29
|
|
54
30
|
begin
|