vite_ruby 3.9.1 → 4.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@
7
7
  # lookup_entrypoint('calendar', type: :javascript)
8
8
  # => { "file" => "/vite/assets/calendar-1016838bab065ae1e314.js", "imports" => [] }
9
9
  #
10
- # NOTE: Using `"autoBuild": true` in `config/vite.json` file will trigger a build
10
+ # NOTE: Using "autoBuild": true` in `config/vite.json` file will trigger a build
11
11
  # on demand as needed, before performing any lookup.
12
12
  class ViteRuby::Manifest
13
13
  def initialize(vite_ruby)
@@ -19,20 +19,19 @@ class ViteRuby::Manifest
19
19
  #
20
20
  # Raises an error if the resource could not be found in the manifest.
21
21
  def path_for(name, **options)
22
- lookup!(name, **options).fetch("file")
22
+ lookup!(name, **options).fetch('file')
23
23
  end
24
24
 
25
- # Public: Returns scripts, imported modules, and stylesheets for the specified
25
+ # Public: Returns entries, imported modules, and stylesheets for the specified
26
26
  # entrypoint files.
27
27
  def resolve_entries(*names, **options)
28
28
  entries = names.map { |name| lookup!(name, **options) }
29
- script_paths = entries.map { |entry| entry.fetch("file") }
30
29
 
31
- imports = dev_server_running? ? [] : entries.flat_map { |entry| entry["imports"] }.compact
30
+ imports = dev_server_running? ? [] : entries.flat_map { |entry| entry['imports'] }.compact.uniq
32
31
  {
33
- scripts: script_paths,
34
- imports: imports.filter_map { |entry| entry.fetch("file") }.uniq,
35
- stylesheets: dev_server_running? ? [] : (entries + imports).flat_map { |entry| entry["css"] }.compact.uniq,
32
+ main: entries.map(&TO_ENTRY),
33
+ imports: imports.map(&TO_ENTRY).uniq,
34
+ stylesheets: dev_server_running? ? [] : (entries + imports).flat_map { |entry| entry['css'] }.compact.uniq,
36
35
  }
37
36
  end
38
37
 
@@ -43,7 +42,7 @@ class ViteRuby::Manifest
43
42
 
44
43
  # Public: The path from where the browser can download the Vite HMR client.
45
44
  def vite_client_src
46
- prefix_asset_with_host("@vite/client") if dev_server_running?
45
+ prefix_asset_with_host('@vite/client') if dev_server_running?
47
46
  end
48
47
 
49
48
  # Public: The content of the preamble needed by the React Refresh plugin.
@@ -51,27 +50,21 @@ class ViteRuby::Manifest
51
50
  if dev_server_running?
52
51
  <<~REACT_REFRESH
53
52
  <script type="module">
54
- #{react_preamble_code}
53
+ import RefreshRuntime from '#{ prefix_asset_with_host('@react-refresh') }'
54
+ RefreshRuntime.injectIntoGlobalHook(window)
55
+ window.$RefreshReg$ = () => {}
56
+ window.$RefreshSig$ = () => (type) => type
57
+ window.__vite_plugin_react_preamble_installed__ = true
55
58
  </script>
56
59
  REACT_REFRESH
57
60
  end
58
61
  end
59
62
 
60
- # Public: Source script for the React Refresh plugin.
61
- def react_preamble_code
62
- if dev_server_running?
63
- <<~REACT_PREAMBLE_CODE
64
- import RefreshRuntime from '#{prefix_asset_with_host("@react-refresh")}'
65
- RefreshRuntime.injectIntoGlobalHook(window)
66
- window.$RefreshReg$ = () => {}
67
- window.$RefreshSig$ = () => (type) => type
68
- window.__vite_plugin_react_preamble_installed__ = true
69
- REACT_PREAMBLE_CODE
70
- end
71
- end
72
-
73
63
  protected
74
64
 
65
+ # Internal: Returns a [src, attrs] entry.
66
+ TO_ENTRY = ->(entry) { [entry.fetch('file'), entry.slice('integrity').symbolize_keys] }
67
+
75
68
  # Internal: Strict version of lookup.
76
69
  #
77
70
  # Returns a relative path for the asset, or raises an error if not found.
@@ -87,7 +80,7 @@ protected
87
80
  # manifest.lookup('calendar.js')
88
81
  # => { "file" => "/vite/assets/calendar-1016838bab065ae1e122.js", "imports" => [] }
89
82
  def lookup(name, **options)
90
- @build_mutex.synchronize { builder.build || (return nil) } if should_build?
83
+ @build_mutex.synchronize { builder.build } if should_build?
91
84
 
92
85
  find_manifest_entry resolve_entry_name(name, **options)
93
86
  end
@@ -95,7 +88,7 @@ protected
95
88
  private
96
89
 
97
90
  # Internal: The prefix used by Vite.js to request files with an absolute path.
98
- FS_PREFIX = "/@fs/"
91
+ FS_PREFIX = '/@fs/'
99
92
 
100
93
  extend Forwardable
101
94
 
@@ -110,7 +103,7 @@ private
110
103
  # Internal: Finds the specified entry in the manifest.
111
104
  def find_manifest_entry(name)
112
105
  if dev_server_running?
113
- {"file" => prefix_vite_asset(name)}
106
+ { 'file' => prefix_vite_asset(name) }
114
107
  else
115
108
  manifest[name]
116
109
  end
@@ -128,36 +121,29 @@ private
128
121
 
129
122
  # Internal: Loads and merges the manifest files, resolving the asset paths.
130
123
  def load_manifest
131
- config.manifest_paths
132
- .map { |path| JSON.parse(path.read) }
133
- .inject({}, &:merge)
134
- .tap { |manifest| resolve_references(manifest) }
124
+ files = [config.manifest_path, config.assets_manifest_path].select(&:exist?)
125
+ files.map { |path| JSON.parse(path.read) }.inject({}, &:merge).tap(&method(:resolve_references))
135
126
  end
136
127
 
137
128
  # Internal: Scopes an asset to the output folder in public, as a path.
138
129
  def prefix_vite_asset(path)
139
- File.join(vite_asset_origin || "/", config.public_output_dir, path)
130
+ File.join("/#{ config.public_output_dir }", path)
140
131
  end
141
132
 
142
133
  # Internal: Prefixes an asset with the `asset_host` for tags that do not use
143
134
  # the framework tag helpers.
144
135
  def prefix_asset_with_host(path)
145
- File.join(vite_asset_origin || config.asset_host || "/", config.public_output_dir, path)
146
- end
147
-
148
- # Internal: The origin of assets managed by Vite.
149
- def vite_asset_origin
150
- config.origin if dev_server_running? && config.skip_proxy
136
+ File.join(config.asset_host || '/', config.public_output_dir, path)
151
137
  end
152
138
 
153
139
  # Internal: Resolves the paths that reference a manifest entry.
154
140
  def resolve_references(manifest)
155
141
  manifest.each_value do |entry|
156
- entry["file"] = prefix_vite_asset(entry["file"])
142
+ entry['file'] = prefix_vite_asset(entry['file'])
157
143
  %w[css assets].each do |key|
158
144
  entry[key] = entry[key].map { |path| prefix_vite_asset(path) } if entry[key]
159
145
  end
160
- entry["imports"]&.map! { |name| manifest.fetch(name) }
146
+ entry['imports']&.map! { |name| manifest.fetch(name) }
161
147
  end
162
148
  end
163
149
 
@@ -166,7 +152,7 @@ private
166
152
  return resolve_virtual_entry(name) if type == :virtual
167
153
 
168
154
  name = with_file_extension(name.to_s, type)
169
- raise ArgumentError, "Asset names can not be relative. Found: #{name}" if name.start_with?(".")
155
+ raise ArgumentError, "Asset names can not be relative. Found: #{ name }" if name.start_with?('.')
170
156
 
171
157
  # Explicit path, relative to the source_code_dir.
172
158
  name.sub(%r{^~/(.+)$}) { return Regexp.last_match(1) }
@@ -175,7 +161,7 @@ private
175
161
  name.sub(%r{^/(.+)$}) { return resolve_absolute_entry(Regexp.last_match(1)) }
176
162
 
177
163
  # Sugar: Prefix with the entrypoints dir if the path is not nested.
178
- name.include?("/") ? name : File.join(config.entrypoints_dir, name)
164
+ name.include?('/') ? name : File.join(config.entrypoints_dir, name)
179
165
  end
180
166
 
181
167
  # Internal: Entry names in the manifest are relative to the Vite.js.
@@ -196,7 +182,7 @@ private
196
182
  # Internal: Adds a file extension to the file name, unless it already has one.
197
183
  def with_file_extension(name, entry_type)
198
184
  if File.extname(name).empty? && (ext = extension_for_type(entry_type))
199
- "#{name}.#{ext}"
185
+ "#{ name }.#{ ext }"
200
186
  else
201
187
  name
202
188
  end
@@ -205,16 +191,16 @@ private
205
191
  # Internal: Allows to receive :javascript and :stylesheet as :type in helpers.
206
192
  def extension_for_type(entry_type)
207
193
  case entry_type
208
- when :javascript then "js"
209
- when :stylesheet then "css"
210
- when :typescript then "ts"
194
+ when :javascript then 'js'
195
+ when :stylesheet then 'css'
196
+ when :typescript then 'ts'
211
197
  else entry_type
212
198
  end
213
199
  end
214
200
 
215
201
  # Internal: Raises a detailed message when an entry is missing in the manifest.
216
202
  def missing_entry_error(name, **options)
217
- raise ViteRuby::MissingEntrypointError.new(
203
+ raise ViteRuby::MissingEntrypointError, OpenStruct.new(
218
204
  file_name: resolve_entry_name(name, **options),
219
205
  last_build: builder.last_build_metadata,
220
206
  manifest: @manifest,
@@ -5,39 +5,31 @@
5
5
  # NOTE: The complexity here is justified by the improved usability of providing
6
6
  # a more specific error message depending on the situation.
7
7
  class ViteRuby::MissingEntrypointError < ViteRuby::Error
8
- attr_reader :file_name, :last_build, :manifest, :config
8
+ extend Forwardable
9
+ def_delegators :@info, :file_name, :last_build, :manifest, :config
9
10
 
10
- def initialize(file_name:, last_build:, manifest:, config:)
11
- @file_name, @last_build, @manifest, @config = file_name, last_build, manifest, config
11
+ def initialize(info)
12
+ @info = info
12
13
  super <<~MSG
13
- Vite Ruby can't find #{file_name} in the manifests.
14
+ Vite Ruby can't find #{ file_name } in #{ config.manifest_path.relative_path_from(config.root) } or #{ config.assets_manifest_path.relative_path_from(config.root) }.
14
15
 
15
16
  Possible causes:
16
- #{possible_causes(last_build)}
17
+ #{ possible_causes(last_build) }
17
18
  :troubleshooting:
18
- #{"Manifest files found:\n#{config.manifest_paths.map { |path| " #{path.relative_path_from(config.root)}" }.join("\n")}\n" if last_build.success}
19
- #{"Content in your manifests:\n#{JSON.pretty_generate(manifest)}\n" if last_build.success}
20
- #{"Last build in #{config.mode} mode:\n#{last_build.to_json}\n" if last_build.success}
19
+ #{ "\nContent in your manifests:\n#{ JSON.pretty_generate(manifest) }\n" if last_build.success }
20
+ #{ "Last build in #{ config.mode } mode:\n#{ last_build.to_json }\n" unless last_build.success.nil? }
21
21
  MSG
22
22
  end
23
23
 
24
24
  def possible_causes(last_build)
25
- if last_build.success == false
26
- FAILED_BUILD_CAUSES
27
- .sub(":mode:", config.mode)
28
- .sub(":errors:", last_build.errors.to_s.gsub(/^(?!$)/, " "))
29
- elsif config.auto_build
30
- DEFAULT_CAUSES
31
- else
32
- DEFAULT_CAUSES + NO_AUTO_BUILD_CAUSES
33
- end
34
- end
25
+ return FAILED_BUILD_CAUSES.sub(':mode:', config.mode) if last_build.success == false
26
+ return DEFAULT_CAUSES if config.auto_build
35
27
 
36
- FAILED_BUILD_CAUSES = <<~MSG
37
- - The last build failed. Try running `bin/vite build --clear --mode=:mode:` manually and check for errors.
28
+ DEFAULT_CAUSES + NO_AUTO_BUILD_CAUSES
29
+ end
38
30
 
39
- Errors:
40
- :errors:
31
+ FAILED_BUILD_CAUSES = <<-MSG
32
+ - The last build failed. Try running `bin/vite build --clear --mode=:mode:` manually and check for errors.
41
33
  MSG
42
34
 
43
35
  DEFAULT_CAUSES = <<-MSG
@@ -7,7 +7,7 @@ class ViteRuby::MissingExecutableError < ViteRuby::Error
7
7
  ❌ The vite binary is not available. Have you installed the npm packages?
8
8
 
9
9
  :troubleshooting:
10
- #{error}
10
+ #{ error }
11
11
  MSG
12
12
  end
13
13
  end
@@ -8,11 +8,11 @@ class ViteRuby::Runner
8
8
 
9
9
  # Public: Executes Vite with the specified arguments.
10
10
  def run(argv, exec: false)
11
- config.within_root {
11
+ Dir.chdir(config.root) {
12
12
  cmd = command_for(argv)
13
13
  return Kernel.exec(*cmd) if exec
14
14
 
15
- log_or_noop = ->(line) { logger.info("vite") { line } } unless config.hide_build_console_output
15
+ log_or_noop = ->(line) { logger.info('vite') { line } } unless config.hide_build_console_output
16
16
  ViteRuby::IO.capture(*cmd, chdir: config.root, with_output: log_or_noop)
17
17
  }
18
18
  rescue Errno::ENOENT => error
@@ -23,31 +23,23 @@ private
23
23
 
24
24
  extend Forwardable
25
25
 
26
- def_delegators :@vite_ruby, :config, :logger, :env
26
+ def_delegators :@vite_ruby, :config, :logger
27
27
 
28
28
  # Internal: Returns an Array with the command to run.
29
29
  def command_for(args)
30
- [config.to_env(env)].tap do |cmd|
31
- exec_args, vite_args = args.partition { |arg| arg.start_with?("--node-options") }
32
- cmd.push(*vite_executable(*exec_args))
33
- cmd.push(*vite_args)
34
- cmd.push("--mode", config.mode) unless args.include?("--mode") || args.include?("-m")
30
+ [config.to_env].tap do |cmd|
31
+ args = args.clone
32
+ cmd.push('node', '--inspect-brk') if args.delete('--inspect')
33
+ cmd.push('node', '--trace-deprecation') if args.delete('--trace_deprecation')
34
+ cmd.push(vite_executable)
35
+ cmd.push(*args)
36
+ cmd.push('--mode', config.mode) unless args.include?('--mode') || args.include?('-m')
35
37
  end
36
38
  end
37
39
 
38
40
  # Internal: Resolves to an executable for Vite.
39
- def vite_executable(*exec_args)
41
+ def vite_executable
40
42
  bin_path = config.vite_bin_path
41
- return [bin_path] if bin_path && File.exist?(bin_path)
42
-
43
- x = case config.package_manager
44
- when "npm" then %w[npx]
45
- when "pnpm" then %w[pnpm exec]
46
- when "bun" then %w[bun x --bun]
47
- when "yarn" then %w[yarn]
48
- else raise ArgumentError, "Unknown package manager #{config.package_manager.inspect}"
49
- end
50
-
51
- [*x, *exec_args, "vite"]
43
+ File.exist?(bin_path) ? bin_path : "#{ `npm bin`.chomp }/vite"
52
44
  end
53
45
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ViteRuby
4
- VERSION = "3.9.1"
4
+ VERSION = '4.0.0.alpha1'
5
5
 
6
6
  # Internal: Versions used by default when running `vite install`.
7
- DEFAULT_VITE_VERSION = "^5.0.0"
8
- DEFAULT_PLUGIN_VERSION = "^5.1.0"
7
+ DEFAULT_VITE_VERSION = '^2.7.7'
8
+ DEFAULT_PLUGIN_VERSION = '^3.0.5'
9
9
  end
data/lib/vite_ruby.rb CHANGED
@@ -1,38 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "logger"
4
- require "forwardable"
5
- require "pathname"
6
- require "socket"
3
+ require 'logger'
4
+ require 'forwardable'
5
+ require 'pathname'
6
+ require 'socket'
7
7
 
8
- require "zeitwerk"
8
+ require 'zeitwerk'
9
9
  loader = Zeitwerk::Loader.for_gem
10
- loader.ignore("#{__dir__}/install")
11
- loader.ignore("#{__dir__}/tasks")
12
- loader.ignore("#{__dir__}/exe")
13
- loader.inflector.inflect("cli" => "CLI")
14
- loader.inflector.inflect("ssr" => "SSR")
15
- loader.inflector.inflect("io" => "IO")
10
+ loader.ignore("#{ __dir__ }/install")
11
+ loader.ignore("#{ __dir__ }/tasks")
12
+ loader.ignore("#{ __dir__ }/exe")
13
+ loader.inflector.inflect('cli' => 'CLI')
14
+ loader.inflector.inflect('io' => 'IO')
16
15
  loader.setup
17
16
 
17
+ require 'vite_ruby/version'
18
+
18
19
  class ViteRuby
19
20
  # Internal: Prefix used for environment variables that modify the configuration.
20
- ENV_PREFIX = "VITE_RUBY"
21
+ ENV_PREFIX = 'VITE_RUBY'
21
22
 
22
23
  # Internal: Companion libraries for Vite Ruby, and their target framework.
23
24
  COMPANION_LIBRARIES = {
24
- "vite_rails" => "rails",
25
- "vite_hanami" => "hanami",
26
- "vite_padrino" => "padrino",
27
- "jekyll-vite" => "jekyll",
28
- "vite_rails_legacy" => "rails",
29
- "vite_plugin_legacy" => "rack",
25
+ 'vite_rails' => 'rails',
26
+ 'vite_hanami' => 'hanami',
27
+ 'vite_padrino' => 'padrino',
28
+ 'jekyll-vite' => 'jekyll',
29
+ 'vite_rails_legacy' => 'rails',
30
+ 'vite_plugin_legacy' => 'rack',
30
31
  }
31
32
 
32
33
  class << self
33
34
  extend Forwardable
34
35
 
35
- def_delegators :instance, :config, :configure, :commands, :digest, :env, :run, :run_proxy?
36
+ def_delegators :instance, :config, :commands, :env, :run, :run_proxy?
36
37
  def_delegators :config, :mode
37
38
 
38
39
  def instance
@@ -46,7 +47,7 @@ class ViteRuby
46
47
 
47
48
  # Internal: Loads all available rake tasks.
48
49
  def install_tasks
49
- load File.expand_path("tasks/vite.rake", __dir__)
50
+ load File.expand_path('tasks/vite.rake', __dir__)
50
51
  end
51
52
 
52
53
  # Internal: Creates a new instance with the specified options.
@@ -57,11 +58,11 @@ class ViteRuby
57
58
  # Internal: Detects if the application has installed a framework-specific
58
59
  # variant of Vite Ruby.
59
60
  def framework_libraries
60
- COMPANION_LIBRARIES.filter_map { |name, framework|
61
+ COMPANION_LIBRARIES.map { |name, framework|
61
62
  if library = Gem.loaded_specs[name]
62
63
  [framework, library]
63
64
  end
64
- }
65
+ }.compact
65
66
  end
66
67
  end
67
68
 
@@ -75,26 +76,17 @@ class ViteRuby
75
76
  @logger ||= Logger.new($stdout)
76
77
  end
77
78
 
78
- # Public: Returns a digest of all the watched files, allowing to detect
79
- # changes. Useful to perform version checks in single-page applications.
80
- def digest
81
- builder.send(:watched_files_digest)
82
- end
83
-
84
79
  # Public: Returns true if the Vite development server is currently running.
85
80
  # NOTE: Checks only once every second since every lookup calls this method.
86
81
  def dev_server_running?
87
82
  return false unless run_proxy?
88
- return @running if defined?(@running) && Time.now - @running_checked_at < 1
89
-
90
- begin
91
- Socket.tcp(config.host, config.port, connect_timeout: config.dev_server_connect_timeout).close
92
- @running = true
93
- rescue
94
- @running = false
95
- ensure
96
- @running_checked_at = Time.now
97
- end
83
+ return true if defined?(@running_at) && @running_at && Time.now - @running_at < 1
84
+
85
+ Socket.tcp(config.host, config.port, connect_timeout: config.dev_server_connect_timeout).close
86
+ @running_at = Time.now
87
+ true
88
+ rescue StandardError
89
+ @running_at = false
98
90
  end
99
91
 
100
92
  # Public: Additional environment variables to pass to Vite.
@@ -107,9 +99,9 @@ class ViteRuby
107
99
 
108
100
  # Public: The proxy for assets should only run in development mode.
109
101
  def run_proxy?
110
- config.mode == "development" || (config.mode == "test" && !ENV["CI"])
111
- rescue => error
112
- logger.error("Failed to check mode for Vite: #{error.message}")
102
+ config.mode == 'development' || (config.mode == 'test' && !ENV['CI'])
103
+ rescue StandardError => error
104
+ logger.error("Failed to check mode for Vite: #{ error.message }")
113
105
  false
114
106
  end
115
107
 
@@ -131,22 +123,15 @@ class ViteRuby
131
123
  # Public: Current instance configuration for Vite.
132
124
  def config
133
125
  unless defined?(@config)
134
- configure
126
+ @config = ViteRuby::Config.resolve_config(**@config_options)
135
127
  @config.load_ruby_config
136
128
  end
137
129
 
138
130
  @config
139
131
  end
140
132
 
141
- # Public: Allows overriding the configuration for this instance.
142
- def configure(**options)
143
- @config = ViteRuby::Config.resolve_config(**@config_options, **options)
144
- end
145
-
146
133
  # Public: Enables looking up assets managed by Vite using name and type.
147
134
  def manifest
148
135
  @manifest ||= ViteRuby::Manifest.new(self)
149
136
  end
150
137
  end
151
-
152
- require "vite_ruby/version"
metadata CHANGED
@@ -1,63 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vite_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.1
4
+ version: 4.0.0.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Máximo Mussini
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-21 00:00:00.000000000 Z
11
+ date: 2022-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0.7'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '2'
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '0.7'
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '2'
33
- - !ruby/object:Gem::Dependency
34
- name: logger
35
15
  requirement: !ruby/object:Gem::Requirement
36
16
  requirements:
37
17
  - - "~>"
38
18
  - !ruby/object:Gem::Version
39
- version: '1.6'
19
+ version: 0.7.0
40
20
  type: :runtime
41
21
  prerelease: false
42
22
  version_requirements: !ruby/object:Gem::Requirement
43
23
  requirements:
44
24
  - - "~>"
45
25
  - !ruby/object:Gem::Version
46
- version: '1.6'
47
- - !ruby/object:Gem::Dependency
48
- name: mutex_m
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '0'
26
+ version: 0.7.0
61
27
  - !ruby/object:Gem::Dependency
62
28
  name: rack-proxy
63
29
  requirement: !ruby/object:Gem::Requirement
@@ -213,7 +179,6 @@ files:
213
179
  - lib/vite_ruby/cli/dev.rb
214
180
  - lib/vite_ruby/cli/file_utils.rb
215
181
  - lib/vite_ruby/cli/install.rb
216
- - lib/vite_ruby/cli/ssr.rb
217
182
  - lib/vite_ruby/cli/upgrade.rb
218
183
  - lib/vite_ruby/cli/upgrade_packages.rb
219
184
  - lib/vite_ruby/cli/version.rb
@@ -236,9 +201,8 @@ homepage: https://github.com/ElMassimo/vite_ruby
236
201
  licenses:
237
202
  - MIT
238
203
  metadata:
239
- source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@3.9.1/vite_ruby
240
- changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@3.9.1/vite_ruby/CHANGELOG.md
241
- rubygems_mfa_required: 'true'
204
+ source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@4.0.0.alpha1/vite_ruby
205
+ changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@4.0.0.alpha1/vite_ruby/CHANGELOG.md
242
206
  post_install_message: "Thanks for installing Vite Ruby!\n\nIf you upgraded the gem
243
207
  manually, please run:\n\tbundle exec vite upgrade"
244
208
  rdoc_options: []
@@ -248,14 +212,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
248
212
  requirements:
249
213
  - - ">="
250
214
  - !ruby/object:Gem::Version
251
- version: '2.5'
215
+ version: '2.4'
252
216
  required_rubygems_version: !ruby/object:Gem::Requirement
253
217
  requirements:
254
- - - ">="
218
+ - - ">"
255
219
  - !ruby/object:Gem::Version
256
- version: '0'
220
+ version: 1.3.1
257
221
  requirements: []
258
- rubygems_version: 3.5.16
222
+ rubygems_version: 3.2.32
259
223
  signing_key:
260
224
  specification_version: 4
261
225
  summary: Use Vite in Ruby and bring joy to your JavaScript experience
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ViteRuby::CLI::SSR < ViteRuby::CLI::Vite
4
- DEFAULT_ENV = CURRENT_ENV || "production"
5
- JS_EXTENSIONS = %w[js mjs cjs]
6
-
7
- desc "Run the resulting app from building in SSR mode."
8
- executable_options
9
-
10
- def call(mode:, inspect: false, trace_deprecation: false)
11
- ViteRuby.env["VITE_RUBY_MODE"] = mode
12
-
13
- ssr_entrypoint = JS_EXTENSIONS
14
- .map { |ext| ViteRuby.config.ssr_output_dir.join("ssr.#{ext}") }
15
- .find(&:exist?)
16
-
17
- raise ArgumentError, "No ssr entrypoint found `#{ViteRuby.config.ssr_output_dir.relative_path_from(ViteRuby.config.root)}/ssr.{#{JS_EXTENSIONS.join(",")}}`. Have you run bin/vite build --ssr?" unless ssr_entrypoint
18
-
19
- cmd = [
20
- "node",
21
- ("--inspect-brk" if inspect),
22
- ("--trace-deprecation" if trace_deprecation),
23
- ssr_entrypoint,
24
- ]
25
- Kernel.exec(*cmd.compact.map(&:to_s))
26
- end
27
- end