File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,13 @@ module JS
3737 # rescue LoadError
3838 # JS::RequireRemote.instance.load(path)
3939 # end
40- # end
40+ # end
41+ #
42+ # You can also load included shim to achieve the same.
43+ #
44+ # == Example
45+ #
46+ # require 'js/require_remote/relative_shim'
4147 #
4248 class RequireRemote
4349 include Singleton
Original file line number Diff line number Diff line change 1+ require 'js/require_remote'
2+
3+ module Kernel
4+ alias original_require_relative require_relative
5+
6+ def require_relative ( path )
7+ caller_path = caller_locations ( 1 , 1 ) . first . absolute_path || ''
8+ dir = File . dirname ( caller_path )
9+ file = File . absolute_path ( path , dir )
10+
11+ original_require_relative ( file )
12+ rescue LoadError
13+ JS ::RequireRemote . instance . load ( path )
14+ end
15+ end
You can’t perform that action at this time.
0 commit comments