I have “a few” JS lines of code in my custom Hugo theme. The problem with this code is that I’m forced to write ancient (ES5) JS to make sure that it’s as backwards compatible as possible. With Hugo v0.70 and its Babel support I hoped that I could write modern JS and transpile it into ES5, and it kind of works: syntax like arrow functions are transformed and
imports to core-js polyfills are included by Babel. The problem is that I’m unable to bundle it, as it seems that webpack/rollup/etc is needed for this matter, and none of them are supported by Hugo.
Am I right so far? I know that I could do something similar to what gohugoioTheme does: install webpack in that repo, build the bundle, commit it to the repo, and reference the bundle (and not the original files) from the template. But I haven’t need webpack for anything else and I’d love to have a modern JS experience with Hugo as good as the one with SCSS.
I’d love to see Hugo handle (compile) ES6+ code out of the box as it does with SCSS