The dev team and I have been in the process of moving our current setup from webpack to esbuild. We have some coffeescript files that rely on actioncable. Actioncable has completely stopped since removing webpacker dependencies/webpack-dev-server. Does anyone know how to get actioncable to run at the window level, so that our coffeescript files can access it? We used sockjs-node for our webpack setup and need to get the same results with esbuild.
package.json
{
"name": "app",
"private": "true",
"dependencies": {
"@rails/actioncable": "^7.0.0"
"@hotwired/turbo-rails": "^7.0.1",
"@popperjs/core": "^2.10.2",
"bootstrap": "^5.1.1",
"esbuild": "^0.13.3",
"esbuild-rails": "^1.0.3",
"sass": "^1.42.1"
},
"scripts": {
"build": "node esbuild.config.js",
"build:css": "sass ./app/assets/stylesheets/application.bootstrap.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules"
}
}
esbuild.config.js
const path = require('path')
const rails = require('esbuild-rails')
require("esbuild").build({
entryPoints: ["application.js"],
bundle: true,
outdir: path.join(process.cwd(), "app/assets/builds"),
absWorkingDir: path.join(process.cwd(), "app/javascript"),
watch: process.argv.includes("--watch"),
plugins: [rails()],
}).catch(() => process.exit(1))
application.js
import actioncable from "actioncable"