From f27ec147bd1663ee01d9de412172e3e9b11e6208 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 2 Jan 2024 22:20:39 +0100 Subject: [PATCH] Spell out Rails dependencies manually --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index b5969dd..3f6d0b3 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,15 @@ Importmap for Rails is automatically included in Rails 7+ for new applications, Note: In order to use JavaScript from Rails frameworks like Action Cable, Action Text, and Active Storage, you must be running Rails 7.0+. This was the first version that shipped with ESM compatible builds of these libraries. +You can pin those libraries manually by relying on the compiled versions included in Rails like this: + +```ruby +pin "@rails/actioncable", to: "actioncable.esm.js" +pin "@rails/activestorage", to: "activestorage.esm.js" +pin "@rails/actiontext", to: "actiontext.esm.js" +pin "trix" +``` + ## How do importmaps work? At their core, importmaps are essentially a string substitution for what are referred to as "bare module specifiers". A "bare module specifier" looks like this: `import React from "react"`. This is not compatible with the ES Module loader spec. Instead, to be ESM compatible, you must provide 1 of the 3 following types of specifiers: