[Regression] Use stable sort when prioritizing app assets#209
Conversation
|
Thanks Chris! I was just talking about this one with a colleague who had this problem. Will just ask him to check and merge if it solves his problem too. |
|
Awesome, thanks for the quick review. It was certainly a head scratcher today as I was testing our Rails 8 migration! |
|
Alternative implementation I considered was to config.assets.paths = config.assets.paths.partition { |path| path.to_s.start_with?(Rails.root.to_s) }.flatten |
|
The |
|
Just for future reference, it seems that if all elements of the array are a |
|
I figured partition would allocate a couple arrays and join them back so it is probably slower. Although the arrays probably aren't large enough to matter. |
|
Thanks!! |
|
The ones causing issues for me are from importmap-rails: https://github.com/rails/importmap-rails/blob/main/lib/importmap/engine.rb#L46-L47 Same approach in most engines/railties I think: https://github.com/rails/mission_control-jobs/blob/main/lib/mission_control/jobs/engine.rb#L93-L94 |
|
Yeah, I doubt it will make that much of a difference. But the |
This fixes a regression introduced in #206.
sort_by!doesn't preserve the original order so this loses the original order. https://ruby-doc.org/3.3.5/Array.html#method-i-sort_by-21I ran into this using esbuild and had
app/assets/buildsas the first entry in paths. After #206,app/javascriptalways ended up higher priority thanapp/assets/buildsso it was finding the wrong file.