@@ -34,21 +34,22 @@ def pin_all_from(dir, under: nil, to: nil, preload: false)
34
34
@directories [ dir ] = MappedDir . new ( dir : dir , under : under , path : to , preload : preload )
35
35
end
36
36
37
- # Returns an array of all the resolved module paths of the pinned packages. The `resolver` must respond to `asset_path`,
38
- # such as `ActionController::Base.helpers` or `ApplicationController.helpers`. You'll want to use the resolver that has
39
- # been configured for the `asset_host` you want these resolved paths to use. In case you need to resolve for different
40
- # asset hosts, you can pass in a custom `cache_key` to vary the cache used by this method for the different cases.
37
+ # Returns an array of all the resolved module paths of the pinned packages. The `resolver` must respond to
38
+ # `path_to_asset`, such as `ActionController::Base.helpers` or `ApplicationController.helpers`. You'll want to use the
39
+ # resolver that has been configured for the `asset_host` you want these resolved paths to use. In case you need to
40
+ # resolve for different asset hosts, you can pass in a custom `cache_key` to vary the cache used by this method for
41
+ # the different cases.
41
42
def preloaded_module_paths ( resolver :, cache_key : :preloaded_module_paths )
42
43
cache_as ( cache_key ) do
43
44
resolve_asset_paths ( expanded_preloading_packages_and_directories , resolver : resolver ) . values
44
45
end
45
46
end
46
47
47
48
# Returns a JSON hash (as a string) of all the resolved module paths of the pinned packages in the import map format.
48
- # The `resolver` must respond to `asset_path `, such as `ActionController::Base.helpers` or `ApplicationController.helpers`.
49
- # You'll want to use the resolver that has been configured for the `asset_host` you want these resolved paths to use.
50
- # In case you need to resolve for different asset hosts, you can pass in a custom `cache_key` to vary the cache used
51
- # by this method for the different cases.
49
+ # The `resolver` must respond to `path_to_asset `, such as `ActionController::Base.helpers` or
50
+ # `ApplicationController.helpers`. You'll want to use the resolver that has been configured for the `asset_host` you
51
+ # want these resolved paths to use. In case you need to resolve for different asset hosts, you can pass in a custom
52
+ # `cache_key` to vary the cache used by this method for the different cases.
52
53
def to_json ( resolver :, cache_key : :json )
53
54
cache_as ( cache_key ) do
54
55
JSON . pretty_generate ( { "imports" => resolve_asset_paths ( expanded_packages_and_directories , resolver : resolver ) } )
@@ -113,7 +114,7 @@ def rescuable_asset_error?(error)
113
114
def resolve_asset_paths ( paths , resolver :)
114
115
paths . transform_values do |mapping |
115
116
begin
116
- resolver . asset_path ( mapping . path )
117
+ resolver . path_to_asset ( mapping . path )
117
118
rescue => e
118
119
if rescuable_asset_error? ( e )
119
120
Rails . logger . warn "Importmap skipped missing path: #{ mapping . path } "
0 commit comments