opal-optimizer 0.1.6 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6498304a0ea20dac60d150ea41df0876ade32476a48a489daca24396686de528
4
- data.tar.gz: e453ead6b82eedb0fd1c03fc38cd2de64a5d1ceda31a55a541e83f50b9ed76d8
3
+ metadata.gz: 4ee7a8b44f7cab98ff99da447a9b934387c9f2e9533af55bea08edea9cd9cc22
4
+ data.tar.gz: 7de32b2e91a478e68fc89bdbaa7868b26033fe8f8dca2fcbd489b6777c7d8cbb
5
5
  SHA512:
6
- metadata.gz: bcbf6fb6a5f209e3cea950be73637504ce830c16a9ef8e7402156b64d82e8905c6406a12e0acbc52feb2a1770a4f869ca1c52b78c6f08b590c6c64df94d7c9c7
7
- data.tar.gz: 941e429601ce081347bad1179f152f0dd5aa0f3b20374cf683e021ca1c00e5e078cd63e44476af127fcc8d21eb0f34b35c605df5ae9a129c2e28c3917c970a59
6
+ metadata.gz: 54374902a29fd0e30c7599f5034ee3d993d94aa294d16899fb2fd53b9ddba19cb0c8d6d1fcc7e83179abc8ebb2e80f75244ad2331868c5fbd4acd7216e474517
7
+ data.tar.gz: da1bf3efc02c9087da38eb28e771210ba01a148565a9fb98efc0bf18451be9c3d6a3bac1e7353b2b3fb10502677b70a137be72083ffabda339b39f3bce43edb0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## v0.1.8
2
+
3
+ * Improve interop with Sprockets when non-Opal javascripts are compiled as well
4
+
5
+ ## v0.1.7
6
+
7
+ * Opal 1.6 compatibility
8
+
1
9
  ## v0.1.6
2
10
 
3
11
  * Further Opal 1.4 compatibility
@@ -7,6 +7,8 @@ module Opal; class Optimizer
7
7
  module Sprockets
8
8
  def self.call input
9
9
  Opal::Optimizer.new(input[:data]).optimize
10
+ rescue NonOpalArgumentError
11
+ input[:data]
10
12
  end
11
13
  end
12
14
 
@@ -1,5 +1,5 @@
1
1
  module Opal
2
2
  class Optimizer
3
- VERSION = "0.1.6"
3
+ VERSION = "0.1.8"
4
4
  end
5
5
  end
@@ -3,10 +3,10 @@ require "rkelly"
3
3
  require "opal/optimizer/helpers"
4
4
  require "opal/compiler"
5
5
 
6
- require "pry"
7
-
8
6
  module Opal
9
7
  class Optimizer
8
+ class NonOpalArgumentError < ArgumentError; end
9
+
10
10
  include Helpers
11
11
 
12
12
  attr_accessor :ast, :opal_version, :corelib, :corelib_source, :corelib_calls,
@@ -15,6 +15,12 @@ module Opal
15
15
  attr_accessor :exports
16
16
 
17
17
  def initialize(code, exports: "", force_corelib: true)
18
+ if force_corelib
19
+ unless code.include? "// A few conventions for the documentation of this file:"
20
+ raise NonOpalArgumentError, "A non-Opal code provided"
21
+ end
22
+ end
23
+
18
24
  @ast = parse_js(code)
19
25
 
20
26
  @corelib = @ast.value.find do |i|
@@ -24,12 +30,15 @@ module Opal
24
30
  es.end_with?("TypeError.$$super = Error;\n}).call(this);")
25
31
  @opal_version = 1.0
26
32
  elsif es.start_with?("(function(global_object) {\n \"use strict\";\n\n // @note\n "\
27
- "// A few conventions for the documentation of this file:") &&
28
- es.end_with?("TypeError.$$super = Error;\n}).call(this);")
29
- if es.include? 'function $prop(object,'
30
- @opal_version = 1.4
31
- else
32
- @opal_version = 1.1
33
+ "// A few conventions for the documentation of this file:")
34
+ if es.end_with?("TypeError.$$super = Error;\n}).call(this);")
35
+ if es.include? 'function $prop(object,'
36
+ @opal_version = 1.4
37
+ else
38
+ @opal_version = 1.1
39
+ end
40
+ elsif es.end_with?("Opal.file_sources = {};\n}).call(this);")
41
+ @opal_version = 1.6
33
42
  end
34
43
  end
35
44
  end
@@ -0,0 +1,2 @@
1
+ require "opal/optimizer"
2
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opal-optimizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - hmdne
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-23 00:00:00.000000000 Z
11
+ date: 2023-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rkelly-turbo
@@ -58,6 +58,7 @@ files:
58
58
  - bin/opal-optimizer
59
59
  - bin/setup
60
60
  - exe/opal-optimizer
61
+ - lib/opal-optimizer.rb
61
62
  - lib/opal/optimizer.rb
62
63
  - lib/opal/optimizer/helpers.rb
63
64
  - lib/opal/optimizer/sprockets.rb
@@ -88,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
89
  - !ruby/object:Gem::Version
89
90
  version: '0'
90
91
  requirements: []
91
- rubygems_version: 3.2.22
92
+ rubygems_version: 3.4.6
92
93
  signing_key:
93
94
  specification_version: 4
94
95
  summary: Optimize Opal's resulting javascript code