question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught TypeError: hljs.getLanguage(...).rawDefinition is not a function

See original GitHub issue

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:

  1. Try using react-syntax-highlighter with Highlight.js 10.16.2
  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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18

github_iconTop GitHub Comments

1reaction
joshgoebelcommented, Jul 31, 2020

I only skimmed but I think my answers remain the same as before:

  • Build and load a monolith JS build (letting us handle the dependencies and load order)
  • Use the Requires: meta-data in the languages files to build your own dependency tree.
  • Use the order of languages in the 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.

1reaction
joshgoebelcommented, Nov 16, 2019

Again, that is exactly what I want.

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: hljs.getLanguage(...).rawDefinition is not ...
when my code run in development with webpack it works fine, but when i build it and run at my website, it went...
Read more >
How to use highlight.js
The bare minimum to auto-detect the language and highlight some code. // load the library and ALL languages hljs = require('highlight.js'); html =...
Read more >
How can I add language aliases to highlightjs? - Stack Overflow
So it recognizes src-emacs-lisp as scheme rather than elisp or just lisp . So for the list of aliases, how do I configure...
Read more >
Core API — highlight.js 11.7.0 documentation - Read the Docs
Core highlighting function. Accepts the code to highlight (string) and a list of options (object). The language parameter must be present and specify...
Read more >
jQuery Error .unhighlight is not a function [#2618264] - Drupal
Hi. while typing something in my search field I get the following jQuery Errors: TypeError: facResult.find(...).unhighlight is not a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found