Skip to content

Commit

Permalink
fix: handle new virtual legacy-polyfill name (#157)
Browse files Browse the repository at this point in the history
The entry of the legacy-polyfill name has changed to start with a
\u0000 character to mark it as a virtual entry in vite 2.7.
This commit ensures that this new name is handled correctly.

See: #156
  • Loading branch information
StefSchenkelaars committed Dec 17, 2021
1 parent 894aa00 commit a34e77f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions test/test_app/public/vite-production/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"_log.d31acc25-legacy.js": {
"file": "assets/log.d31acc25-legacy.js"
},
"../../vite/legacy-polyfills": {
"../../\u0000vite/legacy-polyfills": {
"file": "assets/polyfills-legacy.07477394.js",
"src": "../../vite/legacy-polyfills",
"isEntry": true
Expand Down Expand Up @@ -100,4 +100,4 @@
"_log.818edfb8.js": {
"file": "assets/log.818edfb8.js"
}
}
}
6 changes: 4 additions & 2 deletions vite_ruby/lib/vite_ruby/manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,11 @@ def resolve_references(manifest)

# Internal: Resolves the manifest entry name for the specified resource.
def resolve_entry_name(name, type: nil)
name = with_file_extension(name.to_s, type)
unless name.include?('legacy-polyfills')

This comment has been minimized.

Copy link
@ElMassimo

ElMassimo Dec 17, 2021

Owner

Reminder to self: name could be nil or a symbol, apply to_s before checking with include?

name = with_file_extension(name.to_s, type)

raise ArgumentError, "Asset names can not be relative. Found: #{ name }" if name.start_with?('.') && !name.include?('legacy-polyfills')
raise ArgumentError, "Asset names can not be relative. Found: #{ name }" if name.start_with?('.')
end

# Explicit path, relative to the source_code_dir.
name.sub(%r{^~/(.+)$}) { return Regexp.last_match(1) }
Expand Down

0 comments on commit a34e77f

Please sign in to comment.