@@ -32,14 +32,23 @@ def pin_all_from(dir, under: nil, to: nil, preload: false)
32
32
@directories [ dir ] = MappedDir . new ( dir : dir , under : under , path : to , preload : preload )
33
33
end
34
34
35
- def preloaded_module_paths ( resolver :)
36
- cache_as ( :preloaded_module_paths ) do
35
+ # Returns an array of all the resolved module paths of the pinned packages. The `resolver` must respond to `asset_path`,
36
+ # such as `ActionController::Base.helpers` or `ApplicationController.helpers`. You'll want to use the resolver that has
37
+ # been configured for the `asset_host` you want these resolved paths to use. In case you need to resolve for different
38
+ # asset hosts, you can pass in a custom `cache_key` to vary the cache used by this method for the different cases.
39
+ def preloaded_module_paths ( resolver :, cache_key : :preloaded_module_paths )
40
+ cache_as ( cache_key ) do
37
41
resolve_asset_paths ( expanded_preloading_packages_and_directories , resolver : resolver ) . values
38
42
end
39
43
end
40
44
41
- def to_json ( resolver :)
42
- cache_as ( :json ) do
45
+ # Returns a JSON hash (as a string) of all the resolved module paths of the pinned packages in the import map format.
46
+ # The `resolver` must respond to `asset_path`, such as `ActionController::Base.helpers` or `ApplicationController.helpers`.
47
+ # You'll want to use the resolver that has been configured for the `asset_host` you want these resolved paths to use.
48
+ # In case you need to resolve for different asset hosts, you can pass in a custom `cache_key` to vary the cache used
49
+ # by this method for the different cases.
50
+ def to_json ( resolver :, cache_key : :json )
51
+ cache_as ( cache_key ) do
43
52
JSON . pretty_generate ( { "imports" => resolve_asset_paths ( expanded_packages_and_directories , resolver : resolver ) } )
44
53
end
45
54
end
0 commit comments