terser 1.0.0 → 1.1.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.
@@ -12,6 +12,7 @@ class Terser
12
12
  options[:comments] ||= :none
13
13
  @options = options
14
14
  @cache_key = -"Terser:#{::Terser::VERSION}:#{VERSION}:#{::Sprockets::DigestUtils.digest(options)}"
15
+ @terser = ::Terser.new(@options)
15
16
  end
16
17
 
17
18
  def self.instance
@@ -31,9 +32,8 @@ class Terser
31
32
  if Gem::Version.new(::Sprockets::VERSION) >= Gem::Version.new('4.x')
32
33
  def call(input)
33
34
  input_options = { :source_map => { :filename => input[:filename] } }
34
- terser = ::Terser.new(@options.merge(input_options))
35
35
 
36
- js, map = terser.compile_with_map(input[:data])
36
+ js, map = @terser.compile_with_map(input[:data], input_options)
37
37
 
38
38
  map = ::Sprockets::SourceMapUtils.format_source_map(JSON.parse(map), input)
39
39
  map = ::Sprockets::SourceMapUtils.combine_source_maps(input[:metadata][:map], map)
@@ -42,8 +42,7 @@ class Terser
42
42
  end
43
43
  else
44
44
  def call(input)
45
- terser = ::Terser.new(@options)
46
- terser.compile(input[:data])
45
+ @terser.compile(input[:data])
47
46
  end
48
47
  end
49
48
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  class Terser
4
4
  # Current version of Terser.
5
- VERSION = "1.0.0"
5
+ VERSION = "1.1.2"
6
6
  end
@@ -45,7 +45,11 @@ function terser_wrapper(options) {
45
45
 
46
46
  var inputs = {};
47
47
  inputs[inputFilename] = source;
48
- var result = Terser.minify(inputs, options);
49
- //if (result.error) throw result.error;
50
- return result;
48
+
49
+ try {
50
+ return Terser.minifySync(inputs, options);
51
+ } catch (error) {
52
+ const { message, filename, line, col, pos } = error;
53
+ return {error: {message: message, filename: filename, line: line, col: col, pos: pos}}
54
+ }
51
55
  }
data/terser.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  ]
27
27
 
28
28
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
29
- f.match(%r{^(spec|vendor|gemfiles|patches|benchmark)/})
29
+ f.match(%r{^(spec|vendor|gemfiles|patches|benchmark|.github)/})
30
30
  end
31
31
  spec.require_paths = ["lib"]
32
32
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Rosicky
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-13 00:00:00.000000000 Z
11
+ date: 2021-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: execjs
@@ -103,7 +103,6 @@ files:
103
103
  - ".gitmodules"
104
104
  - ".rspec"
105
105
  - ".rubocop.yml"
106
- - ".travis.yml"
107
106
  - ".yardopts"
108
107
  - CHANGELOG.md
109
108
  - CONTRIBUTING.md
@@ -124,7 +123,7 @@ homepage: http://github.com/ahorek/terser-ruby
124
123
  licenses:
125
124
  - MIT
126
125
  metadata: {}
127
- post_install_message:
126
+ post_install_message:
128
127
  rdoc_options: []
129
128
  require_paths:
130
129
  - lib
@@ -139,8 +138,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
138
  - !ruby/object:Gem::Version
140
139
  version: '0'
141
140
  requirements: []
142
- rubygems_version: 3.1.2
143
- signing_key:
141
+ rubygems_version: 3.1.4
142
+ signing_key:
144
143
  specification_version: 4
145
144
  summary: Ruby wrapper for Terser JavaScript compressor
146
145
  test_files: []
data/.travis.yml DELETED
@@ -1,26 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.3
6
- - 2.5
7
- - 2.7
8
- - ruby-head
9
- - jruby-head
10
- - jruby-9.2.12.0
11
- - truffleruby
12
- before_install:
13
- - gem install bundler -v 1.17.3
14
- git:
15
- submodules: false
16
- gemfile:
17
- - Gemfile
18
- matrix:
19
- include:
20
- - rvm: 2.5
21
- gemfile: gemfiles/miniracer
22
- allow_failures:
23
- - rvm: ruby-head
24
- - rvm: truffleruby
25
- - rvm: jruby-head
26
- fast_finish: true