Key is: use the hightlightjs shim.

Install it using yarn.

yarn add highlightjs

Inside one of your packs (or application.js), add:

import hljs from 'highlightjs'
hljs.initHighlightingOnLoad();