11# frozen_string_literal: true 
22
3+ require  "shakapacker" 
4+ 
35module  ReactOnRails 
46  module  PackerUtils 
5-     def  self . packer 
6-       @packer  ||= begin 
7-         require  "shakapacker" 
8-         ::Shakapacker 
9-       end 
10-     end 
11- 
127    def  self . dev_server_running? 
13-       packer . dev_server . running? 
8+       Shakapacker . dev_server . running? 
149    end 
1510
1611    def  self . dev_server_url 
17-       "#{ packer . dev_server . protocol } #{ packer . dev_server . host_with_port }  
12+       "#{ Shakapacker . dev_server . protocol } #{ Shakapacker . dev_server . host_with_port }  
1813    end 
1914
2015    def  self . shakapacker_version 
@@ -47,14 +42,14 @@ def self.supports_basic_pack_generation?
4742
4843    def  self . supports_autobundling? 
4944      min_version  =  ReactOnRails ::PacksGenerator ::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_REGISTRATION 
50-       packer . config . respond_to? ( :nested_entries? )  && shakapacker_version_requirement_met? ( min_version ) 
45+       :: Shakapacker . config . respond_to? ( :nested_entries? )  && shakapacker_version_requirement_met? ( min_version ) 
5146    end 
5247
5348    # This returns either a URL for the webpack-dev-server, non-server bundle or 
5449    # the hashed server bundle if using the same bundle for the client. 
5550    # Otherwise returns a file path. 
5651    def  self . bundle_js_uri_from_packer ( bundle_name ) 
57-       hashed_bundle_name  =  packer . manifest . lookup! ( bundle_name ) 
52+       hashed_bundle_name  =  :: Shakapacker . manifest . lookup! ( bundle_name ) 
5853
5954      # Support for hashing the server-bundle and having that built 
6055      # the webpack-dev-server is provided by the config value 
@@ -63,7 +58,7 @@ def self.bundle_js_uri_from_packer(bundle_name)
6358      is_bundle_running_on_server  =  ( bundle_name  == ReactOnRails . configuration . server_bundle_js_file )  ||
6459                                    ( bundle_name  == ReactOnRails . configuration . rsc_bundle_js_file ) 
6560
66-       if  packer . dev_server . running?  && ( !is_bundle_running_on_server  ||
61+       if  :: Shakapacker . dev_server . running?  && ( !is_bundle_running_on_server  ||
6762        ReactOnRails . configuration . same_bundle_for_client_and_server ) 
6863        "#{ dev_server_url } #{ hashed_bundle_name }  
6964      else 
@@ -72,7 +67,7 @@ def self.bundle_js_uri_from_packer(bundle_name)
7267    end 
7368
7469    def  self . public_output_uri_path 
75-       "#{ packer . config . public_output_path . relative_path_from ( packer . config . public_path ) }  
70+       "#{ :: Shakapacker . config . public_output_path . relative_path_from ( :: Shakapacker . config . public_path ) }  
7671    end 
7772
7873    # The function doesn't ensure that the asset exists. 
@@ -91,36 +86,36 @@ def self.precompile?
9186    end 
9287
9388    def  self . packer_source_path 
94-       packer . config . source_path 
89+       :: Shakapacker . config . source_path 
9590    end 
9691
9792    def  self . packer_source_entry_path 
98-       packer . config . source_entry_path 
93+       :: Shakapacker . config . source_entry_path 
9994    end 
10095
10196    def  self . nested_entries? 
102-       packer . config . nested_entries? 
97+       :: Shakapacker . config . nested_entries? 
10398    end 
10499
105100    def  self . packer_public_output_path 
106-       packer . config . public_output_path . to_s 
101+       :: Shakapacker . config . public_output_path . to_s 
107102    end 
108103
109104    def  self . manifest_exists? 
110-       packer . config . public_manifest_path . exist? 
105+       :: Shakapacker . config . public_manifest_path . exist? 
111106    end 
112107
113108    def  self . packer_source_path_explicit? 
114-       packer . config . send ( :data ) [ :source_path ] . present? 
109+       :: Shakapacker . config . send ( :data ) [ :source_path ] . present? 
115110    end 
116111
117112    def  self . check_manifest_not_cached 
118-       return  unless  packer . config . cache_manifest? 
113+       return  unless  :: Shakapacker . config . cache_manifest? 
119114
120115      msg  =  <<-MSG . strip_heredoc 
121116          ERROR: you have enabled cache_manifest in the #{ Rails . env }  
122117          ReactOnRails::TestHelper.configure_rspec_to_compile_assets helper 
123-           To fix this: edit your config/shakapacker .yml file and set cache_manifest to false for test. 
118+           To fix this: edit your config/shaka::Shakapacker .yml file and set cache_manifest to false for test. 
124119      MSG 
125120      puts  wrap_message ( msg ) 
126121      exit! 
@@ -140,8 +135,8 @@ def self.webpack_assets_status_checker
140135
141136    def  self . raise_nested_entries_disabled 
142137      msg  =  <<~MSG 
143-         **ERROR** ReactOnRails: `nested_entries` is configured to be disabled in shakapacker . Please update \  
144- shakapacker .yml to enable nested entries. for more information read
138+         **ERROR** ReactOnRails: `nested_entries` is configured to be disabled in shaka::Shakapacker . Please update \  
139+ shaka::Shakapacker .yml to enable nested entries. for more information read
145140        https://www.shakacode.com/react-on-rails/docs/guides/file-system-based-automated-bundle-generation.md#enable-nested_entries-for-shakapacker 
146141      MSG 
147142
@@ -150,18 +145,18 @@ def self.raise_nested_entries_disabled
150145
151146    def  self . raise_shakapacker_version_incompatible_for_autobundling 
152147      msg  =  <<~MSG 
153-         **ERROR** ReactOnRails: Please upgrade Shakapacker to version #{ ReactOnRails ::PacksGenerator ::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_REGISTRATION } \  
148+         **ERROR** ReactOnRails: Please upgrade :: Shakapacker to version #{ ReactOnRails ::PacksGenerator ::MINIMUM_SHAKAPACKER_VERSION_FOR_AUTO_REGISTRATION } \  
154149\ 
155150#{ ReactOnRails ::PackerUtils . shakapacker_version } \ 
156- #{ ReactOnRails ::PacksGenerator ::MINIMUM_SHAKAPACKER_VERSION } 
151+ :: Shakapacker #{ ReactOnRails ::PacksGenerator ::MINIMUM_SHAKAPACKER_VERSION } 
157152      MSG 
158153
159154      raise  ReactOnRails ::Error ,  msg 
160155    end 
161156
162157    def  self . raise_shakapacker_version_incompatible_for_basic_pack_generation 
163158      msg  =  <<~MSG 
164-         **ERROR** ReactOnRails: Please upgrade Shakapacker to version #{ ReactOnRails ::PacksGenerator ::MINIMUM_SHAKAPACKER_VERSION } \  
159+         **ERROR** ReactOnRails: Please upgrade :: Shakapacker to version #{ ReactOnRails ::PacksGenerator ::MINIMUM_SHAKAPACKER_VERSION } \  
165160#{ ReactOnRails ::PackerUtils . shakapacker_version } 
166161      MSG 
167162
@@ -170,7 +165,7 @@ def self.raise_shakapacker_version_incompatible_for_basic_pack_generation
170165
171166    def  self . raise_shakapacker_not_installed 
172167      msg  =  <<~MSG 
173-         **ERROR** ReactOnRails: Missing Shakapacker gem. Please upgrade to use Shakapacker \  
168+         **ERROR** ReactOnRails: Missing :: Shakapacker gem. Please upgrade to use :: Shakapacker \  
174169#{ ReactOnRails ::PacksGenerator ::MINIMUM_SHAKAPACKER_VERSION } \ 
175170
176171      MSG 
0 commit comments