jekyll-esm 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +26 -1
- data/lib/jekyll/esm.rb +6 -0
- data/lib/jekyll/esm/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2fc1ecabf3be2949cece5c1bb60e7285fd273da8b8bbce30f2bf2f28d2117ed
|
4
|
+
data.tar.gz: 03021cb0dcfe320ff0861f1d2ffdf44cc2f839827d1c9b7812fce47511f6f737
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91ea6cf5552e9d4e888229cd5b47c53e1317985f99fcfa4b14893eb2a08d3eeedff0665e35ff2cb0ad10e6479e4109183f17bce81bdc0de4640fd66e3d58de78
|
7
|
+
data.tar.gz: a755d7b58b87571896041a2f095014bb360077663c68c4f70038dbf76a54ed67858ebeac2214f54b48722a19a16560ffce7c45d5441e77f68fd8dade5a4e8768
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -41,7 +41,7 @@ plugins:
|
|
41
41
|
- jekyll/esm
|
42
42
|
```
|
43
43
|
|
44
|
-
#
|
44
|
+
# Ignore package.json!
|
45
45
|
Currently You *MUST* exclude package.json in the `_config.yml` otherwise jekyll will go into a loop. Sucks a bit but will try and improve that.
|
46
46
|
|
47
47
|
```yml
|
@@ -49,6 +49,31 @@ exclude:
|
|
49
49
|
- package.json
|
50
50
|
```
|
51
51
|
|
52
|
+
## Optimizing
|
53
|
+
### Strict mode
|
54
|
+
You can run in strict mode to increase logging verbosity from the js package manager.
|
55
|
+
|
56
|
+
``` yml
|
57
|
+
# _config.yml
|
58
|
+
|
59
|
+
esm:
|
60
|
+
strict: true
|
61
|
+
```
|
62
|
+
|
63
|
+
### data-esm-id attribute
|
64
|
+
You can set this on a declaration to prevent Jekyll from processing it more than once (eg, if you have lots of compiled pages, with the same layout, you don't want to run it more than once per importmap declaration):-
|
65
|
+
|
66
|
+
``` html
|
67
|
+
<script data-esm-id='1' type="importmap">
|
68
|
+
{
|
69
|
+
"imports": {
|
70
|
+
"/src/index.js": "/src/index.js"
|
71
|
+
}
|
72
|
+
}
|
73
|
+
</script>
|
74
|
+
|
75
|
+
If you have multiple importmap declarations with different values, set a different id for each one, or no id at all, but no id is less speed efficient, as jekyll will process them each time for every page.
|
76
|
+
|
52
77
|
### Example `_config.yml`
|
53
78
|
|
54
79
|
You can have a look at the possible configuration options in the fixtures config file at `spec/fixtures/_config.yml` in this repo.
|
data/lib/jekyll/esm.rb
CHANGED
@@ -11,6 +11,7 @@ module Jekyll
|
|
11
11
|
module Esm
|
12
12
|
@@existing_esm_packages = []
|
13
13
|
@@new_esm_packages = []
|
14
|
+
@@esm_ids = []
|
14
15
|
|
15
16
|
class Error < StandardError; end
|
16
17
|
|
@@ -20,6 +21,11 @@ module Jekyll
|
|
20
21
|
import_maps = doc.search('script[type=importmap]')
|
21
22
|
|
22
23
|
import_maps.each do |value|
|
24
|
+
esm_id = value.attributes["data-esm-id"]&.value
|
25
|
+
# declare a data-esm-id so that jekyll will only process an esm declaration once
|
26
|
+
next if @@esm_ids.include?(esm_id)
|
27
|
+
@@esm_ids << esm_id if esm_id
|
28
|
+
|
23
29
|
importmap = JSON.parse(value.children[0].content)
|
24
30
|
imports = importmap["imports"]
|
25
31
|
imports.keys.each do |import_key|
|
data/lib/jekyll/esm/version.rb
CHANGED