DEV: avoid require_dependency for some libs

DEV: avoid require_dependency for some libs

This avoids require dependency on method_profiler and anon cache.

It means that if there is any change to these files the reloader will not pick it up.

Previously the reloader was picking up the anon cache twice causing it to double load on boot.

This caused warnings.

Long term my plan is to give up on require dependency and instead use:

GitHub - Shopify/autoload_reloader: Experimental implementation of code reloading using Ruby's autoload

diff --git a/config/initializers/099-anon-cache.rb b/config/initializers/099-anon-cache.rb
index 1b81655..9c47f36 100644
--- a/config/initializers/099-anon-cache.rb
+++ b/config/initializers/099-anon-cache.rb
@@ -1,4 +1,4 @@
-require_dependency "middleware/anonymous_cache"
+require "middleware/anonymous_cache"
 
 enabled =
   if Rails.configuration.respond_to?(:enable_anon_caching)
diff --git a/lib/hijack.rb b/lib/hijack.rb
index e064118..3fa4b72 100644
--- a/lib/hijack.rb
+++ b/lib/hijack.rb
@@ -1,6 +1,6 @@
 # frozen_string_literal: true
 
-require_dependency 'method_profiler'
+require 'method_profiler'
 
 # This module allows us to hijack a request and send it to the client in the deferred job queue
 # For cases where we are making remote calls like onebox or proxying files and so on this helps
diff --git a/lib/middleware/request_tracker.rb b/lib/middleware/request_tracker.rb
index 7bfcc64..71a1c67 100644
--- a/lib/middleware/request_tracker.rb
+++ b/lib/middleware/request_tracker.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
-require_dependency 'middleware/anonymous_cache'
-require_dependency 'method_profiler'
+require 'method_profiler'
+require 'middleware/anonymous_cache'
 
 class Middleware::RequestTracker

GitHub
sha: a19170a4

1 Like