2dbcb3df33
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 https://github.com/rails/rails/pull/46447. I traced valid compilation back to https://github.com/rails/rails/pull/42895. This commit mimic changes made in https://github.com/rails/rails/pull/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.
42 lines
775 B
JavaScript
42 lines
775 B
JavaScript
import resolve from "@rollup/plugin-node-resolve"
|
|
import commonjs from "@rollup/plugin-commonjs"
|
|
import { terser } from "rollup-plugin-terser"
|
|
|
|
const terserOptions = {
|
|
mangle: false,
|
|
compress: false,
|
|
format: {
|
|
beautify: true,
|
|
indent_level: 2
|
|
}
|
|
}
|
|
|
|
export default [
|
|
{
|
|
input: "app/javascript/actiontext/index.js",
|
|
output: {
|
|
file: "app/assets/javascripts/actiontext.js",
|
|
format: "umd",
|
|
name: "ActionText"
|
|
},
|
|
plugins: [
|
|
resolve(),
|
|
commonjs(),
|
|
terser(terserOptions)
|
|
]
|
|
},
|
|
|
|
{
|
|
input: "app/javascript/actiontext/index.js",
|
|
output: {
|
|
file: "app/assets/javascripts/actiontext.esm.js",
|
|
format: "es"
|
|
},
|
|
plugins: [
|
|
resolve(),
|
|
commonjs(),
|
|
terser(terserOptions)
|
|
]
|
|
}
|
|
]
|