docusaurus: prism.additionalLanguages broken in v2

πŸ› Bug Report

themeConfig.prism.additionalLanguages seems to be broken in the most recent v2 alpha.

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

  • Create a new docusaurus app using 2.0.0-alpha.50.
  • In docusaurus.config.js within themeConfig add
    prism: {
      additionalLanguages: [ 'crystal' ] // Or any language
    }
    
  • Run npm start

Expected behavior

Things should build correctly and syntax highlighting should work with the requested language

Actual Behavior

The following error is shown in the teminal:

TypeError: Cannot read property 'originalSource' of undefined
    at getSourceById (/home/username/projectname/node_modules/react-dev-utils/evalSourceMapMiddleware.js:18:17)
    at handleWebpackInternalMiddleware (/home/username/projectname/node_modules/react-dev-utils/evalSourceMapMiddleware.js:37:22)
    at Layer.handle [as handle_request] (/home/username/projectname/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/home/username/projectname/node_modules/express/lib/router/index.js:317:13)
    at /home/username/projectname/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/home/username/projectname/node_modules/express/lib/router/index.js:335:12)
    at next (/home/username/projectname/node_modules/express/lib/router/index.js:275:10)
    at SendStream.error (/home/username/projectname/node_modules/serve-static/index.js:121:7)
    at SendStream.emit (events.js:315:20)
    at SendStream.error (/home/username/projectname/node_modules/send/index.js:270:17)
    at SendStream.onStatError (/home/username/projectname/node_modules/send/index.js:421:12)
    at next (/home/username/projectname/node_modules/send/index.js:735:16)
    at onstat (/home/username/projectname/node_modules/send/index.js:724:14)
    at FSReqCallback.oncomplete (fs.js:171:21)

Your Environment

  • Docusaurus version used: 2.0.0-alpha.50
  • Environment name and version :
    • Mozilla Firefox 74.0.1
    • NodeJS v13.12.0 (also tried with 12, 11, and 10)
  • Operating system and version (desktop or mobile): Arch Linux 5.5.13-arch2-1

Reproducible Demo

https://github.com/watzon/dousaurus-testapp

Literally a brand new app with the aforementioned section added to the config.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

For anyone having a similar problem.

Here’s how to fix it for the sparql language:

  • run cat node_modules/prismjs/components/prism-sparql.js
  • see Prism.languages.extend('turtle' in source code
  • use additionalLanguages: ['turtle', 'sparql']

The process should be similar to any language requiring extensions

@franck-grenier i solved the issue by restarting the devlopment server

Fix for scala:

     prism: {
       additionalLanguages: ['java', 'scala'],
     },

@lex111 I tried that as well. I still get the same error in the terminal, and in the browser console I get Error: Cannot find module './prism-ruby'.

@slorber, amazing. Many thanks!

Ok well I got it working locally. I was using asdf to version node, so I uninstalled the asdf node plugin and installed node using my system package manager. Now things work.