vite_ruby 3.10.2 → 3.11.1
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/CHANGELOG.md +54 -0
- data/README.md +1 -1
- data/default.vite.json +1 -0
- data/lib/vite_ruby/builder.rb +38 -2
- data/lib/vite_ruby/cli/install.rb +1 -1
- data/lib/vite_ruby/cli/upgrade.rb +1 -1
- data/lib/vite_ruby/config.rb +9 -1
- data/lib/vite_ruby/dev_server_proxy.rb +1 -0
- data/lib/vite_ruby/version.rb +2 -2
- data/lib/vite_ruby.rb +37 -13
- metadata +4 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7b123a02b4b5ed8154b52f7b15f1ffed680818dc6f823c7cb3a7f466a9c0b3e3
|
|
4
|
+
data.tar.gz: 61310dc93fb66de90968b00a1b65f9cd8269501c9451c06b13152727e414f317
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f63402050f71af9335a59737209f985c8671416be2be27a08c6b7281eedb825bb0b213b5d2d11bc473aa6371daaeec39f0b91a11159638ec068b3e8e02df241b
|
|
7
|
+
data.tar.gz: 17c238e9ddef2890f8fbf0508fcd2b1194198821290bcf8673ba897d34f64758d1e3108dd804be0173f7c7c503bfad4596829ffdefd66815b867470828a6264a
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
1
|
+
## [3.11.1](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.11.0...vite_ruby@3.11.1) (2026-09-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* scope dev server metadata to Ruby mode ([#632](https://github.com/ElMassimo/vite_ruby/issues/632)) ([#633](https://github.com/ElMassimo/vite_ruby/issues/633)) ([d3d8e6f](https://github.com/ElMassimo/vite_ruby/commit/d3d8e6f50524e9415df5e0621fe92117175f6dfd))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# [3.11.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.10.6...vite_ruby@3.11.0) (2026-09-17)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* detect if dev server is running using a local file (close [#391](https://github.com/ElMassimo/vite_ruby/issues/391)) ([#621](https://github.com/ElMassimo/vite_ruby/issues/621)) ([d424fbf](https://github.com/ElMassimo/vite_ruby/commit/d424fbf5fbd3782c4446c4c357331320e3512352))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## [3.10.6](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.10.5...vite_ruby@3.10.6) (2026-09-16)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Performance Improvements
|
|
23
|
+
|
|
24
|
+
* skip re-hashing unchanged watched files on every build check ([#625](https://github.com/ElMassimo/vite_ruby/issues/625)) ([e0ad345](https://github.com/ElMassimo/vite_ruby/commit/e0ad34511b7fc0e34cdfbf2bbe9aca4660b2e904)), closes [#624](https://github.com/ElMassimo/vite_ruby/issues/624)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## [3.10.5](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.10.4...vite_ruby@3.10.5) (2026-08-28)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
|
|
33
|
+
* support rack-proxy 1.0 (close [#622](https://github.com/ElMassimo/vite_ruby/issues/622)) ([#623](https://github.com/ElMassimo/vite_ruby/issues/623)) ([3486248](https://github.com/ElMassimo/vite_ruby/commit/3486248d14a7968fe5a9c88f7454540c933f344b))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## [3.10.4](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.10.3...vite_ruby@3.10.4) (2026-08-26)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Bug Fixes
|
|
41
|
+
|
|
42
|
+
* update Vite Ruby gems conservatively ([#613](https://github.com/ElMassimo/vite_ruby/issues/613)) ([c5cc08a](https://github.com/ElMassimo/vite_ruby/commit/c5cc08a8514090a2060c41f6975530869fc6616c))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## [3.10.3](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.10.2...vite_ruby@3.10.3) (2026-08-26)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### Bug Fixes
|
|
50
|
+
|
|
51
|
+
* relax dependency for `rack-proxy` (closes [#619](https://github.com/ElMassimo/vite_ruby/issues/619)) ([37b1edb](https://github.com/ElMassimo/vite_ruby/commit/37b1edb5ee74704192ed0b23efb6c4976e120e7d))
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
1
55
|
## [3.10.2](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.10.1...vite_ruby@3.10.2) (2026-03-30)
|
|
2
56
|
|
|
3
57
|
|
data/README.md
CHANGED
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
[config]: https://vite-ruby.netlify.app/config/
|
|
38
38
|
[vite_rails]: https://github.com/ElMassimo/vite_ruby
|
|
39
39
|
[webpacker]: https://github.com/rails/webpacker
|
|
40
|
-
[vite]:
|
|
40
|
+
[vite]: https://vite.dev/
|
|
41
41
|
[config file]: https://github.com/ElMassimo/vite_ruby/blob/main/vite-plugin-ruby/default.vite.json
|
|
42
42
|
[example app]: https://github.com/ElMassimo/pingcrm-vite
|
|
43
43
|
[heroku]: https://pingcrm-vite.herokuapp.com/
|
data/default.vite.json
CHANGED
data/lib/vite_ruby/builder.rb
CHANGED
|
@@ -6,6 +6,7 @@ require "digest/sha1"
|
|
|
6
6
|
class ViteRuby::Builder
|
|
7
7
|
def initialize(vite_ruby)
|
|
8
8
|
@vite_ruby = vite_ruby
|
|
9
|
+
@file_digests = {}
|
|
9
10
|
end
|
|
10
11
|
|
|
11
12
|
# Public: Checks if the watched files have changed since the last compilation,
|
|
@@ -55,13 +56,48 @@ private
|
|
|
55
56
|
return @last_digest if @last_digest_at && Time.now - @last_digest_at < 1
|
|
56
57
|
|
|
57
58
|
config.within_root do
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
previous_digests = @file_digests
|
|
60
|
+
@file_digests = {}
|
|
61
|
+
file_ids = Dir[*config.watched_paths].sort.filter_map { |file|
|
|
62
|
+
file_digest(file, previous_digests)
|
|
63
|
+
}
|
|
60
64
|
@last_digest_at = Time.now
|
|
61
65
|
@last_digest = Digest::SHA1.hexdigest(file_ids.join("/"))
|
|
62
66
|
end
|
|
63
67
|
end
|
|
64
68
|
|
|
69
|
+
# Internal: Returns the id of a watched file, or nil if it's a directory.
|
|
70
|
+
#
|
|
71
|
+
# NOTE: Reading and hashing every watched file dominates the cost of the
|
|
72
|
+
# check, and the answer is almost always the same one as the last time, so the
|
|
73
|
+
# contents are read again only once the file has been touched. The digest
|
|
74
|
+
# stays content-based: a checkout that changes mtimes but not contents still
|
|
75
|
+
# counts as unchanged, and no Vite build is triggered.
|
|
76
|
+
def file_digest(file, previous_digests)
|
|
77
|
+
stat = File.stat(file)
|
|
78
|
+
return if stat.directory?
|
|
79
|
+
|
|
80
|
+
signature = [stat.mtime, stat.size]
|
|
81
|
+
previous_signature, previous_id = previous_digests[file]
|
|
82
|
+
id = if previous_signature == signature && !recently_modified?(stat)
|
|
83
|
+
previous_id
|
|
84
|
+
else
|
|
85
|
+
"#{File.basename(file)}/#{Digest::SHA1.file(file).hexdigest}"
|
|
86
|
+
end
|
|
87
|
+
@file_digests[file] = [signature, id]
|
|
88
|
+
id
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Internal: Whether the file was modified too recently to trust its mtime.
|
|
92
|
+
#
|
|
93
|
+
# NOTE: A file edited twice within the resolution of the file system clock,
|
|
94
|
+
# without changing its size, would keep the same signature. Rehashing the
|
|
95
|
+
# files touched in the last second rules that out, the same way Git resolves
|
|
96
|
+
# a racily clean entry in the index.
|
|
97
|
+
def recently_modified?(stat)
|
|
98
|
+
Time.now - stat.mtime < 1
|
|
99
|
+
end
|
|
100
|
+
|
|
65
101
|
# Public: Initiates a Vite build command to generate assets.
|
|
66
102
|
def build_with_vite(*args)
|
|
67
103
|
logger.info "Building with Vite ⚡️"
|
|
@@ -110,7 +110,7 @@ private
|
|
|
110
110
|
/public/vite*
|
|
111
111
|
node_modules
|
|
112
112
|
# Vite uses dotenv and suggests to ignore local-only env files. See
|
|
113
|
-
# https://
|
|
113
|
+
# https://vite.dev/guide/env-and-mode.html#env-files
|
|
114
114
|
*.local
|
|
115
115
|
GITIGNORE
|
|
116
116
|
end
|
|
@@ -15,7 +15,7 @@ protected
|
|
|
15
15
|
|
|
16
16
|
libraries = ViteRuby.framework_libraries.map { |_f, library| library.name }
|
|
17
17
|
|
|
18
|
-
run_with_capture("bundle update #{libraries.join(" ")}")
|
|
18
|
+
run_with_capture("bundle update --conservative vite_ruby #{libraries.join(" ")}")
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
# NOTE: Spawn a new process so that it uses the updated vite_ruby.
|
data/lib/vite_ruby/config.rb
CHANGED
|
@@ -5,6 +5,9 @@ require "json"
|
|
|
5
5
|
# Public: Allows to resolve configuration sourced from `config/vite.json` and
|
|
6
6
|
# environment variables, combining them with the default options.
|
|
7
7
|
class ViteRuby::Config
|
|
8
|
+
# Internal: Base name of the metadata file written by the Vite dev server.
|
|
9
|
+
DEV_SERVER_META_BASENAME = "vite-ruby"
|
|
10
|
+
|
|
8
11
|
def origin
|
|
9
12
|
"#{protocol}://#{host_with_port}"
|
|
10
13
|
end
|
|
@@ -38,6 +41,11 @@ class ViteRuby::Config
|
|
|
38
41
|
root.join(public_dir, public_output_dir)
|
|
39
42
|
end
|
|
40
43
|
|
|
44
|
+
# Internal: Path to the metadata file written by the Vite dev server.
|
|
45
|
+
def dev_server_meta_path
|
|
46
|
+
root.join("tmp", "#{DEV_SERVER_META_BASENAME}-#{mode}.json")
|
|
47
|
+
end
|
|
48
|
+
|
|
41
49
|
# Public: The directory where the entries are located.
|
|
42
50
|
def resolved_entrypoints_dir
|
|
43
51
|
vite_root_dir.join(entrypoints_dir)
|
|
@@ -96,7 +104,7 @@ private
|
|
|
96
104
|
config["build_cache_dir"] = root.join(config["build_cache_dir"])
|
|
97
105
|
config["ssr_output_dir"] = root.join(config["ssr_output_dir"])
|
|
98
106
|
config["dev_server_connect_timeout"] = config["dev_server_connect_timeout"].to_f
|
|
99
|
-
coerce_booleans(config, "auto_build", "hide_build_console_output", "https", "skip_compatibility_check", "skip_proxy")
|
|
107
|
+
coerce_booleans(config, "auto_build", "dev_server_connection_check", "hide_build_console_output", "https", "skip_compatibility_check", "skip_proxy")
|
|
100
108
|
config["package_manager"] ||= detect_package_manager(root)
|
|
101
109
|
end
|
|
102
110
|
|
|
@@ -44,6 +44,7 @@ private
|
|
|
44
44
|
def forward_to_vite_dev_server(env)
|
|
45
45
|
rewrite_uri_for_vite(env)
|
|
46
46
|
env["QUERY_STRING"] ||= ""
|
|
47
|
+
env["rack.backend"] = URI(config.origin)
|
|
47
48
|
env["HTTP_HOST"] = env["HTTP_X_FORWARDED_HOST"] = config.host
|
|
48
49
|
env["HTTP_X_FORWARDED_SERVER"] = config.host_with_port
|
|
49
50
|
env["HTTP_PORT"] = env["HTTP_X_FORWARDED_PORT"] = config.port.to_s
|
data/lib/vite_ruby/version.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class ViteRuby
|
|
4
|
-
VERSION = "3.
|
|
4
|
+
VERSION = "3.11.1"
|
|
5
5
|
|
|
6
6
|
# Internal: Versions used by default when running `vite install`.
|
|
7
7
|
DEFAULT_VITE_VERSION = "^8.0.0"
|
|
8
|
-
DEFAULT_PLUGIN_VERSION = "^5.2.
|
|
8
|
+
DEFAULT_PLUGIN_VERSION = "^5.2.5"
|
|
9
9
|
end
|
data/lib/vite_ruby.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "json"
|
|
3
4
|
require "logger"
|
|
4
5
|
require "forwardable"
|
|
5
6
|
require "pathname"
|
|
@@ -82,19 +83,12 @@ class ViteRuby
|
|
|
82
83
|
end
|
|
83
84
|
|
|
84
85
|
# Public: Returns true if the Vite development server is currently running.
|
|
85
|
-
# NOTE: Checks only once every second since every lookup calls this method.
|
|
86
86
|
def dev_server_running?
|
|
87
|
-
return false unless
|
|
88
|
-
return
|
|
87
|
+
return false unless dev_mode?
|
|
88
|
+
return dev_server_connected? if config.dev_server_connection_check
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
@running = true
|
|
93
|
-
rescue
|
|
94
|
-
@running = false
|
|
95
|
-
ensure
|
|
96
|
-
@running_checked_at = Time.now
|
|
97
|
-
end
|
|
90
|
+
meta = dev_server_meta
|
|
91
|
+
meta.is_a?(Hash) && meta["port"] == config.port
|
|
98
92
|
end
|
|
99
93
|
|
|
100
94
|
# Public: Additional environment variables to pass to Vite.
|
|
@@ -105,13 +99,15 @@ class ViteRuby
|
|
|
105
99
|
@env ||= ENV.select { |key, _| key.start_with?(ENV_PREFIX) }
|
|
106
100
|
end
|
|
107
101
|
|
|
108
|
-
# Public:
|
|
109
|
-
def
|
|
102
|
+
# Public: Whether we are in an environment that might run the Vite dev server.
|
|
103
|
+
def dev_mode?
|
|
110
104
|
config.mode == "development" || (config.mode == "test" && !ENV["CI"])
|
|
111
105
|
rescue => error
|
|
112
106
|
logger.error("Failed to check mode for Vite: #{error.message}")
|
|
113
107
|
false
|
|
114
108
|
end
|
|
109
|
+
# Public: The proxy for assets should only run in development mode.
|
|
110
|
+
alias_method :run_proxy?, :dev_mode?
|
|
115
111
|
|
|
116
112
|
# Internal: Executes the vite binary.
|
|
117
113
|
def run(argv, **options)
|
|
@@ -147,6 +143,34 @@ class ViteRuby
|
|
|
147
143
|
def manifest
|
|
148
144
|
@manifest ||= ViteRuby::Manifest.new(self)
|
|
149
145
|
end
|
|
146
|
+
|
|
147
|
+
private
|
|
148
|
+
|
|
149
|
+
# Internal: Returns true if a TCP connection to the dev server can be opened.
|
|
150
|
+
def dev_server_connected?
|
|
151
|
+
return @running if defined?(@running) && Time.now - @running_checked_at < 1
|
|
152
|
+
|
|
153
|
+
begin
|
|
154
|
+
Socket.tcp(config.host, config.port, connect_timeout: config.dev_server_connect_timeout).close
|
|
155
|
+
@running = true
|
|
156
|
+
rescue
|
|
157
|
+
@running = false
|
|
158
|
+
ensure
|
|
159
|
+
@running_checked_at = Time.now
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# Internal: Metadata written by the running Vite dev server, or nil when stopped.
|
|
164
|
+
def dev_server_meta
|
|
165
|
+
return @dev_server_meta if defined?(@dev_server_meta) && Time.now - @dev_server_meta_checked_at < 1
|
|
166
|
+
|
|
167
|
+
path = config.dev_server_meta_path
|
|
168
|
+
@dev_server_meta = (JSON.parse(path.read) if path.exist?)
|
|
169
|
+
rescue JSON::ParserError, SystemCallError
|
|
170
|
+
@dev_server_meta = nil
|
|
171
|
+
ensure
|
|
172
|
+
@dev_server_meta_checked_at = Time.now
|
|
173
|
+
end
|
|
150
174
|
end
|
|
151
175
|
|
|
152
176
|
require "vite_ruby/version"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vite_ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.11.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Máximo Mussini
|
|
@@ -61,9 +61,6 @@ dependencies:
|
|
|
61
61
|
name: rack-proxy
|
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
|
63
63
|
requirements:
|
|
64
|
-
- - "~>"
|
|
65
|
-
- !ruby/object:Gem::Version
|
|
66
|
-
version: '0.6'
|
|
67
64
|
- - ">="
|
|
68
65
|
- !ruby/object:Gem::Version
|
|
69
66
|
version: 0.6.1
|
|
@@ -71,9 +68,6 @@ dependencies:
|
|
|
71
68
|
prerelease: false
|
|
72
69
|
version_requirements: !ruby/object:Gem::Requirement
|
|
73
70
|
requirements:
|
|
74
|
-
- - "~>"
|
|
75
|
-
- !ruby/object:Gem::Version
|
|
76
|
-
version: '0.6'
|
|
77
71
|
- - ">="
|
|
78
72
|
- !ruby/object:Gem::Version
|
|
79
73
|
version: 0.6.1
|
|
@@ -234,8 +228,8 @@ homepage: https://github.com/ElMassimo/vite_ruby
|
|
|
234
228
|
licenses:
|
|
235
229
|
- MIT
|
|
236
230
|
metadata:
|
|
237
|
-
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@3.
|
|
238
|
-
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@3.
|
|
231
|
+
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@3.11.1/vite_ruby
|
|
232
|
+
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@3.11.1/vite_ruby/CHANGELOG.md
|
|
239
233
|
rubygems_mfa_required: 'true'
|
|
240
234
|
post_install_message: "Thanks for installing Vite Ruby!\n\nIf you upgraded the gem
|
|
241
235
|
manually, please run:\n\tbundle exec vite upgrade"
|
|
@@ -253,7 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
253
247
|
- !ruby/object:Gem::Version
|
|
254
248
|
version: '0'
|
|
255
249
|
requirements: []
|
|
256
|
-
rubygems_version:
|
|
250
|
+
rubygems_version: 4.0.16
|
|
257
251
|
specification_version: 4
|
|
258
252
|
summary: Use Vite in Ruby and bring joy to your JavaScript experience
|
|
259
253
|
test_files: []
|