Skip to content

perf: use Shiki shorthand#2026

Merged
antfu merged 11 commits into
slidevjs:mainfrom
kermanx:perf/use-shiki-shorthand
Nov 18, 2025
Merged

perf: use Shiki shorthand#2026
antfu merged 11 commits into
slidevjs:mainfrom
kermanx:perf/use-shiki-shorthand

Conversation

@kermanx

@kermanx kermanx commented Jan 29, 2025

Copy link
Copy Markdown
Member

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.ts was 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.ts also runs in the browser environment, and no longer requires serialization.

@netlify

netlify Bot commented Jan 29, 2025

Copy link
Copy Markdown

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit fa021f6
🔍 Latest deploy log https://app.netlify.com/projects/slidev/deploys/6919e635cc4c850008c956be
😎 Deploy Preview https://deploy-preview-2026--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Jan 29, 2025

Copy link
Copy Markdown

Open in StackBlitz

@slidev/client

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/client@2026

create-slidev

npm i https://pkg.pr.new/slidevjs/slidev/create-slidev@2026

create-slidev-theme

npm i https://pkg.pr.new/slidevjs/slidev/create-slidev-theme@2026

@slidev/parser

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/parser@2026

@slidev/cli

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/cli@2026

@slidev/types

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/types@2026

commit: fa021f6

Comment thread packages/types/src/setups.ts
@kermanx
kermanx marked this pull request as draft January 29, 2025 03:23
@kermanx
kermanx marked this pull request as ready for review January 30, 2025 04:52
Comment on lines +10 to +12
// trigger the shiki to load the langs
shiki.codeToHast('', { lang: 'js', ...shikiOptions }),
shiki.codeToHast('', { lang: 'ts', ...shikiOptions }),

@kermanx kermanx Jan 30, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 😇

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried removing the workaround, and it seems that everything works fine. I am not sure whether this workaround is still needed.

@kermanx
kermanx requested a review from antfu November 16, 2025 14:58
@antfu
antfu merged commit 16dfe4c into slidevjs:main Nov 18, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants