jekyll-esm 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +9 -1
- data/lib/jekyll/esm.rb +19 -13
- 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: 1afb8eff9885f0d3929ec26e1e8453171c9e3ce80cbc324636aaa4e0560fd5a3
|
4
|
+
data.tar.gz: d3839dd0821dfc36e51f5e67e4b3560a1b3e50c2d73bb8385a08c371bfe21d79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 044f9722e1c7f6a4a8e56e0cbf451ac2648ecc8fd27c342e3862b24641c9f6a8a86a74c8c8e8b62d18e9289ed527b5b36f44fa039e70686e24fdc8c175b27ccb
|
7
|
+
data.tar.gz: 4fbe841607df6d91039683482ffd7a06eb01153a51cead4e5ec826970438919afcd7b4565d59bbf749ef0b88588d7ddbe9630d85ed7ceee358426726c5433dc1
|
data/Gemfile.lock
CHANGED
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
|
-
|
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
|
-
|
51
|
-
|
53
|
+
if @@existing_esm_packages.any?
|
54
|
+
for_removal = @@existing_esm_packages - @@new_esm_packages.uniq
|
52
55
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
-
|
61
|
-
|
63
|
+
if site.config.dig('esm', 'strict')
|
64
|
+
runtime_error = stdout =~ /ERROR in|SyntaxError/
|
62
65
|
|
63
|
-
|
64
|
-
|
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
|
data/lib/jekyll/esm/version.rb
CHANGED