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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb026fa4f1d075fee10aa54bc2e86f50bc688cfb
4
- data.tar.gz: 52bf135ebd2d66a0bb0041908df6c88b0572f966
3
+ metadata.gz: 7062a8c1bbde4ac1923e93201a527af14f1e3cea
4
+ data.tar.gz: dc3085b345acd4c4f6e7a71cc26f8ad708e89d0c
5
5
  SHA512:
6
- metadata.gz: 56a67dd0bb264a5a0ecc863bb775d9fe5e559712c958cca43cd829d3461286f27d639d54efa8764b16de11067efeb8394ae6e3f4abffae563b6418f5180e8798
7
- data.tar.gz: c01510deda6fb3fbf9816e2572edbbffd9808a13691d0e0ee7f55b8f1a6c8acb29f57d47e2b2c98833110524be4d39a9d41897fb3868e7f34038817614bcf25e
6
+ metadata.gz: 46541d24080d33015418644c447949a7d7ca996d714640518b98d34d8f5cd50d47de18d33d7161be0e61224ac61fd49d8526a4c745ad49efa4e9ad6ff54879a3
7
+ data.tar.gz: 5c97052928028f300a8c6a5b9163bfb75b807dc6eef86b92e1a0689224eae93d76ded790fd0861d23c41db777a05d8ef819ba35572d5d5cd2299ffba7cd147f8
data/.gitignore CHANGED
@@ -11,6 +11,7 @@ doc
11
11
  # bundler
12
12
  .bundle
13
13
  Gemfile.lock
14
+ gemfiles/*.lock
14
15
 
15
16
  # jeweler generated
16
17
  pkg
@@ -21,3 +21,10 @@ matrix:
21
21
  gemfile: gemfiles/rubyracer
22
22
  - rvm: jruby-19mode
23
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
@@ -1,3 +1,7 @@
1
+ ## 2.7.1 (27 February 2015)
2
+
3
+ - fix compatibility with experimental Alaska ExecJS runtime
4
+
1
5
  ## 2.7.0 (8 January 2015)
2
6
 
3
7
  - copyright comment preservation also includes comments starting with a bang (!)
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec :path=> "../"
4
+ gem "alaska", github: "mavenlink/alaska"
@@ -10,67 +10,68 @@ class Uglifier
10
10
  Error = ExecJS::Error
11
11
  # JavaScript code to call UglifyJS
12
12
  JS = <<-JS
13
- function comments(option) {
14
- if (Object.prototype.toString.call(option) === '[object Array]') {
15
- return new RegExp(option[0], option[1]);
16
- } else if (option == "jsdoc") {
17
- return function(node, comment) {
18
- if (comment.type == "comment2") {
19
- return /@preserve|@license|@cc_on/i.test(comment.value);
20
- } else {
21
- return false;
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
- if (options.compress) {
35
- var compressor = UglifyJS.Compressor(options.compress);
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
- if (options.mangle) {
41
- ast.compute_char_frequency();
42
- ast.mangle_names(options.mangle);
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
- if (options.enclose) {
46
- ast = ast.wrap_enclose(options.enclose);
47
- }
40
+ if (options.mangle) {
41
+ ast.compute_char_frequency();
42
+ ast.mangle_names(options.mangle);
43
+ }
48
44
 
49
- var gen_code_options = options.output;
50
- gen_code_options.comments = comments(options.output.comments);
45
+ if (options.enclose) {
46
+ ast = ast.wrap_enclose(options.enclose);
47
+ }
51
48
 
52
- if (options.generate_map) {
53
- var source_map = UglifyJS.SourceMap(options.source_map_options);
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
- var stream = UglifyJS.OutputStream(gen_code_options);
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
- ast.print(stream);
57
+ var stream = UglifyJS.OutputStream(gen_code_options);
60
58
 
61
- if (options.source_map_options.map_url) {
62
- stream += "\\n//# sourceMappingURL=" + options.source_map_options.map_url;
63
- }
59
+ ast.print(stream);
64
60
 
65
- if (options.source_map_options.url) {
66
- stream += "\\n//# sourceURL=" + options.source_map_options.url;
67
- }
61
+ if (options.source_map_options.map_url) {
62
+ stream += "\\n//# sourceMappingURL=" + options.source_map_options.map_url;
63
+ }
68
64
 
69
- if (options.generate_map) {
70
- return [stream.toString(), source_map.toString()];
71
- } else {
72
- return stream.toString();
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
- @context.exec(Uglifier::JS % json_encode(
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"
@@ -1,4 +1,4 @@
1
1
  class Uglifier
2
2
  # Current version of Uglifier.
3
- VERSION = "2.7.0"
3
+ VERSION = "2.7.1"
4
4
  end
@@ -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.0
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-01-08 00:00:00.000000000 Z
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