I use lit webcomponents with the vite + typescript template. Now i am trying to create my own code block web-component. For syntax highlighting I wanted to use prism js, so i went to their page, selected my favorite languages, downloaded both css and js file and tried adding them to my webcomponent.
I just copy-pasted the css file into an css``
, which should work just fine. But i am rather lost on how to add the js file.
Here is what i did to use the .js file:
- Set
"allowJs": true
in the tsconfig.json. import * as prism from '../prism.js';
in myFile.ts, where i have my component.
But even if i just try to run prism.highlightAll()
I get.
Uncaught TypeError: prism.highlightAll is not a function
at myFile.ts:116:19
I am still rather new to the js/ts ecosystem so any help is greatly appreciated.