Skip to content

Commit ea8810e

Browse files
committed
Handle manifest load
1 parent d1e665e commit ea8810e

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

lib/generators/react/install_generator.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ def setup_react_webpacker
114114

115115
def webpack_source_path
116116
if Webpacker.respond_to?(:config)
117-
Webpacker.config.source_entry_path
117+
Webpacker.config.source_entry_path # Webpacker >3
118118
else
119-
Webpacker::Configuration.source_path.join(Webpacker::Configuration.entry_path)
119+
Webpacker::Configuration.source_path.join(Webpacker::Configuration.entry_path) # Webpacker <3
120120
end
121121
end
122122
end

test/support/webpacker_helpers.rb

+24-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def compile
2222
end
2323
end
2424
# Reload cached JSON manifest:
25-
manifest.load
25+
manifest_refresh
2626
end
2727

2828
def compile_if_missing
@@ -35,8 +35,28 @@ def clear_webpacker_packs
3535
FileUtils.rm_rf(PACKS_DIRECTORY)
3636
end
3737

38+
def manifest_refresh
39+
if Webpacker.respond_to?(:manifest)
40+
Webpacker.manifest.refresh
41+
else
42+
Webpacker::Manifest.load
43+
end
44+
end
45+
46+
def manifest_lookup name
47+
if Webpacker.respond_to?(:manifest)
48+
Webpacker.manifest.lookup(name)
49+
else
50+
Webpacker::Manifest.load(name)
51+
end
52+
end
53+
3854
def manifest
39-
Webpacker.respond_to?(:manifest) ? Webpacker.manifest : Webpacker::Manifest
55+
if Webpacker.respond_to?(:manifest)
56+
Webpacker.manifest
57+
else
58+
Webpacker::Manifest
59+
end
4060
end
4161

4262
# Start a webpack-dev-server
@@ -54,8 +74,8 @@ def with_dev_server
5474
30.times do |i|
5575
begin
5676
# Make sure that the manifest has been updated:
57-
manifest.load("./test/dummy/public/packs/manifest.json")
58-
webpack_manifest = manifest.instance.data
77+
manifest_lookup("./test/dummy/public/packs/manifest.json")
78+
webpack_manifest = manifest.data
5979
example_asset_path = webpack_manifest.values.first
6080
if example_asset_path.nil?
6181
# Debug helper

0 commit comments

Comments
 (0)