jekyll-esm 0.1.1 → 0.2.0

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: 874a4a2123da08d7db10936aa7c1ef9c0ad4bd4b40e1bbdba9c112c362834648
4
- data.tar.gz: 7eb4809d66b456733505bf68cbad740528c333a116bc8c15f05fe68884ed1b5f
3
+ metadata.gz: 1afb8eff9885f0d3929ec26e1e8453171c9e3ce80cbc324636aaa4e0560fd5a3
4
+ data.tar.gz: d3839dd0821dfc36e51f5e67e4b3560a1b3e50c2d73bb8385a08c371bfe21d79
5
5
  SHA512:
6
- metadata.gz: e80869a7324675efcec4ee35c88dc8fba77f82f4068a30aee3aa896e512bc2db17eaa3bce7c736f6ad26ec44bc7ff1ceeae1c3c57a4e452c3352687e8298a676
7
- data.tar.gz: 3929653faeb53d75ea0754f48dbdacd39c8e2f59b2f0defbccdfdda323e4328b3021542af40055c4865fa5b0dbe7ea1a8e6759a7fa9b6c051825c60822ffa2c9
6
+ metadata.gz: 044f9722e1c7f6a4a8e56e0cbf451ac2648ecc8fd27c342e3862b24641c9f6a8a86a74c8c8e8b62d18e9289ed527b5b36f44fa039e70686e24fdc8c175b27ccb
7
+ data.tar.gz: 4fbe841607df6d91039683482ffd7a06eb01153a51cead4e5ec826970438919afcd7b4565d59bbf749ef0b88588d7ddbe9630d85ed7ceee358426726c5433dc1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jekyll-esm (0.1.1)
4
+ jekyll-esm (0.2.0)
5
5
  jekyll
6
6
  listen
7
7
  nokogiri
data/README.md CHANGED
@@ -41,9 +41,17 @@ plugins:
41
41
  - jekyll/esm
42
42
  ```
43
43
 
44
+ # Ingore package.json!
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
+
47
+ ```yml
48
+ exclude:
49
+ - package.json
50
+ ```
51
+
44
52
  ### Example `_config.yml`
45
- You can have a look at the possible configuration options in the fixtures config file at `spec/fixtures/_config.yml` in this repo.
46
53
 
54
+ You can have a look at the possible configuration options in the fixtures config file at `spec/fixtures/_config.yml` in this repo.
47
55
 
48
56
  ## Development
49
57
 
data/lib/jekyll/esm.rb CHANGED
@@ -23,11 +23,14 @@ module Jekyll
23
23
  importmap = JSON.parse(value.children[0].content)
24
24
  imports = importmap["imports"]
25
25
  imports.keys.each do |import_key|
26
+ next if import_key =~ /https?:\/\/[\S]+/
27
+ next if import_key =~ /(^\.+\/)+/
28
+
26
29
  import = import_key.split('/').first
27
30
  pkg_path = File.join(page.site.source, 'node_modules', import)
28
31
 
29
32
  # don't repeatedly attempt to install a package
30
- return if Dir.exists?(pkg_path) && @@new_esm_packages.include?(import)
33
+ next if Dir.exists?(pkg_path) && @@new_esm_packages.include?(import)
31
34
 
32
35
  @@new_esm_packages << import
33
36
 
@@ -47,25 +50,28 @@ module Jekyll
47
50
  end
48
51
 
49
52
  def self.apply(site)
50
- existing_packages = Dir.children(File.join(site.source, 'node_modules')).reject { |dir| dir =~ /^\..*$/ }
51
- for_removal = existing_packages - @@new_esm_packages.uniq
53
+ if @@existing_esm_packages.any?
54
+ for_removal = @@existing_esm_packages - @@new_esm_packages.uniq
52
55
 
53
- # Remove any packages that are no longer referenced in an esm declaration
54
- if for_removal.any?
55
- stdout, stderr, status = Open3.capture3(
56
- "yarn remove #{for_removal.join(' ')}",
57
- chdir: File.expand_path(site.source)
58
- )
56
+ # Remove any packages that are no longer referenced in an esm declaration
57
+ if for_removal.any?
58
+ stdout, stderr, status = Open3.capture3(
59
+ "yarn remove #{for_removal.join(' ')}",
60
+ chdir: File.expand_path(site.source)
61
+ )
59
62
 
60
- if site.config.dig('esm', 'strict')
61
- runtime_error = stdout =~ /ERROR in|SyntaxError/
63
+ if site.config.dig('esm', 'strict')
64
+ runtime_error = stdout =~ /ERROR in|SyntaxError/
62
65
 
63
- raise Error, stderr if stderr.size > 0
64
- raise Error, stdout if !runtime_error.nil?
66
+ raise Error, stderr if stderr.size > 0
67
+ raise Error, stdout if !runtime_error.nil?
68
+ end
65
69
  end
66
70
  end
67
71
 
72
+ FileUtils.rm_rf(File.join(site.dest, 'node_modules'))
68
73
  FileUtils.cp_r(File.join(site.source, 'node_modules'), File.join(site.dest, 'node_modules'))
74
+ @@existing_esm_packages = @@new_esm_packages
69
75
  @@new_esm_packages = []
70
76
  end
71
77
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Esm
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
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.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Martin