Our great sponsors
-
importmap-rails
Use ESM with importmap to manage modern JavaScript in Rails without transpiling or bundling.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
Import Maps is the pattern being shipped with a default Rails 7 application. It makes use of a feature where JavaScript modules that would typically be installed with a package manager, such as Yarn or npm, and in most cases transpiled and bundled into a .js file can be imported directly into the browser and used in your application without an extra build step.
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails import "@hotwired/turbo-rails" import "controllers" import "trix" import "@rails/actiontext" // Importing the home.js script here! import "./home" import LocalTime from "local-time" LocalTime.start()
The Rails team has made available the jsbundling-rails gem that streamlines configuring your application with esbuild, Webpack or Rollup along with [cssbundling-rails](https://github.com/rails/cssbundling-rails) which is the equivalent to manage CSS bundling. Yarn is used in this case.