svelte-on-rails 1.0.11 → 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: 11f044fdee86f5acc0dc592039acf158004a9f9849caaf12aaddbfaf16c7a086
4
- data.tar.gz: '036408c99291e0a454726e0624a8492de97936e70550936fa5b49f670893bfcb'
3
+ metadata.gz: 89b585de2264458769d479f27bcadc4080a8984b23e916cccd5d07876a30ea24
4
+ data.tar.gz: 7255f6af6ee943e809b24ba6551730e05dd21b8279555c677f7be2346d47a0f1
5
5
  SHA512:
6
- metadata.gz: 21235c147c880a84db9ad123aea60e5d9833e0451675754f9e6ac94c395fa445182e69fe1fbce6b1caf09c7e4e5c84fd7fa2a0460d5e9fe18d55fb9384287a58
7
- data.tar.gz: 6673e550b9afc250663c81cdeca7837e4a8649875a4541cb83dabd773544fc528c52787b447d28c7d356ea664b3f1a8b911f6c864d1814e032830f73bc7c0305
6
+ metadata.gz: 3557343363ea9f1776a6766eadcb97a3d8e6376ac069b1daa764cd77aa87a2f04614c91f3ed0b9d16a549b4ca7651ad82716d4b2374fc222c6d649d1e1c538c3
7
+ data.tar.gz: 4f301fb16a422e682e75ca9ebf09a207474346ff973140191d8e92226bc9b284c04eaa3c3662f6745b83637b6db83752c8b5b4dcfa35deaec71eaa0d0ad1d973
@@ -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.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Sedlmair