importmap-rails 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +4 -5
- data/app/assets/javascripts/es-module-shims.js +836 -795
- data/app/assets/javascripts/es-module-shims.js.map +1 -1
- data/app/assets/javascripts/es-module-shims.min.js +1 -1
- data/lib/importmap/commands.rb +59 -0
- data/lib/importmap/map.rb +4 -12
- data/lib/importmap/npm.rb +113 -0
- data/lib/importmap/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af8555e15d3527fb4cfa9fe96e9b23c62b19ad49071ea52d7791340ba8667266
|
4
|
+
data.tar.gz: 5ad2c59b8d549a5afd05505c5d957343db6eeb09947d21b69e96f0e483c5f0dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c743d9f4de29b6cda4b32fa866d3e8b30cfde1f68c1122fb0a29e4fa0fc33108e40a3d5deb4ebd7389268d952de78011df6367c5ed301bc621b7547ad8c19304
|
7
|
+
data.tar.gz: e640cf67cdc9fffc259619baede7a3b2c9f6d37c94bebb251d55a2b572500e045e3e16596ab7f5bd08e3915210ed96440c907ae644e21a3425c1f2ca385b658f
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[Import maps](https://github.com/WICG/import-maps) let you import JavaScript modules using logical names that map to versioned/digested files – directly from the browser. So you can [build modern JavaScript applications using JavaScript libraries made for ES modules (ESM) without the need for transpiling or bundling](https://world.hey.com/dhh/modern-web-apps-without-javascript-bundling-or-transpiling-a20f2755). This frees you from needing Webpack, Yarn, npm, or any other part of the JavaScript toolchain. All you need is the asset pipeline that's already included in Rails.
|
4
4
|
|
5
|
-
With this approach you'll ship many small JavaScript files instead of one big JavaScript file. Thanks to HTTP/2 that no longer carries a material performance penalty during the initial transport, and in fact offers substantial benefits over the long run due to better caching dynamics. Whereas before any change to any JavaScript file included in your big bundle would invalidate the cache for the
|
5
|
+
With this approach you'll ship many small JavaScript files instead of one big JavaScript file. Thanks to HTTP/2 that no longer carries a material performance penalty during the initial transport, and in fact offers substantial benefits over the long run due to better caching dynamics. Whereas before any change to any JavaScript file included in your big bundle would invalidate the cache for the whole bundle, now only the cache for that single file is invalidated.
|
6
6
|
|
7
7
|
There's [native support for import maps in Chrome/Edge 89+](https://caniuse.com/?search=importmap), and [a shim available](https://github.com/guybedford/es-module-shims) for any browser with basic ESM support. So your app will be able to work with all the evergreen browsers.
|
8
8
|
|
@@ -11,9 +11,8 @@ There's [native support for import maps in Chrome/Edge 89+](https://caniuse.com/
|
|
11
11
|
|
12
12
|
Importmap for Rails is automatically included in Rails 7+ for new applications, but you can also install it manually in existing applications:
|
13
13
|
|
14
|
-
1.
|
15
|
-
2. Run `./bin/
|
16
|
-
3. Run `./bin/rails importmap:install`
|
14
|
+
1. Run `./bin/bundle add importmap-rails`
|
15
|
+
2. Run `./bin/rails importmap:install`
|
17
16
|
|
18
17
|
Note: In order to use JavaScript from Rails frameworks like Action Cable, Action Text, and Active Storage, you must be running Rails 7.0+. This was the first version that shipped with ESM compatible builds of these libraries.
|
19
18
|
|
@@ -251,7 +250,7 @@ Import your module on the specific page. Note: you'll likely want to use a `cont
|
|
251
250
|
<% end %>
|
252
251
|
```
|
253
252
|
|
254
|
-
**Important**: The `
|
253
|
+
**Important**: The `javascript_import_module_tag` should come after your `javascript_importmap_tags`
|
255
254
|
|
256
255
|
```erb
|
257
256
|
<%= javascript_importmap_tags %>
|