Skip to content

Commit 8ca878e

Browse files
committed
Update JavaScript CDN section of README
1 parent d91d5e1 commit 8ca878e

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,29 @@ Note: Sprockets used to serve assets (albeit without filename digests) it couldn
9797

9898
Importmap for Rails downloads and vendors your npm package dependencies via JavaScript CDNs that provide pre-compiled distribution versions.
9999

100-
You can use the `./bin/importmap` command that's added as part of the install to pin, unpin, or update npm packages in your import map. This command uses an API from [JSPM.org](https://jspm.org) to resolve your package dependencies efficiently, and then add the pins to your `config/importmap.rb` file. It can resolve these dependencies from JSPM itself, but also from other CDNs, like [unpkg.com](https://unpkg.com) and [jsdelivr.com](https://www.jsdelivr.com).
100+
You can use the `./bin/importmap` command that's added as part of the install to pin, unpin, or update npm packages in your import map. By default this command uses an API from [JSPM.org](https://jspm.org) to resolve your package dependencies efficiently, and then add the pins to your `config/importmap.rb` file.
101101

102102
```bash
103103
./bin/importmap pin react
104-
Pinning "react" to vendor/react.js via download from https://ga.jspm.io/npm:[email protected]/index.js
105-
Pinning "object-assign" to vendor/object-assign.js via download from https://ga.jspm.io/npm:[email protected]/index.js
104+
Pinning "react" to vendor/javascript/react.js via download from https://ga.jspm.io/npm:[email protected]/index.js
106105
```
107106

108-
This will produce pins in your `config/importmap.rb` like so:
107+
This will produce a pin in your `config/importmap.rb` like so:
109108

110109
```ruby
111-
pin "react" # https://ga.jspm.io/npm:[email protected]/index.js
112-
pin "object-assign" # https://ga.jspm.io/npm:[email protected]/index.js
110+
pin "react" # @19.1.0
111+
```
112+
113+
Other CDNs like [unpkg.com](https://unpkg.com) and [jsdelivr.com](https://www.jsdelivr.com) can be specified with `--from`:
114+
115+
```bash
116+
./bin/importmap pin react --from unpkg
117+
Pinning "react" to vendor/javascript/react.js via download from https://unpkg.com/[email protected]/index.js
118+
```
119+
120+
```bash
121+
./bin/importmap pin react --from jsdelivr
122+
Pinning "react" to vendor/javascript/react.js via download from https://cdn.jsdelivr.net/npm/[email protected]/index.js
113123
```
114124

115125
The packages are downloaded to `vendor/javascript`, which you can check into your source control, and they'll be available through your application's own asset pipeline serving.
@@ -119,7 +129,6 @@ If you later wish to remove a downloaded pin:
119129
```bash
120130
./bin/importmap unpin react
121131
Unpinning and removing "react"
122-
Unpinning and removing "object-assign"
123132
```
124133

125134
## Preloading pinned modules

0 commit comments

Comments
 (0)