uglifier 2.7.0 → 2.7.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of uglifier might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +4 -0
- data/gemfiles/alaska +4 -0
- data/lib/uglifier.rb +52 -53
- data/lib/uglifier/version.rb +1 -1
- data/spec/spec_helper.rb +6 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7062a8c1bbde4ac1923e93201a527af14f1e3cea
|
4
|
+
data.tar.gz: dc3085b345acd4c4f6e7a71cc26f8ad708e89d0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46541d24080d33015418644c447949a7d7ca996d714640518b98d34d8f5cd50d47de18d33d7161be0e61224ac61fd49d8526a4c745ad49efa4e9ad6ff54879a3
|
7
|
+
data.tar.gz: 5c97052928028f300a8c6a5b9163bfb75b807dc6eef86b92e1a0689224eae93d76ded790fd0861d23c41db777a05d8ef819ba35572d5d5cd2299ffba7cd147f8
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/gemfiles/alaska
ADDED
data/lib/uglifier.rb
CHANGED
@@ -10,67 +10,68 @@ class Uglifier
|
|
10
10
|
Error = ExecJS::Error
|
11
11
|
# JavaScript code to call UglifyJS
|
12
12
|
JS = <<-JS
|
13
|
-
function
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
13
|
+
(function(options) {
|
14
|
+
function comments(option) {
|
15
|
+
if (Object.prototype.toString.call(option) === '[object Array]') {
|
16
|
+
return new RegExp(option[0], option[1]);
|
17
|
+
} else if (option == "jsdoc") {
|
18
|
+
return function(node, comment) {
|
19
|
+
if (comment.type == "comment2") {
|
20
|
+
return /@preserve|@license|@cc_on/i.test(comment.value);
|
21
|
+
} else {
|
22
|
+
return false;
|
23
|
+
}
|
22
24
|
}
|
25
|
+
} else {
|
26
|
+
return option;
|
23
27
|
}
|
24
|
-
} else {
|
25
|
-
return option;
|
26
28
|
}
|
27
|
-
}
|
28
|
-
|
29
|
-
var options = %s;
|
30
|
-
var source = options.source;
|
31
|
-
var ast = UglifyJS.parse(source, options.parse_options);
|
32
|
-
ast.figure_out_scope();
|
33
29
|
|
34
|
-
|
35
|
-
var
|
36
|
-
ast = ast.transform(compressor);
|
30
|
+
var source = options.source;
|
31
|
+
var ast = UglifyJS.parse(source, options.parse_options);
|
37
32
|
ast.figure_out_scope();
|
38
|
-
}
|
39
33
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
34
|
+
if (options.compress) {
|
35
|
+
var compressor = UglifyJS.Compressor(options.compress);
|
36
|
+
ast = ast.transform(compressor);
|
37
|
+
ast.figure_out_scope();
|
38
|
+
}
|
44
39
|
|
45
|
-
|
46
|
-
|
47
|
-
|
40
|
+
if (options.mangle) {
|
41
|
+
ast.compute_char_frequency();
|
42
|
+
ast.mangle_names(options.mangle);
|
43
|
+
}
|
48
44
|
|
49
|
-
|
50
|
-
|
45
|
+
if (options.enclose) {
|
46
|
+
ast = ast.wrap_enclose(options.enclose);
|
47
|
+
}
|
51
48
|
|
52
|
-
|
53
|
-
|
54
|
-
gen_code_options.source_map = source_map;
|
55
|
-
}
|
49
|
+
var gen_code_options = options.output;
|
50
|
+
gen_code_options.comments = comments(options.output.comments);
|
56
51
|
|
57
|
-
|
52
|
+
if (options.generate_map) {
|
53
|
+
var source_map = UglifyJS.SourceMap(options.source_map_options);
|
54
|
+
gen_code_options.source_map = source_map;
|
55
|
+
}
|
58
56
|
|
59
|
-
|
57
|
+
var stream = UglifyJS.OutputStream(gen_code_options);
|
60
58
|
|
61
|
-
|
62
|
-
stream += "\\n//# sourceMappingURL=" + options.source_map_options.map_url;
|
63
|
-
}
|
59
|
+
ast.print(stream);
|
64
60
|
|
65
|
-
|
66
|
-
|
67
|
-
|
61
|
+
if (options.source_map_options.map_url) {
|
62
|
+
stream += "\\n//# sourceMappingURL=" + options.source_map_options.map_url;
|
63
|
+
}
|
68
64
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
65
|
+
if (options.source_map_options.url) {
|
66
|
+
stream += "\\n//# sourceURL=" + options.source_map_options.url;
|
67
|
+
}
|
68
|
+
|
69
|
+
if (options.generate_map) {
|
70
|
+
return [stream.toString(), source_map.toString()];
|
71
|
+
} else {
|
72
|
+
return stream.toString();
|
73
|
+
}
|
74
|
+
})
|
74
75
|
JS
|
75
76
|
|
76
77
|
# UglifyJS source path
|
@@ -197,7 +198,7 @@ class Uglifier
|
|
197
198
|
|
198
199
|
# Run UglifyJS for given source code
|
199
200
|
def run_uglifyjs(source, generate_map)
|
200
|
-
|
201
|
+
options = {
|
201
202
|
:source => read_source(source),
|
202
203
|
:output => output_options,
|
203
204
|
:compress => compressor_options,
|
@@ -206,7 +207,9 @@ class Uglifier
|
|
206
207
|
:source_map_options => source_map_options,
|
207
208
|
:generate_map => generate_map,
|
208
209
|
:enclose => enclose_options
|
209
|
-
|
210
|
+
}
|
211
|
+
|
212
|
+
@context.call(Uglifier::JS, options)
|
210
213
|
end
|
211
214
|
|
212
215
|
def read_source(source)
|
@@ -296,10 +299,6 @@ class Uglifier
|
|
296
299
|
end
|
297
300
|
end
|
298
301
|
|
299
|
-
def json_encode(obj)
|
300
|
-
JSON.dump(obj)
|
301
|
-
end
|
302
|
-
|
303
302
|
def encode_regexp(regexp)
|
304
303
|
modifiers = if regexp.casefold?
|
305
304
|
"i"
|
data/lib/uglifier/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -7,6 +7,12 @@ require 'source_map'
|
|
7
7
|
# in ./support/ and its subdirectories.
|
8
8
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
9
9
|
|
10
|
+
if ENV["ALASKA"]
|
11
|
+
require 'alaska'
|
12
|
+
require 'tempfile'
|
13
|
+
ExecJS.runtime = Alaska::Runtime.new
|
14
|
+
end
|
15
|
+
|
10
16
|
RSpec.configure do |config|
|
11
17
|
config.mock_with :rspec do |mock|
|
12
18
|
mock.syntax = :expect
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uglifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.7.
|
4
|
+
version: 2.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ville Lautanala
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: execjs
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- LICENSE.txt
|
133
133
|
- README.md
|
134
134
|
- Rakefile
|
135
|
+
- gemfiles/alaska
|
135
136
|
- gemfiles/rubyracer
|
136
137
|
- gemfiles/rubyrhino
|
137
138
|
- lib/es5.js
|