Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean task references removed method from vite_ruby during production deploy #91

Open
malakada opened this issue Nov 11, 2024 · 0 comments · May be fixed by magnolia-development/maglev-core#1
Labels
bug Something isn't working

Comments

@malakada
Copy link

Hi there, I'm building a new Maglev instance (1.7.3) on Rails 7.2 with Ruby 3.3.5.

I'm getting this error when I try to run in production:

info: I, [2024-11-11T18:59:34.011784 #1900]  INFO -- : [Maglev] adding theme: HyperUI (#theme)
info: bin/rails aborted!
info: NoMethodError: undefined method `clean_from_task' for an instance of ViteRuby::Commands (NoMethodError)
info: 
info:         Maglev::Engine.vite_ruby.commands.clean_from_task(args)
info:                                          ^^^^^^^^^^^^^^^^
info: 
info: Tasks: TOP => maglev:vite:clean

After doing some digging, I suspect it's because the clean_from_task method was removed in vite_ruby 3.8.0: https://my.diffend.io/gems/vite_ruby/3.7.0/3.8.0 and the dependency is listed as 3.9.0.... and you can see a commit related to it on Aug 12 here: ElMassimo/vite_ruby@824b4ef, which reads:

fix: remove vite:clean rake task as it can potentially break apps
Vite plugins can create additional files, and some of them are never
referenced in the manifest.

As a result, cleaning files can only be done safely by doing it
before building with Vite, otherwise it can potentially break an app.

Deployment setups without a CDN would actually benefit from keeping
previous builds. Otherwise, in SPA clients might request an asset or dynamic
import chunk that was removed from the server upon deployment, remaining in a
broken state until a full-page reload.

Container-based deployments don't need clean, and they are one of the
most common ways to deploy apps nowadays.

Taking all of this into account, I've decided to remove this task from
vite_ruby, preventing broken apps, and easing the maintenance burden
of something that I've never used and most users don't need.

Closes ElMassimo/vite_ruby#438, ElMassimo/vite_ruby#490, ElMassimo/vite_ruby#404

The problem seems to be here:

desc 'Remove old bundles created by ViteRuby'
task :clean, %i[keep age] => :'vite:verify_install' do |_, args|
within_engine_folder do
Maglev::Engine.vite_ruby.commands.clean_from_task(args)
end
end
but this is where I just don't know enough about what should be "proper" for deploys or not... it seems to make sense to remove this altogether given the above but I don't know enough about how Maglev intends to work with Vite ruby or really enough about Vite in general myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants