Skip to content

Commit

Permalink
fix using actiontext.js in sprocket
Browse files Browse the repository at this point in the history
actiontext.js is compiled as ESM bundle instead of UMD bundle.
This leads to issues when trying to use ActionText with sprockets because the ESM bundle declares variables like they are scoped to the file but sprockets will see them as scoped globally.
This is a problem, in particular, if you want to mix actiontext with
turbo-rails.

The problem got introduced in rails#46447.
I traced valid compilation back to
rails#42895.

This commit mimic changes made in
rails#42895 to ActiveStorage:
   Retains app/assets/javascripts/actiontext.js as a UMD package for backwards compatibility with
   bundling in the asset pipeline, but also adds app/assets/javascripts/actiontext.esm.js for use
   with ESM via importmap in the browser.
  • Loading branch information
mgrunberg committed Nov 7, 2023
1 parent 488a7ce commit 2dbcb3d
Show file tree
Hide file tree
Showing 10 changed files with 1,736 additions and 847 deletions.
8 changes: 8 additions & 0 deletions actiontext/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
* Compile ESM package that can be used directly in the browser as actiontext.esm.js

*Matias Grunberg*

* Fix using actiontext.js with Sprockets

*Matias Grunberg*

* Upgrade Trix to 2.0.7

*Hartley McGuire*
Expand Down
1 change: 1 addition & 0 deletions actiontext/app/assets/javascripts/.gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
actiontext.js linguist-generated
actiontext.esm.js linguist-generated
trix.js linguist-vendored
Loading

0 comments on commit 2dbcb3d

Please sign in to comment.