react-syntax-highlighter: Uncaught TypeError: hljs.getLanguage(...).rawDefinition is not a function
Describe the bug
Receiving the following error with Highlight.js 9.16.2.
Uncaught TypeError: hljs.getLanguage(...).rawDefinition is not a function
Reporting this on behalf of @mattwhocn. Was originally filed against Highlight.js:
https://github.com/highlightjs/highlight.js/issues/2279
To Reproduce Steps to reproduce the behavior:
- Try using
react-syntax-highlighter
with Highlight.js 10.16.2 - See issue I imagine (see additional context below)
Sorry I don’t have more specific steps.
Expected behavior The library works as expected without throwing the error:
Uncaught TypeError: hljs.getLanguage(...).rawDefinition is not a function
Desktop: Dunno. Pretty sure this is not environment specific. (see addl. context)
Smartphone: Dunno. Pretty sure this is not environment specific. (see addl. context)
Additional context
You have created a very custom loading process for languages. Newer versions of Highlight.js have stronger interconnections between languages. cpp
needs to be registered BEFORE arduino
can be registered as they now depend on each other at run-time (during registration).
Not sure what might need to change to fix this, but wanted to file it here as it seems to be a problem with how you all are packaging/loading the languages.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18
I only skimmed but I think my answers remain the same as before:
Requires:
meta-data in the languages files to build your own dependency tree.index
file to decide “proper” load order.Long-term we might switch to modules everywhere and move away from run-time dependencies but that’s probably a 2021 thing, and I don’t see a big rush. Newer work we’re doing (like pulling ECMAscript out into a dependency of JS, TS, Livescript, Coffeescript, etc) is all module based rather than run-time to avoid these issues entirely.
I’ve been working on other things but when I have a PR with the tree stuff I’ll ping you and you can play with it and give feedback.
This is what I’d expect you to see:
https://github.com/conorhastings/react-syntax-highlighter/issues/10