opal-optimizer 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/opal/optimizer/step/collapse_stubs.rb +4 -3
- data/lib/opal/optimizer/step/tree_shaking.rb +7 -3
- data/lib/opal/optimizer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6498304a0ea20dac60d150ea41df0876ade32476a48a489daca24396686de528
|
4
|
+
data.tar.gz: e453ead6b82eedb0fd1c03fc38cd2de64a5d1ceda31a55a541e83f50b9ed76d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcbf6fb6a5f209e3cea950be73637504ce830c16a9ef8e7402156b64d82e8905c6406a12e0acbc52feb2a1770a4f869ca1c52b78c6f08b590c6c64df94d7c9c7
|
7
|
+
data.tar.gz: 941e429601ce081347bad1179f152f0dd5aa0f3b20374cf683e021ca1c00e5e078cd63e44476af127fcc8d21eb0f34b35c605df5ae9a129c2e28c3917c970a59
|
data/CHANGELOG.md
CHANGED
@@ -12,7 +12,7 @@ class CollapseStubs < Step
|
|
12
12
|
nodes = corelib_calls["add_stubs"] || []
|
13
13
|
nodes.each do |node|
|
14
14
|
if opal_version >= 1.4
|
15
|
-
stubs += node.arguments.value.first.value[1..-2].split(',')
|
15
|
+
stubs += node.arguments.value.first.value[1..-2].split(',').map(&"$".method(:+))
|
16
16
|
else
|
17
17
|
stubs += node.arguments.value.first.value.map do |i|
|
18
18
|
i.value.value.gsub(/['"]/, '')
|
@@ -29,12 +29,13 @@ class CollapseStubs < Step
|
|
29
29
|
|
30
30
|
stubs -= ["$respond_to_missing?"] if opal_version >= 1.1
|
31
31
|
|
32
|
-
|
32
|
+
|
33
|
+
new_stub_code = <<~JAVASCRIPT
|
33
34
|
var stubs = '#{stubs.to_a.join(',')}'.split(','), stubs_obj = {};
|
34
35
|
for (var i = 0; i < stubs.length; i++)
|
35
36
|
stubs_obj[stubs[i]] = {value: Opal.stub_for(stubs[i]), enumerable: false, configurable: true, writable: true};
|
36
37
|
Object.defineProperties(Opal.BasicObject.$$prototype, stubs_obj);
|
37
|
-
|
38
|
+
JAVASCRIPT
|
38
39
|
|
39
40
|
new_stub_code = parse_js(new_stub_code)
|
40
41
|
|
@@ -15,7 +15,7 @@ class TreeShaking < Step
|
|
15
15
|
corelib_calls["udef"] +
|
16
16
|
aliases.keys
|
17
17
|
|
18
|
-
method_calls = Set.new
|
18
|
+
method_calls = Set.new(['$method_missing'])
|
19
19
|
|
20
20
|
method_calls += ( function_calls + exports.function_calls ).map do |i|
|
21
21
|
out = if i.value_path?(DotAccessorNode) && i.value.accessor.start_with?("$")
|
@@ -25,7 +25,11 @@ class TreeShaking < Step
|
|
25
25
|
i.value.accessor.value[1] == '$'
|
26
26
|
i.value.accessor.value[1..-2]
|
27
27
|
elsif i.value_path?(ResolveNode, ->(i) { %w[$send $send2 $refined_send].include? i })
|
28
|
-
|
28
|
+
if i.value.value == '$send'
|
29
|
+
old = i.arguments.value[1]
|
30
|
+
else
|
31
|
+
old = i.arguments.value[2]
|
32
|
+
end
|
29
33
|
"$" + old.value[1..-2] if StringNode === old
|
30
34
|
end
|
31
35
|
|
@@ -80,7 +84,7 @@ class TreeShaking < Step
|
|
80
84
|
if opal_version >= 1.4
|
81
85
|
stubs = stubcall.arguments.value.first.value
|
82
86
|
new_stubs = stubs[1..-2].split(",").reject do |i|
|
83
|
-
removed.include? i
|
87
|
+
removed.include? i[1..-1]
|
84
88
|
end.join(',')
|
85
89
|
new_stubs = "'#{new_stubs}'"
|
86
90
|
stubs.replace(new_stubs)
|