Use importmap-rails for JS assets#8186
Merged
Merged
Conversation
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.
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.