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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 74695e12430d39bfeac7225359f66bc2abf14eaf1d71c962486facb6185d6eb3
4
- data.tar.gz: 23710c8c7adda15a3bbf44f87be1645b94c2feb7e2ada6a8a490133dec71da12
3
+ metadata.gz: a2fc1ecabf3be2949cece5c1bb60e7285fd273da8b8bbce30f2bf2f28d2117ed
4
+ data.tar.gz: 03021cb0dcfe320ff0861f1d2ffdf44cc2f839827d1c9b7812fce47511f6f737
5
5
  SHA512:
6
- metadata.gz: affbdc5ba825c5e95b2ed17c513d7d157acf12143a768d73486db3ef8fb502154beabaaa12a2807b9a0b79718dbb97d0c5a35cb23fce6364094c86fe0c417057
7
- data.tar.gz: 4f24b237f2d43f8b9a68aea193137ec3910d53448cefe3a00ea72a7f7ade3915e0513ea6ed19c3a6b8e7dbd17346439f03a228530aa3e9fbd2d1442364bf1b56
6
+ metadata.gz: 91ea6cf5552e9d4e888229cd5b47c53e1317985f99fcfa4b14893eb2a08d3eeedff0665e35ff2cb0ad10e6479e4109183f17bce81bdc0de4640fd66e3d58de78
7
+ data.tar.gz: a755d7b58b87571896041a2f095014bb360077663c68c4f70038dbf76a54ed67858ebeac2214f54b48722a19a16560ffce7c45d5441e77f68fd8dade5a4e8768
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jekyll-esm (0.2.0)
4
+ jekyll-esm (0.2.2)
5
5
  jekyll
6
6
  listen
7
7
  nokogiri
data/README.md CHANGED
@@ -41,7 +41,7 @@ plugins:
41
41
  - jekyll/esm
42
42
  ```
43
43
 
44
- # Ingore package.json!
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|
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Esm
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-esm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Martin