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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1a5bcc964aa9ff10fac375fdcbc9605976eb2d086676606aadf4f1869c84a42
4
- data.tar.gz: c350bb0dd47258df7155b7b45ce1d4e2767b1a97804393a75b9c688e4e284437
3
+ metadata.gz: 89b585de2264458769d479f27bcadc4080a8984b23e916cccd5d07876a30ea24
4
+ data.tar.gz: 7255f6af6ee943e809b24ba6551730e05dd21b8279555c677f7be2346d47a0f1
5
5
  SHA512:
6
- metadata.gz: 2cd99018e1314db22ae7116c354a9949ab57724420ffbb2f34d8f1f5e909031ee34ef58ecf728e695ea90675cf63bf901c478450f0cbe641e739ef698fecf734
7
- data.tar.gz: 64687a8f4b734dd41cd0f39cc068043ac710b8b90da6c6b05d807bb325c147735ebcaab99017af3da71bcbe71f6c2a56dda7559f63da3c5786aa81923f8d09e4
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
- It is not yet implemented on my customer projects, but this will follow soon.
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
- Restart the server and you will see a svelte hello world component rendered on the browser.
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
- msg = " +++ ERROR compiling Svelte components («#{cmd}») +++ "
67
- puts "\033[97;41m#{msg}\033[0m"
68
- puts "\033[31m#{stderr}\033[0m"
69
- puts "\033[97;41m +++ End of error message +++ \033[0m"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svelte-on-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Sedlmair