@@ -8,6 +8,9 @@ def setup
8
8
pin "editor" , to : "rich_text.js" , preload : false
9
9
pin "not_there" , to : "nowhere.js" , preload : false
10
10
pin "md5" , to : "https://cdn.skypack.dev/md5" , preload : true
11
+ pin "leaflet" , to : "https://cdn.skypack.dev/leaflet" , preload : 'application'
12
+ pin "chartkick" , to : "https://cdn.skypack.dev/chartkick" , preload : [ 'application' , 'alternate' ]
13
+ pin "tinyMCE" , to : "https://cdn.skypack.dev/tinymce" , preload : 'alternate'
11
14
12
15
pin_all_from "app/javascript/controllers" , under : "controllers" , preload : true
13
16
pin_all_from "app/javascript/spina/controllers" , under : "controllers/spina" , preload : true
@@ -78,10 +81,32 @@ def setup
78
81
end
79
82
end
80
83
81
- test "preloaded modules are included in preload tags" do
84
+ test "preloaded modules are included in preload tags when no entry_point specified " do
82
85
preloading_module_paths = @importmap . preloaded_module_paths ( resolver : ApplicationController . helpers ) . to_s
83
86
assert_match /md5/ , preloading_module_paths
84
87
assert_match /goodbye_controller/ , preloading_module_paths
88
+ assert_match /leaflet/ , preloading_module_paths
89
+ assert_no_match /application/ , preloading_module_paths
90
+ assert_no_match /tinymce/ , preloading_module_paths
91
+ end
92
+
93
+ test "preloaded modules are included in preload tags based on single entry_point provided" do
94
+ preloading_module_paths = @importmap . preloaded_module_paths ( resolver : ApplicationController . helpers , entry_point : "alternate" ) . to_s
95
+ assert_no_match /leaflet/ , preloading_module_paths
96
+ assert_match /tinymce/ , preloading_module_paths
97
+ assert_match /chartkick/ , preloading_module_paths
98
+ assert_match /md5/ , preloading_module_paths
99
+ assert_match /goodbye_controller/ , preloading_module_paths
100
+ assert_no_match /application/ , preloading_module_paths
101
+ end
102
+
103
+ test "preloaded modules are included in preload tags based on multiple entry_points provided" do
104
+ preloading_module_paths = @importmap . preloaded_module_paths ( resolver : ApplicationController . helpers , entry_point : [ "application" , "alternate" ] ) . to_s
105
+ assert_match /leaflet/ , preloading_module_paths
106
+ assert_match /tinymce/ , preloading_module_paths
107
+ assert_match /chartkick/ , preloading_module_paths
108
+ assert_match /md5/ , preloading_module_paths
109
+ assert_match /goodbye_controller/ , preloading_module_paths
85
110
assert_no_match /application/ , preloading_module_paths
86
111
end
87
112
0 commit comments