What is the future of reusing JS in the rails? Should we move everything to npm?

(I actually think I found some answers from Webpacker presents a more difficult OOB experience for JS Sprinkles than Sprockets did).

We have two platforms. Both rails 5 and we are currently migrating them to rails 6. We would like to share a common “feature” between the two. Feature is - upload file, process it, show some result. There are css, js, images, a controller.

My question is, in the long run - next 4-5 years, what is the recommended way to reuse the js? What should we aim for? Guidance would be very helpful.

  1. With a rails engine we can reuse the controller.

  2. With a rails engine and sprockets we can reuse css, images,

  3. But for the js it is not clear - I read more and more about moving the js entirely to npm and getting it with webpack. People share that you should even try skipping webpacker and us directly webpack. (source - https://github.com/rails/webpacker/issues/57, https://github.com/rails/webpacker/issues/348). But there is also the webpacker engine support which people seem to get working, but have issues with (again - the above two threads).

  4. Rails 6 recommends webpacker for js and sprockets for others, but if we have to manage a gem and a npm package we are probably better of just moving everything in the npm package - css, images, js.

  5. There are no guides about this on https://guides.rubyonrails.org/.

Should we even aim for keeping any js in gems/engines or we should move all of it to npm even when it makes no sense (as this js makes no sense without the view, controller, css, images)?

Recently I moved everything to sprockets. Sprockets loads only necessary files. Webpacker adds useless load to client. I am sad to know that sprockets not developing actively.