Skip to content

Conversation

@stephannv
Copy link
Contributor

@stephannv stephannv commented Nov 18, 2024

Make generators compatible with importmaps. Some js packages I had to point to jsdelivr +esm because using bin/importmap pin motion would download the wrong file and get a lot of errors. I'm not sure if there is a way to use correct file using pin command.

ps. Using this branch I could generate a Rails app from scratch and I could use RubyUI components (+ their javascripts) using only our generators.

@stephannv stephannv self-assigned this Nov 18, 2024
Comment on lines +109 to +111
when "motion"
pin_motion
when "tippy.js"
Copy link
Contributor Author

@stephannv stephannv Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two packages didn't play well with importmaps, so I'm pointing to remote cdn. My first take was to download the file and add to vendor/javascript folder and add pin "motion" to config/importmap.rb, but I'm not sure if that was the best option, because it could go wrong if user tried to update/redownload the packages. If think it's safer to point to CDN and let the users download the file if they want.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stephannv , this is fine. Tippy.js will be replaced by floating-ui, and motion is used on the Accordion, but I don't think we need any dependency there. In other words, it's fine, and we should remove both dependencies soon.

Comment on lines +60 to +64
if File.exist?(Rails.root.join("tailwind.config.js")) # tailwindcss js package
template "tailwind.config.js.js-package.erb", Rails.root.join("tailwind.config.js")
elsif File.exist?(Rails.root.join("config/tailwind.config.js")) # tailwindcss-rails gem
template "tailwind.config.js.tailwindcss-rails.erb", Rails.root.join("config/tailwind.config.js")
else
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rails apps using importmaps use tailwindcss-rails gem, the config file is located on config folder and uses a slightly different file content but I think it was enough to create 2 separated templates, I think it was easier than trying inject pieces of code conditionally.

Copy link
Collaborator

@cirdes cirdes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great!!

Comment on lines +109 to +111
when "motion"
pin_motion
when "tippy.js"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stephannv , this is fine. Tippy.js will be replaced by floating-ui, and motion is used on the Accordion, but I don't think we need any dependency there. In other words, it's fine, and we should remove both dependencies soon.

@stephannv stephannv merged commit 5ec5879 into ruby-ui:main Nov 18, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants