vite_ruby 1.2.20 → 2.0.0.beta.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba6a2c2dfa0c80f225fa9779b50aa3937c7cc12d260399c858e5491c6e9b9b9b
4
- data.tar.gz: 2db29cb4b421ea2e4b96a936924b70abd071f32a3272a3d524296989fefe2c99
3
+ metadata.gz: 4958a06ce37c85ac97dda22ba69f7e65b4c75e0398bd65c3889821b766d9bf76
4
+ data.tar.gz: 3bd1b130ff9ddb0ae9a2e8108b2263922b9eba12493acaa7a40d87335ceddeaf
5
5
  SHA512:
6
- metadata.gz: bd0b836df9e9890ac7de7e7729b11deebb064331bcc30e2df82568feae4c219aa6195848dde7b535f292300dfd888824eeabcd59f08175e4da7e450ef6776363
7
- data.tar.gz: 93eb9909a490974e14b375b2375173b669523e674877783019b9c09d62ff31e46f1a55c6c00d2b15eeffdfff88326d5670759a4fbef96c767ed53a50a394384d
6
+ metadata.gz: db3357ac2c2290bc2002434b4391bff4cc0690b84ce151aa70c48f7e3b10ab7cdc46f6b90b485685fbc47e9208a243dfa896b9679301f18c9bd75589d21425b5
7
+ data.tar.gz: 4097a262af50ccec4e3b802d0e77e387eb22ca065036dc207583b2e4ea423902447ad056ba0d06081c85a71022922f240d03c76d11a912e5bd2b21f055d03d62
data/default.vite.json CHANGED
@@ -1,4 +1,5 @@
1
1
  {
2
+ "additionalInputGlobs": ["{assets,fonts,icons,images}/**/*"],
2
3
  "assetHost": null,
3
4
  "assetsDir": "assets",
4
5
  "autoBuild": false,
data/lib/vite_ruby.rb CHANGED
@@ -17,10 +17,6 @@ class ViteRuby
17
17
  # Internal: Prefix used for environment variables that modify the configuration.
18
18
  ENV_PREFIX = 'VITE_RUBY'
19
19
 
20
- # Internal: Versions used by default when running `vite install`.
21
- DEFAULT_VITE_VERSION = '^2.3.8'
22
- DEFAULT_PLUGIN_VERSION = '^2.0.4'
23
-
24
20
  # Internal: Companion libraries for Vite Ruby, and their target framework.
25
21
  COMPANION_LIBRARIES = {
26
22
  'vite_rails' => 'rails',
@@ -30,7 +30,7 @@ class ViteRuby::Config
30
30
 
31
31
  # Public: The directory where the entries are located.
32
32
  def resolved_entrypoints_dir
33
- root.join(source_code_dir, entrypoints_dir)
33
+ vite_root_dir.join(entrypoints_dir)
34
34
  end
35
35
 
36
36
  # Internal: The directory where Vite stores its processing cache.
@@ -38,6 +38,11 @@ class ViteRuby::Config
38
38
  root.join('node_modules/.vite')
39
39
  end
40
40
 
41
+ # Public: The directory that Vite uses as root.
42
+ def vite_root_dir
43
+ root.join(source_code_dir)
44
+ end
45
+
41
46
  # Public: Sets additional environment variables for vite-plugin-ruby.
42
47
  def to_env
43
48
  CONFIGURABLE_WITH_ENV.each_with_object({}) do |option, env|
@@ -138,7 +143,7 @@ private
138
143
  DEFAULT_CONFIG = load_json("#{ __dir__ }/../../default.vite.json").freeze
139
144
 
140
145
  # Internal: Configuration options that can not be provided as env vars.
141
- NOT_CONFIGURABLE_WITH_ENV = %w[watch_additional_paths].freeze
146
+ NOT_CONFIGURABLE_WITH_ENV = %w[additional_input_globs watch_additional_paths].freeze
142
147
 
143
148
  # Internal: Configuration options that can be provided as env vars.
144
149
  CONFIGURABLE_WITH_ENV = (DEFAULT_CONFIG.keys + %w[mode root] - NOT_CONFIGURABLE_WITH_ENV).freeze
@@ -52,13 +52,12 @@ private
52
52
  path = env['PATH_INFO']
53
53
  return true if path.start_with?(vite_asset_url_prefix) # Vite asset
54
54
  return true if path.start_with?(VITE_DEPENDENCY_PREFIX) # Packages and imports
55
- return true if vite_entrypoint?(path) # HMR for entrypoint stylesheets and imports does not include the prefix
55
+ return true if file_in_vite_root?(path) # Fallback if Vite can serve the file
56
56
  end
57
57
 
58
- # Internal: We want to avoid checking the filesystem if possible
59
- def vite_entrypoint?(path)
60
- path.include?('.') &&
61
- config.resolved_entrypoints_dir.join(path.start_with?('/') ? path[1..-1] : path).file?
58
+ def file_in_vite_root?(path)
59
+ path.include?('.') && # Check for extension, avoid filesystem if possible.
60
+ config.vite_root_dir.join(path.start_with?('/') ? path[1..-1] : path).file?
62
61
  end
63
62
 
64
63
  def vite_asset_url_prefix
@@ -66,8 +66,8 @@ protected
66
66
  # Internal: Strict version of lookup.
67
67
  #
68
68
  # Returns a relative path for the asset, or raises an error if not found.
69
- def lookup!(*args, **options)
70
- lookup(*args, **options) || missing_entry_error(*args, **options)
69
+ def lookup!(name, **options)
70
+ lookup(name, **options) || missing_entry_error(name, **options)
71
71
  end
72
72
 
73
73
  # Internal: Computes the path for a given Vite asset using manifest.json.
@@ -77,10 +77,10 @@ protected
77
77
  # Example:
78
78
  # manifest.lookup('calendar.js')
79
79
  # => { "file" => "/vite/assets/calendar-1016838bab065ae1e122.js", "imports" => [] }
80
- def lookup(name, type: nil)
80
+ def lookup(name, **options)
81
81
  @build_mutex.synchronize { builder.build } if should_build?
82
82
 
83
- find_manifest_entry(with_file_extension(name, type))
83
+ find_manifest_entry resolve_entry_name(name, **options)
84
84
  end
85
85
 
86
86
  private
@@ -98,9 +98,9 @@ private
98
98
  # Internal: Finds the specified entry in the manifest.
99
99
  def find_manifest_entry(name)
100
100
  if dev_server_running?
101
- { 'file' => prefix_vite_asset(name.to_s) }
101
+ { 'file' => prefix_vite_asset(name) }
102
102
  else
103
- manifest[name.to_s]
103
+ manifest[name]
104
104
  end
105
105
  end
106
106
 
@@ -140,12 +140,26 @@ private
140
140
  end
141
141
  end
142
142
 
143
+ # Internal: Resolves the manifest entry name for the specified resource.
144
+ def resolve_entry_name(name, type: nil)
145
+ name = with_file_extension(name.to_s, type)
146
+ name = name[1..-1] if name.start_with?('/')
147
+
148
+ # Prefix scripts and stylesheets with the entrypoints dir.
149
+ if (type || File.dirname(name) == '.') && !name.start_with?(config.entrypoints_dir)
150
+ File.join(config.entrypoints_dir, name)
151
+ else
152
+ name
153
+ end
154
+ end
155
+
143
156
  # Internal: Adds a file extension to the file name, unless it already has one.
144
157
  def with_file_extension(name, entry_type)
145
- return name unless File.extname(name.to_s).empty?
146
-
147
- extension = extension_for_type(entry_type)
148
- extension ? "#{ name }.#{ extension }" : name
158
+ if File.extname(name).empty? && (ext = extension_for_type(entry_type))
159
+ "#{ name }.#{ ext }"
160
+ else
161
+ name
162
+ end
149
163
  end
150
164
 
151
165
  # Internal: Allows to receive :javascript and :stylesheet as :type in helpers.
@@ -159,9 +173,9 @@ private
159
173
  end
160
174
 
161
175
  # Internal: Raises a detailed message when an entry is missing in the manifest.
162
- def missing_entry_error(name, type: nil, **_options)
176
+ def missing_entry_error(name, **options)
163
177
  raise ViteRuby::MissingEntrypointError, OpenStruct.new(
164
- file_name: with_file_extension(name, type),
178
+ file_name: resolve_entry_name(name, **options),
165
179
  last_build: builder.last_build_metadata,
166
180
  manifest: @manifest,
167
181
  config: config,
@@ -1,5 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ViteRuby
4
- VERSION = '1.2.20'
4
+ VERSION = '2.0.0.beta.4'
5
+
6
+ # Internal: Versions used by default when running `vite install`.
7
+ DEFAULT_VITE_VERSION = '^2.5.0-beta.2'
8
+ DEFAULT_PLUGIN_VERSION = '^3.0.0-beta.3'
5
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vite_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.20
4
+ version: 2.0.0.beta.4
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: 2021-07-30 00:00:00.000000000 Z
11
+ date: 2021-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli
@@ -198,9 +198,12 @@ homepage: https://github.com/ElMassimo/vite_ruby
198
198
  licenses:
199
199
  - MIT
200
200
  metadata:
201
- source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@1.2.20/vite_ruby
202
- changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@1.2.20/vite_ruby/CHANGELOG.md
203
- post_install_message:
201
+ source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@2.0.0.beta.4/vite_ruby
202
+ changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@2.0.0.beta.4/vite_ruby/CHANGELOG.md
203
+ post_install_message: |-
204
+ Thanks for installing Vite Ruby!
205
+
206
+ When upgrading, please verify package.json to ensure you have installed the recommended versions of vite (^2.5.0-beta.2) and vite-plugin-ruby (^3.0.0-beta.3).
204
207
  rdoc_options: []
205
208
  require_paths:
206
209
  - lib
@@ -211,9 +214,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
211
214
  version: '2.4'
212
215
  required_rubygems_version: !ruby/object:Gem::Requirement
213
216
  requirements:
214
- - - ">="
217
+ - - ">"
215
218
  - !ruby/object:Gem::Version
216
- version: '0'
219
+ version: 1.3.1
217
220
  requirements: []
218
221
  rubygems_version: 3.1.4
219
222
  signing_key: