vite_ruby 3.10.5 → 3.11.0
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 +18 -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/config.rb +9 -1
- data/lib/vite_ruby/version.rb +1 -1
- data/lib/vite_ruby.rb +36 -13
- metadata +5 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8349aea6809e111e73935d71ab1bd256abb988a20207b155f44efc86f99af61a
|
|
4
|
+
data.tar.gz: 8c43f3fc3bd96ae6ceea8c47f57c5807ff282a1055c84ae0be2c3763f80b5527
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8d92c2da929fa6664b2f08427606daf86dea0eae6d068d8cd527fb947f4083068e5f6fa8327b8d505d51316d502df60538a8b9adeec4d62d67eaeb1126d62bca
|
|
7
|
+
data.tar.gz: e9425003b0d0b8a6c7d29e72a65d9a529ee4035f23228b31f28e35ea5ccb905e5e47e9d63d276111f9aa2e3b1167a0077a25675c93449f8dc863c38e1cef2c50
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
# [3.11.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.10.6...vite_ruby@3.11.0) (2026-09-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* 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))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## [3.10.6](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.10.5...vite_ruby@3.10.6) (2026-09-16)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Performance Improvements
|
|
14
|
+
|
|
15
|
+
* 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)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
1
19
|
## [3.10.5](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.10.4...vite_ruby@3.10.5) (2026-08-28)
|
|
2
20
|
|
|
3
21
|
|
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
|
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: Name of the metadata file written by the Vite dev server.
|
|
9
|
+
DEV_SERVER_META_FILENAME = "vite-ruby.json"
|
|
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_FILENAME)
|
|
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
|
|
data/lib/vite_ruby/version.rb
CHANGED
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,11 @@ 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
|
-
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
|
|
90
|
+
!dev_server_meta.nil?
|
|
98
91
|
end
|
|
99
92
|
|
|
100
93
|
# Public: Additional environment variables to pass to Vite.
|
|
@@ -105,13 +98,15 @@ class ViteRuby
|
|
|
105
98
|
@env ||= ENV.select { |key, _| key.start_with?(ENV_PREFIX) }
|
|
106
99
|
end
|
|
107
100
|
|
|
108
|
-
# Public:
|
|
109
|
-
def
|
|
101
|
+
# Public: Whether we are in an environment that might run the Vite dev server.
|
|
102
|
+
def dev_mode?
|
|
110
103
|
config.mode == "development" || (config.mode == "test" && !ENV["CI"])
|
|
111
104
|
rescue => error
|
|
112
105
|
logger.error("Failed to check mode for Vite: #{error.message}")
|
|
113
106
|
false
|
|
114
107
|
end
|
|
108
|
+
# Public: The proxy for assets should only run in development mode.
|
|
109
|
+
alias_method :run_proxy?, :dev_mode?
|
|
115
110
|
|
|
116
111
|
# Internal: Executes the vite binary.
|
|
117
112
|
def run(argv, **options)
|
|
@@ -147,6 +142,34 @@ class ViteRuby
|
|
|
147
142
|
def manifest
|
|
148
143
|
@manifest ||= ViteRuby::Manifest.new(self)
|
|
149
144
|
end
|
|
145
|
+
|
|
146
|
+
private
|
|
147
|
+
|
|
148
|
+
# Internal: Returns true if a TCP connection to the dev server can be opened.
|
|
149
|
+
def dev_server_connected?
|
|
150
|
+
return @running if defined?(@running) && Time.now - @running_checked_at < 1
|
|
151
|
+
|
|
152
|
+
begin
|
|
153
|
+
Socket.tcp(config.host, config.port, connect_timeout: config.dev_server_connect_timeout).close
|
|
154
|
+
@running = true
|
|
155
|
+
rescue
|
|
156
|
+
@running = false
|
|
157
|
+
ensure
|
|
158
|
+
@running_checked_at = Time.now
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Internal: Metadata written by the running Vite dev server, or nil when stopped.
|
|
163
|
+
def dev_server_meta
|
|
164
|
+
return @dev_server_meta if defined?(@dev_server_meta) && Time.now - @dev_server_meta_checked_at < 1
|
|
165
|
+
|
|
166
|
+
path = config.dev_server_meta_path
|
|
167
|
+
@dev_server_meta = (JSON.parse(path.read) if path.exist?)
|
|
168
|
+
rescue JSON::ParserError, SystemCallError
|
|
169
|
+
@dev_server_meta = nil
|
|
170
|
+
ensure
|
|
171
|
+
@dev_server_meta_checked_at = Time.now
|
|
172
|
+
end
|
|
150
173
|
end
|
|
151
174
|
|
|
152
175
|
require "vite_ruby/version"
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
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.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Máximo Mussini
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: dry-cli
|
|
@@ -184,7 +183,6 @@ dependencies:
|
|
|
184
183
|
- - "<"
|
|
185
184
|
- !ruby/object:Gem::Version
|
|
186
185
|
version: '0.23'
|
|
187
|
-
description:
|
|
188
186
|
email:
|
|
189
187
|
- maximomussini@gmail.com
|
|
190
188
|
executables:
|
|
@@ -230,8 +228,8 @@ homepage: https://github.com/ElMassimo/vite_ruby
|
|
|
230
228
|
licenses:
|
|
231
229
|
- MIT
|
|
232
230
|
metadata:
|
|
233
|
-
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@3.
|
|
234
|
-
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.0/vite_ruby
|
|
232
|
+
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@3.11.0/vite_ruby/CHANGELOG.md
|
|
235
233
|
rubygems_mfa_required: 'true'
|
|
236
234
|
post_install_message: "Thanks for installing Vite Ruby!\n\nIf you upgraded the gem
|
|
237
235
|
manually, please run:\n\tbundle exec vite upgrade"
|
|
@@ -249,8 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
249
247
|
- !ruby/object:Gem::Version
|
|
250
248
|
version: '0'
|
|
251
249
|
requirements: []
|
|
252
|
-
rubygems_version:
|
|
253
|
-
signing_key:
|
|
250
|
+
rubygems_version: 4.0.16
|
|
254
251
|
specification_version: 4
|
|
255
252
|
summary: Use Vite in Ruby and bring joy to your JavaScript experience
|
|
256
253
|
test_files: []
|