rails / cssbundling-rails

Bundle and process CSS in Rails with Tailwind, PostCSS, and Sass via Node.js.
MIT License
563 stars 83 forks source link

Regression: Rake task methods override each other #131

Closed excid3 closed 9 months ago

excid3 commented 9 months ago

Rake task files that define methods end up in a global namespace, which means that cssbundling-rails and jsbundling-rails now conflict as they both define build_command.

https://github.com/rails/cssbundling-rails/blob/2f2945e74fb492ebecfd42fff11c0d206f67e7c0/lib/tasks/cssbundling/build.rake#L26C8-L26C8

To reproduce the issue, have a project with both cssbundling-rails and jsbundling-rails in it.

± rails css:build
yarn install v1.22.19
[1/4] 🔍  Resolving packages...
success Already up-to-date.
✨  Done in 0.05s.

From: /Users/chris/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/cssbundling-rails-1.3.0/lib/tasks/cssbundling/build.rake @ line 12 :

     7:     end
     8:   end
     9:
    10:   desc "Build your CSS bundle"
    11:   build_task = task :build do
 => 12:     binding.irb
    13:     command = build_command
    14:     unless system(command)
    15:       raise "cssbundling-rails: Command build failed, ensure `#{command}` runs without errors"
    16:     end
    17:   end

irb(main):001:0> method(:build_command)
=> #<Method: Object#build_command() /Users/chris/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/jsbundling-rails-1.2.0/lib/tasks/jsbundling/build.rake:27>
jaybloke commented 9 months ago

Also experiencing the same problem - had to revert back to jsbundling-rails 1.1.2 and cssbundling-rails 1.2.0