Import maps let you import JavaScript modules using logical names that map to versioned/digested files – directly from the browser. This will be a default in the upcoming Rails 7.
Use esbuild to bundle your JavaScript, then deliver it via the asset pipeline in Rails. This gem provides an installer to get you going with esbuild in a new Rails application.