Solved this. I’d updated the Rails and Webpacker gem, but not the Webpacker npm module. Following through this GitHub issues I did the following:
yarn add @rails/webpacker
yarn add webpack-cli
bundle exec rails webpacker:install
And then followed the prompts.