uglifier 1.3.0 → 4.2.0

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.
data/uglifier.gemspec CHANGED
@@ -1,68 +1,35 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
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 |s|
7
- s.name = "uglifier"
8
- s.version = "1.3.0"
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
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Ville Lautanala"]
12
- s.date = "2012-09-02"
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
- "Gemfile",
16
+ spec.required_ruby_version = '>= 1.9.3'
17
+
18
+ spec.extra_rdoc_files = [
24
19
  "LICENSE.txt",
25
20
  "README.md",
26
- "Rakefile",
27
- "VERSION",
28
- "build.js",
29
- "lib/es5.js",
30
- "lib/uglifier.rb",
31
- "lib/uglify.js",
32
- "spec/spec_helper.rb",
33
- "spec/uglifier_spec.rb",
34
- "uglifier.gemspec"
21
+ "CHANGELOG.md",
22
+ "CONTRIBUTING.md"
35
23
  ]
36
- s.homepage = "http://github.com/lautis/uglifier"
37
- s.require_paths = ["lib"]
38
- s.rubygems_version = "1.8.23"
39
- s.summary = "Ruby wrapper for UglifyJS JavaScript compressor"
40
24
 
41
- if s.respond_to? :specification_version then
42
- s.specification_version = 3
43
-
44
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
- s.add_runtime_dependency(%q<execjs>, [">= 0.3.0"])
46
- s.add_runtime_dependency(%q<multi_json>, [">= 1.0.2", "~> 1.0"])
47
- s.add_development_dependency(%q<rspec>, ["~> 2.7"])
48
- s.add_development_dependency(%q<bundler>, ["~> 1.0"])
49
- s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
50
- s.add_development_dependency(%q<rdoc>, ["~> 3.11"])
51
- else
52
- s.add_dependency(%q<execjs>, [">= 0.3.0"])
53
- s.add_dependency(%q<multi_json>, [">= 1.0.2", "~> 1.0"])
54
- s.add_dependency(%q<rspec>, ["~> 2.7"])
55
- s.add_dependency(%q<bundler>, ["~> 1.0"])
56
- s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
57
- s.add_dependency(%q<rdoc>, ["~> 3.11"])
58
- end
59
- else
60
- s.add_dependency(%q<execjs>, [">= 0.3.0"])
61
- s.add_dependency(%q<multi_json>, [">= 1.0.2", "~> 1.0"])
62
- s.add_dependency(%q<rspec>, ["~> 2.7"])
63
- s.add_dependency(%q<bundler>, ["~> 1.0"])
64
- s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
65
- s.add_dependency(%q<rdoc>, ["~> 3.11"])
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(spec|vendor|gemfiles|patches)/})
66
27
  end
67
- end
28
+ spec.require_paths = ["lib"]
68
29
 
30
+ spec.add_runtime_dependency "execjs", [">= 0.3.0", "< 3"]
31
+ spec.add_development_dependency "rspec", "~> 3.0"
32
+ spec.add_development_dependency "rake", "~> 12.0"
33
+ spec.add_development_dependency "bundler", ">= 1.3"
34
+ spec.add_development_dependency "sourcemap", "~> 0.1.1"
35
+ end
metadata CHANGED
@@ -1,167 +1,147 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uglifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
5
- prerelease:
4
+ version: 4.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ville Lautanala
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-09-02 00:00:00.000000000 Z
11
+ date: 2019-09-25 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: execjs
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.3.0
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: 0.3.0
30
- - !ruby/object:Gem::Dependency
31
- name: multi_json
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
20
+ - - "<"
36
21
  - !ruby/object:Gem::Version
37
- version: 1.0.2
38
- - - ~>
39
- - !ruby/object:Gem::Version
40
- version: '1.0'
22
+ version: '3'
41
23
  type: :runtime
42
24
  prerelease: false
43
25
  version_requirements: !ruby/object:Gem::Requirement
44
- none: false
45
26
  requirements:
46
- - - ! '>='
27
+ - - ">="
47
28
  - !ruby/object:Gem::Version
48
- version: 1.0.2
49
- - - ~>
29
+ version: 0.3.0
30
+ - - "<"
50
31
  - !ruby/object:Gem::Version
51
- version: '1.0'
32
+ version: '3'
52
33
  - !ruby/object:Gem::Dependency
53
34
  name: rspec
54
35
  requirement: !ruby/object:Gem::Requirement
55
- none: false
56
36
  requirements:
57
- - - ~>
37
+ - - "~>"
58
38
  - !ruby/object:Gem::Version
59
- version: '2.7'
39
+ version: '3.0'
60
40
  type: :development
61
41
  prerelease: false
62
42
  version_requirements: !ruby/object:Gem::Requirement
63
- none: false
64
43
  requirements:
65
- - - ~>
44
+ - - "~>"
66
45
  - !ruby/object:Gem::Version
67
- version: '2.7'
46
+ version: '3.0'
68
47
  - !ruby/object:Gem::Dependency
69
- name: bundler
48
+ name: rake
70
49
  requirement: !ruby/object:Gem::Requirement
71
- none: false
72
50
  requirements:
73
- - - ~>
51
+ - - "~>"
74
52
  - !ruby/object:Gem::Version
75
- version: '1.0'
53
+ version: '12.0'
76
54
  type: :development
77
55
  prerelease: false
78
56
  version_requirements: !ruby/object:Gem::Requirement
79
- none: false
80
57
  requirements:
81
- - - ~>
58
+ - - "~>"
82
59
  - !ruby/object:Gem::Version
83
- version: '1.0'
60
+ version: '12.0'
84
61
  - !ruby/object:Gem::Dependency
85
- name: jeweler
62
+ name: bundler
86
63
  requirement: !ruby/object:Gem::Requirement
87
- none: false
88
64
  requirements:
89
- - - ~>
65
+ - - ">="
90
66
  - !ruby/object:Gem::Version
91
- version: 1.8.3
67
+ version: '1.3'
92
68
  type: :development
93
69
  prerelease: false
94
70
  version_requirements: !ruby/object:Gem::Requirement
95
- none: false
96
71
  requirements:
97
- - - ~>
72
+ - - ">="
98
73
  - !ruby/object:Gem::Version
99
- version: 1.8.3
74
+ version: '1.3'
100
75
  - !ruby/object:Gem::Dependency
101
- name: rdoc
76
+ name: sourcemap
102
77
  requirement: !ruby/object:Gem::Requirement
103
- none: false
104
78
  requirements:
105
- - - ~>
79
+ - - "~>"
106
80
  - !ruby/object:Gem::Version
107
- version: '3.11'
81
+ version: 0.1.1
108
82
  type: :development
109
83
  prerelease: false
110
84
  version_requirements: !ruby/object:Gem::Requirement
111
- none: false
112
85
  requirements:
113
- - - ~>
86
+ - - "~>"
114
87
  - !ruby/object:Gem::Version
115
- version: '3.11'
116
- description:
117
- email: lautis@gmail.com
88
+ version: 0.1.1
89
+ description: Uglifier minifies JavaScript files by wrapping UglifyJS to be accessible
90
+ in Ruby
91
+ email:
92
+ - lautis@gmail.com
118
93
  executables: []
119
94
  extensions: []
120
95
  extra_rdoc_files:
121
96
  - LICENSE.txt
122
97
  - README.md
98
+ - CHANGELOG.md
99
+ - CONTRIBUTING.md
123
100
  files:
124
- - .document
125
- - .gitmodules
126
- - .rspec
127
- - .travis.yml
101
+ - ".document"
102
+ - ".github/workflows/ruby.yml"
103
+ - ".gitignore"
104
+ - ".gitmodules"
105
+ - ".rspec"
106
+ - ".rubocop.yml"
107
+ - ".travis.yml"
108
+ - ".yardopts"
109
+ - CHANGELOG.md
110
+ - CONTRIBUTING.md
128
111
  - Gemfile
129
112
  - LICENSE.txt
130
113
  - README.md
131
114
  - Rakefile
132
- - VERSION
133
- - build.js
134
115
  - lib/es5.js
116
+ - lib/source-map.js
117
+ - lib/split.js
118
+ - lib/uglifier.js
135
119
  - lib/uglifier.rb
120
+ - lib/uglifier/version.rb
121
+ - lib/uglify-harmony.js
136
122
  - lib/uglify.js
137
- - spec/spec_helper.rb
138
- - spec/uglifier_spec.rb
139
123
  - uglifier.gemspec
140
124
  homepage: http://github.com/lautis/uglifier
141
- licenses: []
125
+ licenses:
126
+ - MIT
127
+ metadata: {}
142
128
  post_install_message:
143
129
  rdoc_options: []
144
130
  require_paths:
145
131
  - lib
146
132
  required_ruby_version: !ruby/object:Gem::Requirement
147
- none: false
148
133
  requirements:
149
- - - ! '>='
134
+ - - ">="
150
135
  - !ruby/object:Gem::Version
151
- version: '0'
152
- segments:
153
- - 0
154
- hash: -550840341360460746
136
+ version: 1.9.3
155
137
  required_rubygems_version: !ruby/object:Gem::Requirement
156
- none: false
157
138
  requirements:
158
- - - ! '>='
139
+ - - ">="
159
140
  - !ruby/object:Gem::Version
160
141
  version: '0'
161
142
  requirements: []
162
- rubyforge_project:
163
- rubygems_version: 1.8.23
143
+ rubygems_version: 3.0.3
164
144
  signing_key:
165
- specification_version: 3
145
+ specification_version: 4
166
146
  summary: Ruby wrapper for UglifyJS JavaScript compressor
167
147
  test_files: []
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.3.0
data/build.js DELETED
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var fs = require("fs");
4
- var stitch = require("stitch");
5
-
6
- var package = stitch.createPackage({
7
- paths: [__dirname + "/vendor/uglifyjs/lib"]
8
- });
9
-
10
- package.compile(function(err, source) {
11
- if (err) throw err;
12
-
13
- source = "(function(global) {" +
14
- source + ";\n" +
15
- "global.UglifyJS = {};\n" +
16
- "global.UglifyJS.parser = this.require('parse-js');\n" +
17
- "global.UglifyJS.uglify = this.require('process');\n" +
18
- "}).call({}, this);\n";
19
-
20
- fs.writeFile(__dirname + "/lib/uglify.js", source, function(err) {
21
- if (err) throw err;
22
- });
23
- });
data/spec/spec_helper.rb DELETED
@@ -1,11 +0,0 @@
1
- # encoding: UTF-8
2
- require 'uglifier'
3
- require 'rspec'
4
-
5
- # Requires supporting files with custom matchers and macros, etc,
6
- # in ./support/ and its subdirectories.
7
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
8
-
9
- RSpec.configure do |config|
10
-
11
- end
@@ -1,148 +0,0 @@
1
- # encoding: UTF-8
2
- require 'stringio'
3
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
4
-
5
- describe "Uglifier" do
6
- it "minifies JS" do
7
- source = File.open("lib/uglify.js", "r:UTF-8").read
8
- minified = Uglifier.new.compile(source)
9
- minified.length.should < source.length
10
- lambda {
11
- Uglifier.new.compile(minified)
12
- }.should_not raise_error
13
- end
14
-
15
- it "throws an exception when compilation fails" do
16
- lambda {
17
- Uglifier.new.compile(")(")
18
- }.should raise_error(Uglifier::Error)
19
- end
20
-
21
- it "doesn't omit null character in strings" do
22
- Uglifier.new.compile('var foo="\0bar"').should match(/(\0|\\0)/)
23
- end
24
-
25
- it "doesn't try to mangle $super by default to avoid breaking PrototypeJS" do
26
- Uglifier.new.compile('function foo($super) {return $super}').should include("$super")
27
- end
28
-
29
- it "adds trailing semicolon to minified source" do
30
- source = "function id(i) {return i;};"
31
- Uglifier.new.compile(source)[-1].should eql(";"[0])
32
- end
33
-
34
- describe "Copyright Preservation" do
35
- before :all do
36
- @source = <<-EOS
37
- /* Copyright Notice */
38
- /* (c) 2011 */
39
- // INCLUDED
40
- function identity(p) { return p; }
41
- EOS
42
- @minified = Uglifier.compile(@source, :copyright => true)
43
- end
44
-
45
- it "preserves copyright notice" do
46
- @minified.should match /Copyright Notice/
47
- end
48
-
49
- it "handles multiple copyright blocks" do
50
- @minified.should match /\(c\) 2011/
51
- end
52
-
53
- it "does include different comment types" do
54
- @minified.should match /INCLUDED/
55
- end
56
-
57
- it "puts comments on own lines" do
58
- @minified.split("\n").should have(4).items
59
- end
60
-
61
- it "omits copyright notification if copyright parameter is set to false" do
62
- Uglifier.compile(@source, :copyright => false).should_not match /Copyright/
63
- end
64
- end
65
-
66
- it "does additional squeezing when unsafe options is true" do
67
- unsafe_input = "function a(b){b.toString();}"
68
- Uglifier.new(:unsafe => true).compile(unsafe_input).length.should < Uglifier.new(:unsafe => false).compile(unsafe_input).length
69
- end
70
-
71
- it "mangles variables only if mangle is set to true" do
72
- code = "function longFunctionName(){};"
73
- Uglifier.new(:mangle => false).compile(code).length.should == code.length
74
- end
75
-
76
- it "squeezes code only if squeeze is set to true" do
77
- code = "function a(a){if(a) { return 0; } else { return 1; }}"
78
- Uglifier.compile(code, :squeeze => false).length.should > Uglifier.compile(code, :squeeze => true).length
79
- end
80
-
81
- it "should allow top level variables to be mangled" do
82
- code = "var foo = 123"
83
- Uglifier.compile(code, :toplevel => true).should_not include("var foo")
84
- end
85
-
86
- it "allows variables to be excluded from mangling" do
87
- code = "var foo = {bar: 123};"
88
- Uglifier.compile(code, :except => ["foo"], :toplevel => true).should include("var foo")
89
- end
90
-
91
- it "allows disabling of function name mangling" do
92
- code = "function sample() {var bar = 1; function foo() { return bar; }}"
93
- mangled = Uglifier.compile(code, :mangle => :vars)
94
- mangled.should include("foo()")
95
- mangled.should_not include("bar")
96
- end
97
-
98
- it "honors max line length" do
99
- code = "var foo = 123;var bar = 123456"
100
- Uglifier.compile(code, :max_line_length => 8).split("\n").length.should == 2
101
- end
102
-
103
- it "lifts vars to top of the scope" do
104
- code = "function something() { var foo = 123; foo = 1234; var bar = 123456; return foo + bar}"
105
- Uglifier.compile(code, :lift_vars => true).should match /var \w,\w/
106
- end
107
-
108
- it "can be configured to output only ASCII" do
109
- code = "function emoji() { return '\\ud83c\\ude01'; }"
110
- Uglifier.compile(code, :ascii_only => true).should include("\\ud83c\\ude01")
111
- end
112
-
113
- it "escapes </script when asked to" do
114
- code = "function test() { return '</script>';}"
115
- Uglifier.compile(code, :inline_script => true).should_not include("</script>")
116
- end
117
-
118
- it "quotes keys" do
119
- code = "var a = {foo: 1}"
120
- Uglifier.compile(code, :quote_keys => true).should include('"foo"')
121
- end
122
-
123
- it "handles constant definitions" do
124
- code = "if (BOOLEAN) { var a = STRING; var b = NULL; var c = NUMBER; }"
125
- defines = {"NUMBER" => 1234, "BOOLEAN" => true, "NULL" => nil, "STRING" => "str"}
126
- processed = Uglifier.compile(code, :define => defines)
127
- processed.should include("a=\"str\"")
128
- processed.should_not include("if")
129
- processed.should include("b=null")
130
- processed.should include("c=1234")
131
- end
132
-
133
- describe "Input Formats" do
134
- let(:code) { "function hello() { return 'hello world'; }" }
135
-
136
- it "handles strings" do
137
- lambda {
138
- Uglifier.new.compile(code).should_not be_empty
139
- }.should_not raise_error
140
- end
141
-
142
- it "handles IO objects" do
143
- lambda {
144
- Uglifier.new.compile(StringIO.new(code)).should_not be_empty
145
- }.should_not raise_error
146
- end
147
- end
148
- end