opal-optimizer 0.1.6 → 0.1.8
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 +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/opal/optimizer/sprockets.rb +2 -0
- data/lib/opal/optimizer/version.rb +1 -1
- data/lib/opal/optimizer.rb +17 -8
- data/lib/opal-optimizer.rb +2 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ee7a8b44f7cab98ff99da447a9b934387c9f2e9533af55bea08edea9cd9cc22
|
4
|
+
data.tar.gz: 7de32b2e91a478e68fc89bdbaa7868b26033fe8f8dca2fcbd489b6777c7d8cbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54374902a29fd0e30c7599f5034ee3d993d94aa294d16899fb2fd53b9ddba19cb0c8d6d1fcc7e83179abc8ebb2e80f75244ad2331868c5fbd4acd7216e474517
|
7
|
+
data.tar.gz: da1bf3efc02c9087da38eb28e771210ba01a148565a9fb98efc0bf18451be9c3d6a3bac1e7353b2b3fb10502677b70a137be72083ffabda339b39f3bce43edb0
|
data/CHANGELOG.md
CHANGED
data/lib/opal/optimizer.rb
CHANGED
@@ -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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
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.
|
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:
|
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.
|
92
|
+
rubygems_version: 3.4.6
|
92
93
|
signing_key:
|
93
94
|
specification_version: 4
|
94
95
|
summary: Optimize Opal's resulting javascript code
|