Modern Front-End Development for Rails: Typo/Correction? import * as Channels for application.ts

Page 15 shows these imports for the conversion of application.js to application.ts

import * as ActiveStorage from "@rails/activestorage"
import Rails from "@rails/ujs"
import * as Channels from "channels"
import Turbolinks from "turbolinks"

However I had to change the Channels import to the following to get a build:

// from @rails/actioncable not channels
import * as Channels from "@rails/actioncable"

Environment: Ruby 2.7.1 Rails 6.0.3.2 Ubuntu 20 LTS

2 Likes

This works without the changes on 6.1.1 and Ruby 3.0.0 (and probably 2.7.x) as-of January 20, 2021. The intro (beta 6 as-of August 2020) said to use edge Rails (6.1 prerelease on master), and it might have worked on master before 6.1.x officially released.

1 Like