svelte-on-rails 1.0.10 → 1.0.12
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/README.md +12 -9
- data/lib/svelte_on_rails/lib/utils.rb +29 -4
- 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: 89b585de2264458769d479f27bcadc4080a8984b23e916cccd5d07876a30ea24
|
4
|
+
data.tar.gz: 7255f6af6ee943e809b24ba6551730e05dd21b8279555c677f7be2346d47a0f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3557343363ea9f1776a6766eadcb97a3d8e6376ac069b1daa764cd77aa87a2f04614c91f3ed0b9d16a549b4ca7651ad82716d4b2374fc222c6d649d1e1c538c3
|
7
|
+
data.tar.gz: 4f301fb16a422e682e75ca9ebf09a207474346ff973140191d8e92226bc9b284c04eaa3c3662f6745b83637b6db83752c8b5b4dcfa35deaec71eaa0d0ad1d973
|
data/README.md
CHANGED
@@ -34,6 +34,10 @@ This all fits perfectly with the Rails way of minimalist javascript, but: Where
|
|
34
34
|
- 🤝 fully integrated with `assets:precompile`
|
35
35
|
- 🚀 cero-config deployment
|
36
36
|
|
37
|
+
# Known Issues
|
38
|
+
|
39
|
+
see [issues](https://gitlab.com/sedl/svelte-on-rails/-/issues)
|
40
|
+
|
37
41
|
# Svelte on Rails 👍
|
38
42
|
|
39
43
|
Rock-solid and seamless integration of Svelte Components into Rails views, based on `vite_rails`.
|
@@ -51,8 +55,8 @@ Thanks to [shakacode](https://github.com/shakacode/react_on_rails)
|
|
51
55
|
and [ElMassimo](https://github.com/ElMassimo) for inspiring and helping me with their gems.
|
52
56
|
|
53
57
|
**STATUS** This gem is in early development but ready to use for curious developers.
|
54
|
-
It has a 100% test coverage, all tests pass
|
55
|
-
|
58
|
+
It has a nearly 100% test coverage, all tests pass and, since 2025-05-15 it is successfully
|
59
|
+
implemented on my first customers app.
|
56
60
|
|
57
61
|
If you have issues, please open one, and contributors are welcome!
|
58
62
|
|
@@ -68,8 +72,6 @@ If you have issues, please open one, and contributors are welcome!
|
|
68
72
|
|
69
73
|
## Installation from cero ⚙️
|
70
74
|
|
71
|
-
With haml, vite, svelte and turbo:
|
72
|
-
|
73
75
|
```bash
|
74
76
|
rails new my-test-app --skip-javascript
|
75
77
|
```
|
@@ -88,7 +90,7 @@ rails g svelte_on_rails:install --full
|
|
88
90
|
|
89
91
|
You have done it! 👍
|
90
92
|
|
91
|
-
|
93
|
+
Start the server and you will see a svelte hello world component rendered on the browser.
|
92
94
|
|
93
95
|
**Explanation:**
|
94
96
|
|
@@ -164,11 +166,12 @@ And you should see your component rendered on the browser! 👍 🤗
|
|
164
166
|
|
165
167
|
this Minimal installer does:
|
166
168
|
|
167
|
-
- `app/frontend/initializers/svelte.js`
|
169
|
+
- add `app/frontend/initializers/svelte.js`
|
168
170
|
- Adds a import statement for that initializer to `application.js`
|
169
|
-
- `app/frontend/ssr/ssr.js`
|
170
|
-
- `config/svelte_on_rails.yml`
|
171
|
-
- `vite-ssr.config.ts`
|
171
|
+
- add `app/frontend/ssr/ssr.js`
|
172
|
+
- add `config/svelte_on_rails.yml`
|
173
|
+
- add `vite-ssr.config.ts`
|
174
|
+
- add command `npm run build:ssr` to package.json
|
172
175
|
- installs or updates npm packages to the latest:
|
173
176
|
- `@csedl/svelte-on-rails`
|
174
177
|
- `typescript`
|
@@ -58,16 +58,41 @@ module SvelteOnRails
|
|
58
58
|
|
59
59
|
def self.precompile(last_mtime = nil)
|
60
60
|
config = SvelteOnRails::Configuration.instance
|
61
|
+
|
62
|
+
mtime = (File.exist?(config.ssr_dist_folder.join('last_mtime')) ? File.read(config.ssr_dist_folder.join('last_mtime')).to_f : 0.0)
|
63
|
+
|
61
64
|
Dir.chdir(config.rails_root) do
|
65
|
+
|
66
|
+
# run build
|
67
|
+
|
62
68
|
cmd = "./node_modules/.bin/vite build --config vite-ssr.config.ts"
|
63
69
|
stdout, stderr, status = Open3.capture3(cmd)
|
70
|
+
mtime2 = (File.exist?(config.ssr_dist_folder.join('last_mtime')) ? File.read(config.ssr_dist_folder.join('last_mtime')).to_f : 0.0)
|
71
|
+
|
72
|
+
# error handling
|
64
73
|
|
65
74
|
if stderr.present?
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
75
|
+
|
76
|
+
nothing_done = mtime2 == mtime
|
77
|
+
color = (nothing_done ? "\033[97;41m" : "\033[30;106m")
|
78
|
+
|
79
|
+
msg = " +++ #{nothing_done ? 'ERROR' : 'WARNING'} compiling Svelte components#{nothing_done ? ' failed' : ''} («#{cmd}») +++ "
|
80
|
+
puts "#{color}#{msg}\033[0m"
|
81
|
+
errs = stderr.split("\n")
|
82
|
+
errs.each { |e| puts "#{color} \033[0m #{e}" }
|
83
|
+
puts "#{color} +++ End of error message +++ \033[0m"
|
84
|
+
puts "#{color} +++ Run «npm run build:ssr» on the console to see the original error message +++ \033[0m"
|
85
|
+
|
86
|
+
if nothing_done
|
87
|
+
critical_lines = errs.select { |e| e.match(/Could not resolve/i) }
|
88
|
+
cl_str = if critical_lines.present?
|
89
|
+
"#{critical_lines.join("\n")}\n\n"
|
90
|
+
end
|
91
|
+
raise "Svelte components compilation failed\n\n#{cl_str}Full message:\n+++\n#{stderr}+++\n\nYou can run «npm run build:ssr» on the console to see the original error message\n"
|
92
|
+
end
|
93
|
+
|
70
94
|
end
|
95
|
+
|
71
96
|
puts stdout
|
72
97
|
|
73
98
|
end
|