Skip to content

Use importmap-rails for JS assets#8186

Merged
javierjulio merged 4 commits into
masterfrom
importmap-rails-js
Dec 26, 2023
Merged

Use importmap-rails for JS assets#8186
javierjulio merged 4 commits into
masterfrom
importmap-rails-js

Conversation

@javierjulio

Copy link
Copy Markdown
Member

For ActiveAdmin v4 the default will be importmap-rails for JS. This helps us simplify a lot for both sides as we can now provide JS assets to host app through the gem using Ruby instead of a NPM package. We should be able to support jsbundling-rails though, just the library and CI will only run against importmap-rails, so for now I'm not adding importmap-rails as a hard dependency, much like we are not with cssbundling-rails since a user should be able to use tailwindcss-rails if they want.

Since we need to have Tailwind scan the Flowbite JS for classes used, we already use the activeadmin gem path in the Tailwind config file, so we may as well just vendor this JS to make it easier.

It's been problematic to pin Flowbite as the builds from the supported providers don't work. We receive different errors in testing. The Flowbite docs suggest Cloudflare and that works fine when importing that URL. The jspm.org API doesn't support it which is what importmap-rails uses. So we are just vendoring the same file we would have pinned.
By using importmap-rails we no longer need an NPM package with these dependencies so we can remove them. It seems that they would need to be listed on the app host package.json file anyway from testing. We'll stick to serving the JS through importmap-rails as the only option.

Due to how we generate the dev/test apps for gem development, we need to specify tailwindcss as a devDependency in package.json since the config file will point to `../../` the project root.
Using importmap-rails will be easier for us to provide the JS for host app. With feedback we can see what we need to support jsbundling-rails without requiring a dependency on either gem. For tests and CI, we'll only use the importmap-rails approach.
@javierjulio javierjulio self-assigned this Dec 26, 2023
@codecov

codecov Bot commented Dec 26, 2023

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f74c392) 99.03% compared to head (bd119de) 99.03%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8186   +/-   ##
=======================================
  Coverage   99.03%   99.03%           
=======================================
  Files         151      151           
  Lines        4151     4163   +12     
=======================================
+ Hits         4111     4123   +12     
  Misses         40       40           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@javierjulio javierjulio merged commit 2a48c10 into master Dec 26, 2023
@javierjulio javierjulio deleted the importmap-rails-js branch December 26, 2023 18:06
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.

1 participant