uglifier 2.2.1 → 2.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +44 -0
- data/.rubocop.yml +27 -0
- data/.travis.yml +24 -16
- data/CHANGELOG.md +63 -0
- data/CONTRIBUTING.md +36 -11
- data/Gemfile +5 -22
- data/README.md +36 -10
- data/Rakefile +13 -15
- data/gemfiles/alaska +4 -0
- data/gemfiles/rubyracer +4 -0
- data/gemfiles/rubyrhino +4 -0
- data/lib/es5.js +1 -1
- data/lib/uglifier/version.rb +4 -0
- data/lib/uglifier.rb +167 -136
- data/lib/uglify.js +599 -256
- data/spec/source_map_spec.rb +60 -36
- data/spec/spec_helper.rb +13 -2
- data/spec/uglifier_spec.rb +120 -63
- data/uglifier.gemspec +28 -68
- metadata +72 -85
- data/VERSION +0 -1
data/spec/source_map_spec.rb
CHANGED
@@ -3,18 +3,8 @@ require 'stringio'
|
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
4
4
|
|
5
5
|
describe "Uglifier" do
|
6
|
-
|
7
|
-
|
8
|
-
minified, map = Uglifier.new.compile_with_map(source)
|
9
|
-
minified.length.should < source.length
|
10
|
-
map.length.should > 0
|
11
|
-
lambda {
|
12
|
-
JSON.parse(map)
|
13
|
-
}.should_not raise_error
|
14
|
-
end
|
15
|
-
|
16
|
-
it "generates source maps with the correct meta-data" do
|
17
|
-
source = <<-JS
|
6
|
+
let(:source) do
|
7
|
+
<<-JS
|
18
8
|
function hello () {
|
19
9
|
function world () {
|
20
10
|
return 2;
|
@@ -23,18 +13,28 @@ describe "Uglifier" do
|
|
23
13
|
return world() + world();
|
24
14
|
};
|
25
15
|
JS
|
16
|
+
end
|
17
|
+
|
18
|
+
it "generates source maps" do
|
19
|
+
source = File.open("lib/uglify.js", "r:UTF-8").read
|
20
|
+
minified, map = Uglifier.new.compile_with_map(source)
|
21
|
+
expect(minified.length).to be < source.length
|
22
|
+
expect(map.length).to be > 0
|
23
|
+
expect { JSON.parse(map) }.not_to raise_error
|
24
|
+
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
it "generates source maps with the correct meta-data" do
|
27
|
+
_, map = Uglifier.compile_with_map(source,
|
28
|
+
:source_filename => "ahoy.js",
|
29
|
+
:output_filename => "ahoy.min.js",
|
30
|
+
:source_root => "http://localhost/")
|
31
31
|
|
32
32
|
map = SourceMap.from_s(map)
|
33
|
-
map.file.
|
34
|
-
map.sources.
|
35
|
-
map.names.
|
36
|
-
map.source_root.
|
37
|
-
map.mappings.first[:generated_line].
|
33
|
+
expect(map.file).to eq("ahoy.min.js")
|
34
|
+
expect(map.sources).to eq(["ahoy.js"])
|
35
|
+
expect(map.names).to eq(%w(hello world))
|
36
|
+
expect(map.source_root).to eq("http://localhost/")
|
37
|
+
expect(map.mappings.first[:generated_line]).to eq(1)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should skip copyright lines in source maps" do
|
@@ -49,11 +49,11 @@ describe "Uglifier" do
|
|
49
49
|
};
|
50
50
|
JS
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
_, map = Uglifier.compile_with_map(source,
|
53
|
+
:source_filename => "ahoy.js",
|
54
|
+
:source_root => "http://localhost/")
|
55
55
|
map = SourceMap.from_s(map)
|
56
|
-
map.mappings.first[:generated_line].
|
56
|
+
expect(map.mappings.first[:generated_line]).to eq(2)
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should be able to handle an input source map" do
|
@@ -67,20 +67,44 @@ describe "Uglifier" do
|
|
67
67
|
};
|
68
68
|
JS
|
69
69
|
|
70
|
-
minified1, map1 = Uglifier.compile_with_map(
|
71
|
-
|
72
|
-
|
73
|
-
|
70
|
+
minified1, map1 = Uglifier.compile_with_map(
|
71
|
+
source,
|
72
|
+
:source_filename => "ahoy.js",
|
73
|
+
:source_root => "http://localhost/",
|
74
|
+
:mangle => false
|
75
|
+
)
|
74
76
|
|
75
|
-
|
76
|
-
|
77
|
-
|
77
|
+
_, map2 = Uglifier.compile_with_map(source,
|
78
|
+
:input_source_map => map1,
|
79
|
+
:mangle => true)
|
78
80
|
|
79
|
-
minified1.lines.to_a.length.
|
81
|
+
expect(minified1.lines.to_a.length).to eq(1)
|
80
82
|
|
81
83
|
map = SourceMap.from_s(map2)
|
82
|
-
map.sources.
|
83
|
-
map.mappings.first[:source_line].
|
84
|
-
map.mappings.last[:source_line].
|
84
|
+
expect(map.sources).to eq(["ahoy.js", "http://localhost/ahoy.js"])
|
85
|
+
expect(map.mappings.first[:source_line]).to eq(1)
|
86
|
+
expect(map.mappings.last[:source_line]).to eq(6)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "appens source map url" do
|
90
|
+
minified, _ = Uglifier.compile_with_map(
|
91
|
+
source,
|
92
|
+
:source_filename => "ahoy.js",
|
93
|
+
:output_filename => "ahoy.min.js",
|
94
|
+
:source_root => "http://localhost/",
|
95
|
+
:source_map_url => "http://example.com/map"
|
96
|
+
)
|
97
|
+
expect(minified).to include("\n//# sourceMappingURL=http://example.com/map")
|
98
|
+
end
|
99
|
+
|
100
|
+
it "appens source url" do
|
101
|
+
minified, _ = Uglifier.compile_with_map(
|
102
|
+
source,
|
103
|
+
:source_filename => "ahoy.js",
|
104
|
+
:output_filename => "ahoy.min.js",
|
105
|
+
:source_root => "http://localhost/",
|
106
|
+
:source_url => "http://example.com/source"
|
107
|
+
)
|
108
|
+
expect(minified).to include("\n//# sourceURL=http://example.com/source")
|
85
109
|
end
|
86
110
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,8 +5,19 @@ require 'source_map'
|
|
5
5
|
|
6
6
|
# Requires supporting files with custom matchers and macros, etc,
|
7
7
|
# in ./support/ and its subdirectories.
|
8
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
9
|
+
|
10
|
+
if ENV["ALASKA"]
|
11
|
+
require 'alaska'
|
12
|
+
require 'tempfile'
|
13
|
+
ExecJS.runtime = Alaska::Runtime.new
|
14
|
+
end
|
9
15
|
|
10
16
|
RSpec.configure do |config|
|
11
|
-
|
17
|
+
config.mock_with :rspec do |mock|
|
18
|
+
mock.syntax = :expect
|
19
|
+
end
|
20
|
+
config.expect_with :rspec do |expect|
|
21
|
+
expect.syntax = :expect
|
22
|
+
end
|
12
23
|
end
|
data/spec/uglifier_spec.rb
CHANGED
@@ -6,93 +6,102 @@ describe "Uglifier" do
|
|
6
6
|
it "minifies JS" do
|
7
7
|
source = File.open("lib/uglify.js", "r:UTF-8").read
|
8
8
|
minified = Uglifier.new.compile(source)
|
9
|
-
minified.length.
|
10
|
-
|
11
|
-
Uglifier.new.compile(minified)
|
12
|
-
}.should_not raise_error
|
9
|
+
expect(minified.length).to be < source.length
|
10
|
+
expect { Uglifier.new.compile(minified) }.not_to raise_error
|
13
11
|
end
|
14
12
|
|
15
13
|
it "throws an exception when compilation fails" do
|
16
|
-
expect {
|
17
|
-
Uglifier.new.compile(")(")
|
18
|
-
}.to raise_error(Uglifier::Error)
|
14
|
+
expect { Uglifier.new.compile(")(") }.to raise_error(Uglifier::Error)
|
19
15
|
end
|
20
16
|
|
21
17
|
it "throws an exception on invalid option" do
|
22
|
-
expect {
|
23
|
-
Uglifier.new(:foo => true)
|
24
|
-
}.to raise_error(ArgumentError)
|
18
|
+
expect { Uglifier.new(:foo => true) }.to raise_error(ArgumentError)
|
25
19
|
end
|
26
20
|
|
27
21
|
it "doesn't omit null character in strings" do
|
28
|
-
Uglifier.new.compile('var foo="\0bar"').
|
22
|
+
expect(Uglifier.new.compile('var foo="\0bar"')).to include("\\x00bar")
|
29
23
|
end
|
30
24
|
|
31
25
|
it "adds trailing semicolon to minified source" do
|
32
26
|
source = "(function id(i) {return i;}());"
|
33
|
-
Uglifier.new.compile(source)[-1].
|
27
|
+
expect(Uglifier.new.compile(source)[-1]).to eql(";"[0])
|
34
28
|
end
|
35
29
|
|
36
30
|
describe "argument name mangling" do
|
37
31
|
it "doesn't try to mangle $super by default to avoid breaking PrototypeJS" do
|
38
|
-
Uglifier.compile('function foo($super) {return $super}').
|
32
|
+
expect(Uglifier.compile('function foo($super) {return $super}')).to include("$super")
|
39
33
|
end
|
40
34
|
|
41
35
|
it "allows variables to be excluded from mangling" do
|
42
36
|
code = "function bar(foo) {return foo + 'bar'};"
|
43
|
-
Uglifier.compile(code, :mangle => {:except => ["foo"]}).
|
37
|
+
expect(Uglifier.compile(code, :mangle => { :except => ["foo"] })).to include("(foo)")
|
44
38
|
end
|
45
39
|
|
46
40
|
it "skips mangling when set to false" do
|
47
41
|
code = "function bar(foo) {return foo + 'bar'};"
|
48
|
-
Uglifier.compile(code, :mangle => false).
|
42
|
+
expect(Uglifier.compile(code, :mangle => false)).to include("(foo)")
|
49
43
|
end
|
50
44
|
|
51
45
|
it "mangles argumen names by default" do
|
52
46
|
code = "function bar(foo) {return foo + 'bar'};"
|
53
|
-
Uglifier.compile(code, :mangle => true).
|
47
|
+
expect(Uglifier.compile(code, :mangle => true)).not_to include("(foo)")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "mangles top-level names when explicitly instructed" do
|
51
|
+
code = "function bar(foo) {return foo + 'bar'};"
|
52
|
+
expect(Uglifier.compile(code, :mangle => { :toplevel => false })).to include("bar(")
|
53
|
+
expect(Uglifier.compile(code, :mangle => { :toplevel => true })).not_to include("bar(")
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
57
|
describe "comment preservation" do
|
58
|
-
let(:source)
|
58
|
+
let(:source) do
|
59
59
|
<<-EOS
|
60
60
|
/* @preserve Copyright Notice */
|
61
61
|
/* (c) 2011 */
|
62
62
|
// INCLUDED
|
63
|
+
//! BANG
|
63
64
|
function identity(p) { return p; }
|
64
65
|
/* Another Copyright */
|
66
|
+
/*! Another Bang */
|
67
|
+
// A comment!
|
65
68
|
function add(a, b) { return a + b; }
|
66
69
|
EOS
|
67
|
-
|
70
|
+
end
|
68
71
|
|
69
72
|
it "handles copyright option" do
|
70
73
|
compiled = Uglifier.compile(source, :copyright => false)
|
71
|
-
compiled.
|
74
|
+
expect(compiled).not_to match(/Copyright/)
|
72
75
|
end
|
73
76
|
|
74
77
|
describe ":copyright" do
|
75
78
|
subject { Uglifier.compile(source, :comments => :copyright) }
|
76
79
|
|
77
80
|
it "preserves comments with string Copyright" do
|
78
|
-
subject.
|
79
|
-
subject.
|
81
|
+
expect(subject).to match(/Copyright Notice/)
|
82
|
+
expect(subject).to match(/Another Copyright/)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "preserves comments that start with a bang (!)" do
|
86
|
+
expect(subject).to match(/! BANG/)
|
87
|
+
expect(subject).to match(/! Another Bang/)
|
80
88
|
end
|
81
89
|
|
82
90
|
it "ignores other comments" do
|
83
|
-
subject.
|
91
|
+
expect(subject).not_to match(/INCLUDED/)
|
92
|
+
expect(subject).not_to match(/A comment!/)
|
84
93
|
end
|
85
94
|
end
|
86
95
|
|
87
96
|
describe ":jsdoc" do
|
88
|
-
subject { Uglifier.compile(source, :output => {:comments => :jsdoc}) }
|
97
|
+
subject { Uglifier.compile(source, :output => { :comments => :jsdoc }) }
|
89
98
|
|
90
99
|
it "preserves jsdoc license/preserve blocks" do
|
91
|
-
subject.
|
100
|
+
expect(subject).to match(/Copyright Notice/)
|
92
101
|
end
|
93
102
|
|
94
103
|
it "ignores other comments" do
|
95
|
-
subject.
|
104
|
+
expect(subject).not_to match(/Another Copyright/)
|
96
105
|
end
|
97
106
|
end
|
98
107
|
|
@@ -100,8 +109,8 @@ describe "Uglifier" do
|
|
100
109
|
subject { Uglifier.compile(source, :comments => :all) }
|
101
110
|
|
102
111
|
it "preserves all comments" do
|
103
|
-
subject.
|
104
|
-
subject.
|
112
|
+
expect(subject).to match(/INCLUDED/)
|
113
|
+
expect(subject).to match(/2011/)
|
105
114
|
end
|
106
115
|
end
|
107
116
|
|
@@ -109,8 +118,8 @@ describe "Uglifier" do
|
|
109
118
|
subject { Uglifier.compile(source, :comments => :none) }
|
110
119
|
|
111
120
|
it "omits all comments" do
|
112
|
-
subject.
|
113
|
-
subject.
|
121
|
+
expect(subject).not_to match %r{//}
|
122
|
+
expect(subject).not_to match(/\/\*/)
|
114
123
|
end
|
115
124
|
end
|
116
125
|
|
@@ -118,87 +127,133 @@ describe "Uglifier" do
|
|
118
127
|
subject { Uglifier.compile(source, :comments => /included/i) }
|
119
128
|
|
120
129
|
it "matches comment blocks with regex" do
|
121
|
-
subject.
|
130
|
+
expect(subject).to match(/INCLUDED/)
|
122
131
|
end
|
123
132
|
|
124
133
|
it "omits other blocks" do
|
125
|
-
subject.
|
134
|
+
expect(subject).not_to match(/2011/)
|
126
135
|
end
|
127
136
|
end
|
128
137
|
end
|
129
138
|
|
130
139
|
it "squeezes code only if squeeze is set to true" do
|
131
140
|
code = "function a(a){if(a) { return 0; } else { return 1; }}"
|
132
|
-
|
141
|
+
minified = Uglifier.compile(code, :squeeze => false)
|
142
|
+
squeezed = Uglifier.compile(code, :squeeze => true)
|
143
|
+
expect(minified.length).to be > squeezed.length
|
133
144
|
end
|
134
145
|
|
135
146
|
it "honors max line length" do
|
136
147
|
code = "var foo = 123;function bar() { return foo; }"
|
137
|
-
Uglifier.
|
148
|
+
uglifier = Uglifier.new(:output => { :max_line_len => 20 }, :compress => false)
|
149
|
+
expect(uglifier.compile(code).split("\n").map(&:length)).to all(be < 28)
|
138
150
|
end
|
139
151
|
|
140
152
|
it "hoists vars to top of the scope" do
|
141
|
-
code = "function something() { var
|
142
|
-
Uglifier.compile(code, :compress => {:hoist_vars => true})
|
153
|
+
code = "function something() { var a = 1; a = 2; var b = 3; return a + b;}"
|
154
|
+
minified = Uglifier.compile(code, :compress => { :hoist_vars => true })
|
155
|
+
expect(minified).to match(/var \w,\w/)
|
143
156
|
end
|
144
157
|
|
145
158
|
it "forwards screw_ie8 option to UglifyJS" do
|
146
159
|
code = "function something() { return g['switch']; }"
|
147
|
-
Uglifier.compile(code, :mangle => false, :screw_ie8 => true).
|
148
|
-
Uglifier.compile(code, :compress => false, :screw_ie8 => true).
|
160
|
+
expect(Uglifier.compile(code, :mangle => false, :screw_ie8 => true)).to match(/g\.switch/)
|
161
|
+
expect(Uglifier.compile(code, :compress => false, :screw_ie8 => true)).to match(/g\.switch/)
|
149
162
|
end
|
150
163
|
|
151
164
|
it "can be configured to output only ASCII" do
|
152
165
|
code = "function emoji() { return '\\ud83c\\ude01'; }"
|
153
|
-
Uglifier.compile(code, :output => {:ascii_only => true})
|
166
|
+
minified = Uglifier.compile(code, :output => { :ascii_only => true })
|
167
|
+
expect(minified).to include("\\ud83c\\ude01")
|
154
168
|
end
|
155
169
|
|
156
170
|
it "escapes </script when asked to" do
|
157
171
|
code = "function test() { return '</script>';}"
|
158
|
-
Uglifier.compile(code, :output => {:inline_script => true})
|
172
|
+
minified = Uglifier.compile(code, :output => { :inline_script => true })
|
173
|
+
expect(minified).not_to include("</script>")
|
159
174
|
end
|
160
175
|
|
161
176
|
it "quotes keys" do
|
162
177
|
code = "var a = {foo: 1}"
|
163
|
-
Uglifier.compile(code, :output => {:quote_keys => true})
|
178
|
+
minified = Uglifier.compile(code, :output => { :quote_keys => true })
|
179
|
+
expect(minified).to include('"foo"')
|
164
180
|
end
|
165
181
|
|
166
182
|
it "quotes unsafe keys by default" do
|
167
|
-
code = 'var code = {"class": ""}'
|
168
|
-
Uglifier.compile(code).
|
183
|
+
code = 'var code = {"class": "", "\u200c":"A"}'
|
184
|
+
expect(Uglifier.compile(code)).to include('"class"')
|
185
|
+
expect(Uglifier.compile(code)).to include('"\u200c"')
|
186
|
+
|
187
|
+
uglifier = Uglifier.new(:output => { :ascii_only => false, :quote_keys => false })
|
188
|
+
expect(uglifier.compile(code)).to include(["200c".to_i(16)].pack("U*"))
|
169
189
|
end
|
170
190
|
|
171
191
|
it "handles constant definitions" do
|
172
|
-
code = "if (
|
173
|
-
defines = {"
|
192
|
+
code = "if (BOOL) { var a = STR; var b = NULL; var c = NUM; }"
|
193
|
+
defines = { "NUM" => 1234, "BOOL" => true, "NULL" => nil, "STR" => "str" }
|
174
194
|
processed = Uglifier.compile(code, :define => defines)
|
175
|
-
processed.
|
176
|
-
processed.
|
177
|
-
processed.
|
178
|
-
processed.
|
195
|
+
expect(processed).to include("a=\"str\"")
|
196
|
+
expect(processed).not_to include("if")
|
197
|
+
expect(processed).to include("b=null")
|
198
|
+
expect(processed).to include("c=1234")
|
179
199
|
end
|
180
200
|
|
181
201
|
it "can disable IIFE negation" do
|
182
202
|
code = "(function() { console.log('test')})();"
|
183
|
-
disabled_negation = Uglifier.compile(code, :compress => {:negate_iife => false})
|
184
|
-
disabled_negation.
|
185
|
-
negation = Uglifier.compile(code, :compress => {:negate_iife => true})
|
186
|
-
negation.
|
203
|
+
disabled_negation = Uglifier.compile(code, :compress => { :negate_iife => false })
|
204
|
+
expect(disabled_negation).not_to include("!")
|
205
|
+
negation = Uglifier.compile(code, :compress => { :negate_iife => true })
|
206
|
+
expect(negation).to include("!")
|
207
|
+
end
|
208
|
+
|
209
|
+
it "can drop console logging" do
|
210
|
+
code = "(function() { console.log('test')})();"
|
211
|
+
compiled = Uglifier.compile(code, :compress => { :drop_console => true })
|
212
|
+
expect(compiled).not_to include("console")
|
213
|
+
end
|
214
|
+
|
215
|
+
it "processes @ngInject annotations" do
|
216
|
+
code = <<-EOF
|
217
|
+
/**
|
218
|
+
* @ngInject
|
219
|
+
*/
|
220
|
+
var f = function(foo, bar) { return foo + bar};
|
221
|
+
EOF
|
222
|
+
with_angular = Uglifier.compile(code, :compress => { :angular => true })
|
223
|
+
without_angular = Uglifier.compile(code, :compress => { :angular => false })
|
224
|
+
expect(with_angular).to include("f.$inject")
|
225
|
+
expect(without_angular).not_to include("f.$inject")
|
226
|
+
end
|
227
|
+
|
228
|
+
it "keeps unused function arguments when keep_fargs option is set" do
|
229
|
+
code = <<-EOF
|
230
|
+
function plus(a, b, c) { return a + b};
|
231
|
+
plus(1, 2);
|
232
|
+
EOF
|
233
|
+
|
234
|
+
options = lambda do |keep_fargs|
|
235
|
+
{
|
236
|
+
:mangle => false,
|
237
|
+
:compress => {
|
238
|
+
:keep_fargs => keep_fargs,
|
239
|
+
:unsafe => true
|
240
|
+
}
|
241
|
+
}
|
242
|
+
end
|
243
|
+
|
244
|
+
expect(Uglifier.compile(code, options.call(false))).not_to include("c)")
|
245
|
+
expect(Uglifier.compile(code, options.call(true))).to include("c)")
|
187
246
|
end
|
188
247
|
|
189
248
|
describe "Input Formats" do
|
190
249
|
let(:code) { "function hello() { return 'hello world'; }" }
|
191
250
|
|
192
251
|
it "handles strings" do
|
193
|
-
|
194
|
-
Uglifier.new.compile(code).should_not be_empty
|
195
|
-
}.should_not raise_error
|
252
|
+
expect(Uglifier.new.compile(code)).not_to be_empty
|
196
253
|
end
|
197
254
|
|
198
255
|
it "handles IO objects" do
|
199
|
-
|
200
|
-
Uglifier.new.compile(StringIO.new(code)).should_not be_empty
|
201
|
-
}.should_not raise_error
|
256
|
+
expect(Uglifier.new.compile(StringIO.new(code))).not_to be_empty
|
202
257
|
end
|
203
258
|
end
|
204
259
|
|
@@ -206,18 +261,20 @@ describe "Uglifier" do
|
|
206
261
|
let(:code) { "$.foo()" }
|
207
262
|
|
208
263
|
it "encloses code with given arguments" do
|
209
|
-
Uglifier.compile(code, :enclose => {'window.jQuery' => '$'})
|
264
|
+
minified = Uglifier.compile(code, :enclose => { 'window.jQuery' => '$' })
|
265
|
+
expect(minified).to match(/window.jQuery/)
|
210
266
|
end
|
211
267
|
|
212
268
|
it "handles multiple definitions" do
|
213
|
-
|
214
|
-
minified.
|
215
|
-
minified.
|
269
|
+
definitions = [%w(lol lulz), %w(foo bar)]
|
270
|
+
minified = Uglifier.compile(code, :enclose => definitions)
|
271
|
+
expect(minified).to match(/lol,foo/)
|
272
|
+
expect(minified).to match(/lulz,bar/)
|
216
273
|
end
|
217
274
|
|
218
275
|
it "wraps with function when given empty object" do
|
219
276
|
minified = Uglifier.compile(code, :enclose => {})
|
220
|
-
minified.
|
277
|
+
expect(minified).to match(/function\(/)
|
221
278
|
end
|
222
279
|
end
|
223
280
|
end
|
data/uglifier.gemspec
CHANGED
@@ -1,75 +1,35 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'uglifier/version'
|
5
5
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "uglifier"
|
8
|
+
spec.version = Uglifier::VERSION
|
9
|
+
spec.authors = ["Ville Lautanala"]
|
10
|
+
spec.email = ["lautis@gmail.com"]
|
11
|
+
spec.homepage = "http://github.com/lautis/uglifier"
|
12
|
+
spec.summary = "Ruby wrapper for UglifyJS JavaScript compressor"
|
13
|
+
spec.description = "Uglifier minifies JavaScript files by wrapping UglifyJS to be accessible in Ruby"
|
14
|
+
spec.license = "MIT"
|
9
15
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
s.email = "lautis@gmail.com"
|
14
|
-
s.extra_rdoc_files = [
|
15
|
-
"LICENSE.txt",
|
16
|
-
"README.md"
|
17
|
-
]
|
18
|
-
s.files = [
|
19
|
-
".document",
|
20
|
-
".gitmodules",
|
21
|
-
".rspec",
|
22
|
-
".travis.yml",
|
23
|
-
"CHANGELOG.md",
|
24
|
-
"CONTRIBUTING.md",
|
25
|
-
"Gemfile",
|
16
|
+
spec.required_ruby_version = '>= 1.8.7'
|
17
|
+
|
18
|
+
spec.extra_rdoc_files = [
|
26
19
|
"LICENSE.txt",
|
27
20
|
"README.md",
|
28
|
-
"
|
29
|
-
"
|
30
|
-
"lib/es5.js",
|
31
|
-
"lib/split.js",
|
32
|
-
"lib/uglifier.rb",
|
33
|
-
"lib/uglify.js",
|
34
|
-
"spec/source_map_spec.rb",
|
35
|
-
"spec/spec_helper.rb",
|
36
|
-
"spec/uglifier_spec.rb",
|
37
|
-
"uglifier.gemspec"
|
21
|
+
"CHANGELOG.md",
|
22
|
+
"CONTRIBUTING.md"
|
38
23
|
]
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
s.rubygems_version = "1.8.23"
|
43
|
-
s.summary = "Ruby wrapper for UglifyJS JavaScript compressor"
|
44
|
-
|
45
|
-
if s.respond_to? :specification_version then
|
46
|
-
s.specification_version = 3
|
24
|
+
spec.files = `git ls-files`.split($/)
|
25
|
+
spec.test_files = spec.files.grep(%r{^spec/})
|
26
|
+
spec.require_paths = ["lib"]
|
47
27
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
s.add_development_dependency(%q<source_map>, [">= 0"])
|
56
|
-
else
|
57
|
-
s.add_dependency(%q<execjs>, [">= 0.3.0"])
|
58
|
-
s.add_dependency(%q<multi_json>, [">= 1.0.2", "~> 1.0"])
|
59
|
-
s.add_dependency(%q<rspec>, ["~> 2.7"])
|
60
|
-
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
61
|
-
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
62
|
-
s.add_dependency(%q<rdoc>, [">= 3.11"])
|
63
|
-
s.add_dependency(%q<source_map>, [">= 0"])
|
64
|
-
end
|
65
|
-
else
|
66
|
-
s.add_dependency(%q<execjs>, [">= 0.3.0"])
|
67
|
-
s.add_dependency(%q<multi_json>, [">= 1.0.2", "~> 1.0"])
|
68
|
-
s.add_dependency(%q<rspec>, ["~> 2.7"])
|
69
|
-
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
70
|
-
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
71
|
-
s.add_dependency(%q<rdoc>, [">= 3.11"])
|
72
|
-
s.add_dependency(%q<source_map>, [">= 0"])
|
73
|
-
end
|
28
|
+
spec.add_runtime_dependency "execjs", ">= 0.3.0"
|
29
|
+
spec.add_runtime_dependency "json", ">= 1.8.0"
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.4"
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
33
|
+
spec.add_development_dependency "rdoc", ">= 3.11"
|
34
|
+
spec.add_development_dependency "source_map", ">= 0"
|
74
35
|
end
|
75
|
-
|