Description
It's currently possible to "manually" add a URL to config/importmap.rb
that will not attempt to be locally cached e.g.
# config/importmap.rb
pin "some-package", to: "https://someotherhost.com/some-package.js"
...but there isn't currently a way to add that entry through the $ bin/importmap pin
command because it will always attempt to download and vendor the file through jspm:
importmap-rails/lib/importmap/commands.rb
Lines 15 to 19 in ddf9be4
This Issue proposes an option for adding a new entry using bin/importmap pin
that will not be downloaded and maintain the direct URL:
bin/importmap pin https://mycdn.com/some-package.js --from direct
Update: Thinking some more about this, I wonder if when using the CLI pin
command, merely passing a value that starts with http[s]://
would result in the direct mode.
Update2: Oops, I overlooked the change where pin
is now synonymous with vendoring the library. I think maybe I have two thoughts now on this:
- The behavior of providing a static URL does still seem to work when added to the
config/importmap.rb
file. - The use-case behind this is a desire to use my own js libraries that are served from their own remote host and are available upon multiple websites/projects and I'd like to update/manage them remotely without vendoring/updating/managing them within multiple individual Rails apps. Unfortunately browser imports only allow a single
<script type="importmap"> ...
tag per HTML page, which means that all importmap definitions would need to go through a single helper.