perf: use Shiki shorthand#2026
Conversation
✅ Deploy Preview for slidev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
@slidev/client
create-slidev
create-slidev-theme
@slidev/parser
@slidev/cli
@slidev/types
commit: |
| // trigger the shiki to load the langs | ||
| shiki.codeToHast('', { lang: 'js', ...shikiOptions }), | ||
| shiki.codeToHast('', { lang: 'ts', ...shikiOptions }), |
There was a problem hiding this comment.
This is an ugly workaround 🥲
I tried passing lang and langAlias to transformerTwoslash, but it either complains "language not loaded" or doesn't transform the code.
There was a problem hiding this comment.
I want to work on that to have codeToHast able to load grammars on demand - but that would requires quote some changes to the codebase to provide an async version of shiki - which I not yet have time to work on it properly 😇
There was a problem hiding this comment.
I just tried removing the workaround, and it seems that everything works fine. I am not sure whether this workaround is still needed.
This speeds up the demo slides' start-up time (from running the command to printing the URLs) by almost 2s on my machine.
Previously,
setup/shiki.tswas documented to run in BOTH environments, but was actually only run on Node and the options (including custom grammars) were serialized and sent to the frontend via#slidev/shiki. In this PR,setup/shiki.tsalso runs in the browser environment, and no longer requires serialization.