Skip to content

Commit cbf36d0

Browse files
authored
Make a few improvements to the README (#41)
1 parent a2e5632 commit cbf36d0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Pinning "scheduler" to https://ga.jspm.io/npm:[email protected]/index.js
4848

4949
{
5050
"imports": {
51-
"application": "/application.js",
51+
"application": "/assets/application-37f365cbecf1fa2810a8303f4b6571676fa1f9c56c248528bc14ddb857531b95.js",
5252
"react": "https://ga.jspm.io/npm:[email protected]/index.js",
5353
"react-dom": "https://ga.jspm.io/npm:[email protected]/index.js",
5454
"object-assign": "https://ga.jspm.io/npm:[email protected]/index.js",
@@ -169,9 +169,9 @@ pin_all_from File.expand_path("../app/assets/javascripts", __dir__)
169169
```
170170

171171

172-
## Include a digest of the import map in your etag
172+
## Include a digest of the import map in your ETag
173173

174-
If you're using etags generated by Rails helpers like `stale?` or `fresh_when`, you need to include the digest of the import map into this calculation. Otherwise your application will return 302 cache responses even when your JavaScript assets have changed. You can avoid this with something like:
174+
If you're using [ETags](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) generated by Rails helpers like `stale?` or `fresh_when`, you need to include the digest of the import map into this calculation. Otherwise your application will return 302 cache responses even when your JavaScript assets have changed. You can avoid this with something like:
175175

176176
```ruby
177177
class ApplicationController < ActionController::Base
@@ -182,7 +182,7 @@ end
182182

183183
## Sweeping the cache in development and test
184184

185-
Generating the import map json and modulepreloads may require resolving hundreds of assets. This can take a while, so these operations are cached, but in development and test, we watch for changes to both `config/importmap.rb` and files in `app/javascript` to clear this cache. This feature can be controlled in an environment configuration file via the boolean `config.importmap.sweep_cache`. If you're pinning local files from outside of `app/javascript`, you'll need to restart your development server upon changes.
185+
Generating the import map json and modulepreloads may require resolving hundreds of assets. This can take a while, so these operations are cached, but in development and test, we watch for changes to both `config/importmap.rb` and files in `app/javascript` to clear this cache. This feature can be controlled in an environment configuration file via the boolean `config.importmap.sweep_cache`. If you're pinning local files from outside of `app/javascript`, you'll need to restart your development server upon changes to those external files.
186186

187187

188188
## Expected errors from using the es-module-shim
@@ -192,12 +192,12 @@ While import maps are native in Chrome and Edge, they need a shim in other brows
192192

193193
## Turning off the shim
194194

195-
Under certain circumstances, like running system tests using chromedriver under CI (which may be resource constrained and trigger errors in certain cases), you may want to explicitly turn off including the shim. If can do this by calling the bulk tag helper with `javascript_importmap_tags("application", shim: false)`. Thus you can pass in something like `shim: !ENV["CI"]`. If you want, and are sure you're not doing any full-page caching, you can also connect this directive to a user agent check (using a gem like `useragent`) to check whether the browser is chrome/edge 89+. But you really shouldn't have to, as the shim is designed to gracefully work with natively compatible drivers.
195+
Under certain circumstances, like running system tests using chromedriver under CI (which may be resource constrained and trigger errors in certain cases), you may want to explicitly turn off including the shim. You can do this by calling the bulk tag helper with `javascript_importmap_tags("application", shim: false)`. Thus you can pass in something like `shim: !ENV["CI"]`. If you want, and are sure you're not doing any full-page caching, you can also connect this directive to a user agent check (using a gem like `useragent`) to check whether the browser is chrome/edge 89+. But you really shouldn't have to, as the shim is designed to gracefully work with natively compatible drivers.
196196

197197

198198
## A note about browser extensions
199199

200-
Certain extensions that also load Javascript modules may block import maps from being loaded (for instance, the Apollo Client Devtools extension). If you see a console message like `An import map is added after module script load was triggered`, browser extensions are likely the culprit.
200+
Certain extensions that also load JavaScript modules may block import maps from being loaded (for instance, the Apollo Client Devtools extension). If you see a console message like `An import map is added after module script load was triggered`, browser extensions are likely the culprit.
201201

202202

203203
## License

0 commit comments

Comments
 (0)