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

Stimulus.js via importmap #4392

Closed
wants to merge 14 commits into from
Closed

Stimulus.js via importmap #4392

wants to merge 14 commits into from

Conversation

martinemde
Copy link
Member

I've been working with Stimulus a bunch on another project and thought I would draft a quick conversion.

This doesn't take advantage of most of the stimulus features, but it's mostly loading and working (almost certainly things are broken and I will follow up)

I wanted to gauge the receptivity to this conversion. It is somewhat significant, but at least it doesn't add Node as a dependency and it brings us all the way to the most modern rails default. (I also drafted an esbuild branch, but adding yarn and a build step to this very javascript-light app felt like major overkill).

@martinemde martinemde marked this pull request as draft January 25, 2024 05:43
vendor/javascript/@rails--ujs.js Dismissed Show dismissed Hide dismissed
vendor/javascript/@rails--ujs.js Dismissed Show dismissed Hide dismissed
@simi
Copy link
Member

simi commented Jan 25, 2024

There are already other PRs touching on the JS assets pipeline. #3470 #4123 it would be good to get in sync and finally decide what to do in here. 🙏

I do like approach in this PR since I do prefer to stick with default Rails app as much as possible, to make it simple for new contributors to contribute, and stimulus is default Rails choice. 💪 Feel free to ping me if you need help with making this PR ✅.

@martinemde
Copy link
Member Author

martinemde commented Jan 25, 2024

@simi thank you for linking those. I had forgotten about them but now I remember seeing them. I think #4123 significantly overlaps and may have some of the fixes I needed to get.

I spent most of my time adapting the JavaScript to use stimulus and implemented importmap just to get it done.

I suggest these steps to move forward with this PR and #4123

  1. Get importmap working without changing sprockets (and without stimulus)
  2. Merge and deploy importmap, but still using sprockets for css etc.
  3. Progressively add stimulus one controller at a time so we can actually feel confident that they work.
  4. In parallel, once importmap is merged, make css asset changes as desired since the JS bundling won't interfere with the choice.
  5. Modern JavaScript and CSS!

@segiddins @hsbt how do you feel about that plan?

Copy link

codecov bot commented Jan 26, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (8c47cf5) 96.97% compared to head (e6b0dd2) 96.69%.
Report is 1 commits behind head on master.

Files Patch % Lines
app/helpers/api_keys_helper.rb 20.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4392      +/-   ##
==========================================
- Coverage   96.97%   96.69%   -0.28%     
==========================================
  Files         336      336              
  Lines        7477     7483       +6     
==========================================
- Hits         7251     7236      -15     
- Misses        226      247      +21     

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

@martinemde
Copy link
Member Author

I will extract and push one at a time from this branch on top of #4396.

@martinemde martinemde closed this Feb 1, 2024
@martinemde martinemde deleted the stimulus branch February 1, 2024 17:09
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