Rails 6 to 7 upgrade javascript not loading

I am trying to upgrade a project from Rails 6 to Rails 7.

Gemfile

ruby '3.1.2'
gem 'rails',           '7.0.4'
gem "sassc-rails",     '2.1.2'
gem "sprockets-rails", "3.4.2"
gem "importmap-rails", "1.1.0"
gem "turbo-rails",     "1.1.1"
gem "stimulus-rails",  "1.0.4"
gem "jbuilder",        "2.11.5"
gem "puma",            "5.6.4"
gem "bootsnap",        "1.12.0", require: false
gem 'sass-rails',      '6.0.0'

app/assets/config/manifest.js

// link_directory ../javascripts .js
//= link_tree ../images
//= link_directory ../stylesheets .css
//= link_tree ../../javascript .js
//= link_tree ../../../vendor/javascript .js

config/importmap.rb

pin "application", preload: true
pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
pin_all_from "app/javascript/controllers", under: "controllers"
pin_all_from "app/javascript/custom",      under: "custom"

app/javascript/application.js

import "@hotwired/turbo-rails"
import "controllers"
import "custom/menu"
alert('hello');

I have moved all my javascript files from app/assets/javascripts/ to app/javascript/ (all except the old application.js which remains in assets).

The javascript in app/javascript/application.js should be loaded, which means an alert box with “hello” in should appear, but it does not. Where am I going wrong?