New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discuss: CDN builds should include ESM ready modules #3199
Comments
My key concern OTTOMH is the how/instructional side. We have a very clear process for using CJS modules via script tags: <script src=".../cdn-release@10.7.1/build/highlight.min.js"></script>
<script src=".../cdn-release@10.7.1/build/languages/go.min.js"></script> Two lines, done. Languages auto-register. Meanwhile for ESM: import hljs from 'highlight.js/lib/core';
import javascript from 'highlight.js/lib/languages/javascript';
hljs.registerLanguage('javascript', javascript); A bit more elbow grease... is this just expected? Is there a shorter form of writing that like you can with require (without forcing us to make our API async)? If we support ESM do people suddenly expect some sort of magic async API to make working with ESM easier? |
IF there were no other library changes that needed to be made then I think we could build a CDN ESM version and just include it in an
Although I suppose I'm open to alternative suggestions if there is a common standard - BUT I'm not sure that moving the CJS files from their historic places is desirable at this time... but I suppose that would leave open the argument for a bunch of |
@aduh95 If you're interesting I think this is quite likely as simple and taking the ESM build code I removed from |
I would like a very minimal cdn bundle... import hljs from 'highlight.js/lib/core';
if (hljs.supports(language)) {
// takes care of import()-ing the js parser for the respected cdn automatically
hljs.highlight(code, { language }).then(html => {
xyz.innerHTML = html
})
}
if (hljs.supports('js') || hljs.supports( 'javascript' )) {
// takes care of import()-ing the js parser for the respected cdn automatically
hljs.highlight(code, { language: 'js' }).then(html => {
xyz.innerHTML = html
})
} Right now i think that it only supports like 32 with the default bundle. but you do support more langauges than that... i want to support every language that you support (lazily). |
This bundle already exists (CDN build):
This currently does not exist. This would require several complexities be resolved before it could exist in core:
I'm probably forgetting things, you'd have to skim several of these threads - I've definitely written on this subject before. Also, see #2405. Right now I'm unconvinced that this isn't better handled by a wrapper outside of core such as say a new |
Originally posted by @joshgoebel in #3188 (comment)
The text was updated successfully, but these errors were encountered: