Hightlight.js basically have two main modes of usage:
The one you complain about is specifically about importing everything, because that's what the user wants in that case, importing it like that signals that that's what the user wants.
Otherwise you can do the following:
import hljs from 'highlight.js/lib/core';
import javascript from 'highlight.js/lib/languages/javascript';
hljs.registerLanguage('javascript', javascript);
Maybe the defaults should be different, but a 30 second read of the most basic information available in the repository would reveal how you can use it the way you want too, without any complication that the rest of your comment seems to want to introduce.
90% of time people will use the default unless it doesn't work for them. So if you used a default with a popular language, many people would try copy-pasting and it would "not work" because they didn't substitute their own language.
They'd move begin searching for a new solution.
Some would recognize they should substitute their language.
Then a tiny fraction of users will actually read your documentation :)
If you're making software for actual end-users, your point has merit. If you are creating a library for programmers to import into their own projects, nope, sorry, RTFM (at least the first part of it) or get lost.
But that's what my code does, albeit my code loads only on demand (plus can be easily improved to load any further language dynamically), whereas your code statically bundles everything into the main bundle (if not using proprietary Webpack chunk comments, which I see as antipatterns).
But I agree with you, that you probably want to only load it when really needed, especially if your total budget is 500kb which this would take a big part of it already.
Edit: I see now their budget was actually more than 1MB actually, as they for some reason only "really care" about gzip'd sizes... Then I wouldn't say it's so bad to just say fuck it and do it the easy way. Saves any latency introduced by lazy-loading it too.
Dynamic imports aren't unique to webpack, they're a standard feature.
The two different variants written are six of one half a dozen of the other. There's nothing stopping you from writing the imports + register in one file and dynamically importing it in a dom loaded event in another.
The one you complain about is specifically about importing everything, because that's what the user wants in that case, importing it like that signals that that's what the user wants.
Otherwise you can do the following:
Maybe the defaults should be different, but a 30 second read of the most basic information available in the repository would reveal how you can use it the way you want too, without any complication that the rest of your comment seems to want to introduce.