Add option to `bin/importmap pin URL` to create direct/remote link without downloading
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:
https://github.com/rails/importmap-rails/blob/ddf9be434e0aca1103eabafe6d34b0e8a5064057/lib/importmap/commands.rb#L15-L19
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.rbfile. - 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.