-
Notifications
You must be signed in to change notification settings - Fork 18
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
Support jsbundling #12
Comments
Yes @adrienpoly. We only support importmaps for now. In any case I'll leave this open as we should handle that more gracefully. |
I think it'd be good if that was explicit in the readme, it'll save a lot of unnecessary issues being opened 😅 |
This was also my first question :-) |
I think a path here would be to add a new endpoint to return the source given a stimulus controller path. That would let us use a unified reloader that works with both jssbundling and importmaps. It would also simplify not having to parse the import maps or reload the HTML document before that. I'll take a stab at this this week. |
I think this change will make Hotwire Spark compatible with jsbundling and other alternatives. Tomorrow I'll test and confirm. I'd appreciate it if anyone gives that branch a try to confirm too. |
I had a go with the default hello controller - adding the controller to a view updates the html as expected. Modifying the textContents string reloads but returns: This includes re running the server post install and double checking my gemfile.lock:
On a fresh rails install @8.0.1 with jsbundling |
I gave it a try on our App, Rails 8 /JS bundling / CSS Bundling The error is gone. As far as I could tell the changes in the HTML, JS, and CSS are captured and the page is refreshed. Might be something with our app??? |
This is not working to provide hot-reloading for stimulus controllers under jsbundling. Check my reply to @kobaltz here. I'll play a bit more with the approach, but I'm afraid a saner way for jsbundling will be to get this merged and use replaces instead of morphing for the jsbundling path. |
Hey @adrienpoly did you try this branch by any chance? That's the only branch that should be triggering a new turbo visit here 🤔 |
I went with a different approach here. It will now detect jsbundling and configure some dedicated options: instead of trying to hot-reload stimulus controllers, it will reload the current page with Turbo (new option introduced by #40). The problem with hot reloading with jsbundling are dependencies: the browser can't resolve those outside of the bundling environment, so enabling hot-reloading is a much more complex endeavour than when using importmaps. |
I did some more investigating and it is an issue on my side with some legacy esbuild reload that I put in place. Will do some more testing but it is looking good as fare as I could tell |
I'm closing this as jsbundling will work fine now. I'll be happy to consider hot-reloading for stimulus controllers within this path too if something comes with a good idea that isn't terribly complex. |
I am going to try hotwire-spark with Ruby Vite. The HMR of RubyVite is amazing. I think there is a sweet spot between Spark html morph updates and RubyVite HMR for JS/CSS. This could be an advanced path to get HMR without importmaps without making Spark too complex neither |
@SyedMSawaid have you updated to latest? Also, it could be a caching issue (304 response and, thus, not updating the JS library file). Try disabling the cache to see if that fixes it. |
I gave it a spin a our app using css_bundling and js_bundling
updating the html works but I am getting this error in the console.
I suppose it is because I don't have importmaps in my app
Given that it seems to work I think it would be best to silence this error
The text was updated successfully, but these errors were encountered: