svelte-on-rails 1.0.11 → 1.0.13

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: 11f044fdee86f5acc0dc592039acf158004a9f9849caaf12aaddbfaf16c7a086
4
- data.tar.gz: '036408c99291e0a454726e0624a8492de97936e70550936fa5b49f670893bfcb'
3
+ metadata.gz: c2bddaae521fc71ed3c7975612b8b9109830fd25210eda2d30c00c6150265dca
4
+ data.tar.gz: 7adeb7e7181508d704ff98087f5b601a596159d1205cb0ffb08e98f5fca81272
5
5
  SHA512:
6
- metadata.gz: 21235c147c880a84db9ad123aea60e5d9833e0451675754f9e6ac94c395fa445182e69fe1fbce6b1caf09c7e4e5c84fd7fa2a0460d5e9fe18d55fb9384287a58
7
- data.tar.gz: 6673e550b9afc250663c81cdeca7837e4a8649875a4541cb83dabd773544fc528c52787b447d28c7d356ea664b3f1a8b911f6c864d1814e032830f73bc7c0305
6
+ metadata.gz: 77f1fd03901c9c73c8893c471b464db9e2e4fd212b9a36dad9a78f15b34f155865155b4796af3409e32b741dd4693a9756c369bcfb32caf05b1a1abdfa6e1af5
7
+ data.tar.gz: 7be8fd8640a3d7431dd6e8274a3bc3f3a9eca0c9c9e30f46d42f4eb00735f13a8e8421e8b0e6142c17ac0a0aab9bc9df5cc0914b17add50677498575401ac20b
data/README.md CHANGED
@@ -4,7 +4,14 @@
4
4
 
5
5
  ---
6
6
 
7
- Svelte is the missing peace for ambitious Rails frontends.
7
+ Do you want to combine DHH's [vision](https://rubyonrails.org/2021/12/15/Rails-7-fulfilling-a-vision)
8
+ with modern front-end requirements?
9
+
10
+ Svelte.
11
+
12
+ Vite.
13
+
14
+ Nothing else.
8
15
 
9
16
  # Why Svelte?
10
17
 
@@ -14,12 +21,12 @@ On every app there are parts where you want it to shine. This is where Svelte co
14
21
  - Perfect addition to Stimulus
15
22
  - Easy to learn
16
23
  - Powerful
24
+ - Super fast
17
25
  - **Compared to Stimulus**
18
26
  - No more writing double logic of the initial HTML state
19
- - Stimulus is good for parts where you have simple and little javascript and lots of html
20
- - The more complexity, the more you will love svelte
27
+ - Stimulus is great for rails views with some javascript, but, complex parts: Svelte. Nothing else.
21
28
  - **Compared to React**
22
- - No Shadow dom
29
+ - No more shadow dom and all those packages that are supposed to improve performance (e.g. useCallback...)
23
30
  - Slimmer packages
24
31
  - Easier to learn
25
32
  - Faster
@@ -27,12 +34,15 @@ On every app there are parts where you want it to shine. This is where Svelte co
27
34
  Have a look at this entertaining video [rethinking reactivity](https://svelte.dev/blog/svelte-3-rethinking-reactivity)
28
35
  by Rich Harris, especially from 3:50 to 6:40 and his comparison to react.
29
36
 
30
- This all fits perfectly with the Rails way of minimalist javascript, but: Where we need it, we have it.
37
+ This all fits in perfectly with the Rails way of minimalist javascript,
38
+ but: Where needed, we want full power.
31
39
 
32
40
  # Features
33
41
 
34
- - 🤝 fully integrated with `assets:precompile`
35
- - 🚀 cero-config deployment
42
+ - 🤝 Fully integrated with `assets:precompile`
43
+ - 🚀 Cero-config deployment
44
+ - ✍️ Sophisticated error messages
45
+ - 😍 Contributor friendly
36
46
 
37
47
  # Known Issues
38
48
 
@@ -189,7 +199,7 @@ The most importand rule is to firstly check all npm packages installed and passi
189
199
  ## Check if it all works
190
200
 
191
201
  Server Side Rendering (SSR) is a parallel pipeline to client side rendering.
192
- Both should return the same html. And your global styles should be applied same way
202
+ Both should return the same HTML. And your global styles should be applied same way
193
203
  for both cases. For normal use cases this is.
194
204
 
195
205
  For check the **ssr pipeline** you can pass the options `ssr: true` and `hydrate: false`
@@ -62,20 +62,37 @@ module SvelteOnRails
62
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
63
 
64
64
  Dir.chdir(config.rails_root) do
65
+
66
+ # run build
67
+
65
68
  cmd = "./node_modules/.bin/vite build --config vite-ssr.config.ts"
66
69
  stdout, stderr, status = Open3.capture3(cmd)
67
70
  mtime2 = (File.exist?(config.ssr_dist_folder.join('last_mtime')) ? File.read(config.ssr_dist_folder.join('last_mtime')).to_f : 0.0)
68
- build_failed = mtime2 == mtime
69
- color = (build_failed ? "\033[97;41m" : "\033[30;106m")
71
+
72
+ # error handling
70
73
 
71
74
  if stderr.present?
72
- msg = " +++ #{build_failed ? 'ERROR' : 'WARNING'} compiling Svelte components#{build_failed ? ' failed' : ''} («#{cmd}») +++ "
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}») +++ "
73
80
  puts "#{color}#{msg}\033[0m"
74
81
  errs = stderr.split("\n")
75
- errs.each {|e|puts "#{color} \033[0m #{e}"}
82
+ errs.each { |e| puts "#{color} \033[0m #{e}" }
76
83
  puts "#{color} +++ End of error message +++ \033[0m"
77
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
+
78
94
  end
95
+
79
96
  puts stdout
80
97
 
81
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.11
4
+ version: 1.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Sedlmair
@@ -95,6 +95,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  requirements: []
96
96
  rubygems_version: 3.6.7
97
97
  specification_version: 4
98
- summary: Rock-solid and seamless integration of Svelte Components into Rails views,
99
- based on vite_rails.
98
+ summary: Solid and seamless integration of Svelte Components into Rails views.
100
99
  test_files: []