importmap-rails 0.4.3 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +94 -16
- data/app/assets/javascripts/es-module-shims.js +1 -1
- data/app/assets/javascripts/es-module-shims@0.14.0.csp.js +1635 -0
- data/app/helpers/importmap/importmap_tags_helper.rb +18 -7
- data/lib/importmap/commands.rb +45 -3
- data/lib/importmap/map.rb +1 -1
- data/lib/importmap/packager.rb +68 -0
- data/lib/importmap/version.rb +1 -1
- data/lib/install/config/importmap.rb +0 -4
- metadata +4 -18
- data/app/assets/javascripts/es-module-shims@0.12.8.js +0 -698
- data/lib/importmap/pinner.rb +0 -32
data/lib/importmap/pinner.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require "httparty"
|
2
|
-
|
3
|
-
class Importmap::Pinner
|
4
|
-
include HTTParty
|
5
|
-
base_uri "https://api.jspm.io"
|
6
|
-
|
7
|
-
def pin(*packages, env: "production", from: "jspm")
|
8
|
-
fetch_imports(*packages, env: env, provider: from)&.tap do |imports|
|
9
|
-
imports.each do |package, url|
|
10
|
-
append_to_importmap package, url
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
def append_to_importmap(package, url)
|
17
|
-
Rails.root.join("config/importmap.rb").open("a") do |config|
|
18
|
-
config.puts %(pin "#{package}", to: "#{url}")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def fetch_imports(*packages, env:, provider:)
|
23
|
-
response = self.class.post("/generate", body: {
|
24
|
-
"install" => Array(packages),
|
25
|
-
"flattenScope" => true,
|
26
|
-
"env" => [ "browser", "module", env ],
|
27
|
-
"provider" => provider.to_s
|
28
|
-
}.to_json)
|
29
|
-
|
30
|
-
response.dig("map", "imports")
|
31
|
-
end
|
32
|
-
end
|