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
Question about _fetchJSONAssets
#439
Comments
It was before my time, but I'd guess because the vscode parser uses jsonc then folks probably add comments to the JSON files - there could maybe be a processing step in this repo to allow them to be converted to something JSON.parse could handle during a deploy though |
I see, yeah that would be great (unless people supply their own language/theme files at runtime). Another option is that we try JSON.parse and then fall back to jsonc-parser if it throws. I'd be happy to put up a PR for that, if that sounds good to you. |
I think trying JSON parse then falling back is a good answer 👍🏻 |
That 270ms difference is surprising - I wonder if VS Code itself tries to side-step that. |
This improves the parsing time for themes and grammars by first using `JSON.parse` and then falling back on `jsonc-parser`. Since all of the themes and grammars currently checked in are valid JSON, this speeds up startup time considerably: ``` import shiki from './packages/shiki/dist/index.js' import { hrtime } from 'process'; const start = hrtime() const highlighter = await shiki.getHighlighter({ theme: 'nord'}); console.log(hrtime(start)[1] / 1e6) ``` This goes from ~420ms to ~185ms on my machine. Fixes shikijs#439
Hello again,
I'm wondering why
_fetchJSONAssets
usesjsonc-parser
instead ofJSON.parse
. It looks like all of the bundled themes and languages are valid JSON:_fetchJSONAssets
takes around 300ms right now, but switching it toJSON.parse
brings it down to 30ms. I ask because this is the source of a noticeable delay in start up time for https://github.com/banga/git-split-diffs.The text was updated successfully, but these errors were encountered: