shakapacker 6.2.0 → 6.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +44 -3
- data/CONTRIBUTING.md +2 -2
- data/Gemfile.lock +1 -1
- data/README.md +46 -14
- data/docs/deployment.md +2 -2
- data/docs/react.md +262 -0
- data/docs/troubleshooting.md +18 -0
- data/docs/v6_upgrade.md +3 -1
- data/lib/install/config/webpacker.yml +6 -0
- data/lib/tasks/webpacker/clean.rake +1 -3
- data/lib/tasks/webpacker/clobber.rake +1 -3
- data/lib/tasks/webpacker/compile.rake +1 -4
- data/lib/webpacker/base_strategy.rb +24 -0
- data/lib/webpacker/compiler.rb +4 -67
- data/lib/webpacker/compiler_strategy.rb +20 -0
- data/lib/webpacker/configuration.rb +14 -0
- data/lib/webpacker/digest_strategy.rb +59 -0
- data/lib/webpacker/helper.rb +26 -1
- data/lib/webpacker/instance.rb +4 -0
- data/lib/webpacker/manifest.rb +2 -2
- data/lib/webpacker/mtime_strategy.rb +40 -0
- data/lib/webpacker/version.rb +1 -1
- data/package/babel/preset.js +0 -1
- data/package/rules/file.js +2 -2
- data/package.json +12 -11
- data/test/compiler_strategy_test.rb +27 -0
- data/test/compiler_test.rb +26 -34
- data/test/configuration_test.rb +29 -4
- data/test/digest_strategy_test.rb +33 -0
- data/test/helper_test.rb +22 -0
- data/test/manifest_test.rb +3 -3
- data/test/mtime_strategy_test.rb +42 -0
- data/test/test_app/config/webpacker_no_precompile.yml +7 -0
- data/yarn.lock +917 -884
- metadata +16 -3
data/test/helper_test.rb
CHANGED
@@ -115,6 +115,28 @@ class HelperTest < ActionView::TestCase
|
|
115
115
|
javascript_pack_tag("application", "bootstrap", defer: false)
|
116
116
|
end
|
117
117
|
|
118
|
+
def test_javascript_pack_with_append
|
119
|
+
append_javascript_pack_tag("bootstrap", defer: false)
|
120
|
+
assert_equal \
|
121
|
+
%(<script src="/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js" defer="defer"></script>\n) +
|
122
|
+
%(<script src="/packs/vendors~application-e55f2aae30c07fb6d82a.chunk.js" defer="defer"></script>\n) +
|
123
|
+
%(<script src="/packs/application-k344a6d59eef8632c9d1.js" defer="defer"></script>\n) +
|
124
|
+
%(<script src="/packs/bootstrap-300631c4f0e0f9c865bc.js"></script>),
|
125
|
+
javascript_pack_tag("application")
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_append_javascript_pack_tag_raises
|
129
|
+
error = assert_raises do
|
130
|
+
javascript_pack_tag("application")
|
131
|
+
append_javascript_pack_tag("bootstrap", defer: false)
|
132
|
+
end
|
133
|
+
|
134
|
+
assert_equal \
|
135
|
+
"You can only call append_javascript_pack_tag before javascript_pack_tag helper. " +
|
136
|
+
"Please refer to https://github.com/shakacode/shakapacker/blob/master/README.md#usage for the usage guide",
|
137
|
+
error.message
|
138
|
+
end
|
139
|
+
|
118
140
|
def test_javascript_pack_tag_splat
|
119
141
|
assert_equal \
|
120
142
|
%(<script src="/packs/vendors~application~bootstrap-c20632e7baf2c81200d3.chunk.js" defer="defer"></script>\n) +
|
data/test/manifest_test.rb
CHANGED
@@ -8,7 +8,7 @@ class ManifestTest < Minitest::Test
|
|
8
8
|
Webpacker.manifest.lookup!(asset_file)
|
9
9
|
end
|
10
10
|
|
11
|
-
assert_match "
|
11
|
+
assert_match "Shakapacker can't find #{asset_file} in #{manifest_path}", error.message
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_lookup_with_type_exception!
|
@@ -18,7 +18,7 @@ class ManifestTest < Minitest::Test
|
|
18
18
|
Webpacker.manifest.lookup!(asset_file, type: :javascript)
|
19
19
|
end
|
20
20
|
|
21
|
-
assert_match "
|
21
|
+
assert_match "Shakapacker can't find #{asset_file}.js in #{manifest_path}", error.message
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_lookup_success!
|
@@ -60,7 +60,7 @@ class ManifestTest < Minitest::Test
|
|
60
60
|
Webpacker.manifest.lookup_pack_with_chunks!(asset_file, type: :javascript)
|
61
61
|
end
|
62
62
|
|
63
|
-
assert_match "
|
63
|
+
assert_match "Shakapacker can't find #{asset_file}.js in #{manifest_path}", error.message
|
64
64
|
end
|
65
65
|
|
66
66
|
def test_lookup_entrypoint
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class MtimeStrategyTest < Minitest::Test
|
4
|
+
def setup
|
5
|
+
@mtime_strategy = Webpacker::MtimeStrategy.new
|
6
|
+
@manifest_timestamp = Time.parse("2021-01-01 12:34:56 UTC")
|
7
|
+
end
|
8
|
+
|
9
|
+
def with_stubs(latest_timestamp:, manifest_exists: true)
|
10
|
+
@mtime_strategy.stub :latest_modified_timestamp, latest_timestamp do
|
11
|
+
FileTest.stub :exist?, manifest_exists do
|
12
|
+
File.stub :mtime, @manifest_timestamp do
|
13
|
+
yield
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_freshness_when_manifest_missing
|
20
|
+
latest_timestamp = @manifest_timestamp + 3600
|
21
|
+
|
22
|
+
with_stubs(latest_timestamp: latest_timestamp.to_i, manifest_exists: false) do
|
23
|
+
assert @mtime_strategy.stale?
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_freshness_when_manifest_older
|
28
|
+
latest_timestamp = @manifest_timestamp + 3600
|
29
|
+
|
30
|
+
with_stubs(latest_timestamp: latest_timestamp.to_i) do
|
31
|
+
assert @mtime_strategy.stale?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_freshness_when_manifest_newer
|
36
|
+
latest_timestamp = @manifest_timestamp - 3600
|
37
|
+
|
38
|
+
with_stubs(latest_timestamp: latest_timestamp.to_i) do
|
39
|
+
assert @mtime_strategy.fresh?
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|