Skip to content
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

perf: use Shiki shorthand #2026

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

kermanx
Copy link
Member

@kermanx kermanx commented Jan 29, 2025

This speeds up the demo slides' start-up time (from running the command to printing the URLs) by almost 2s on my machine.

Copy link

netlify bot commented Jan 29, 2025

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit 00f9ce4
🔍 Latest deploy log https://app.netlify.com/sites/slidev/deploys/679b4e16956e1100082e51e9
😎 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 site configuration.

Copy link

pkg-pr-new bot commented Jan 29, 2025

Open in Stackblitz

create-slidev

npm i https://pkg.pr.new/slidevjs/slidev/create-slidev@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/client

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

@slidev/types

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

create-slidev-theme

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

commit: 00f9ce4

@@ -57,8 +57,7 @@ export type ShikiSetupReturn =
& CodeOptionsThemes<BuiltinTheme>
& CodeOptionsMeta
& {
setup: (highlighter: Highlighter) => Awaitable<void>
Copy link
Member Author

Choose a reason for hiding this comment

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

It seems that this function is never called. And I don't know how to support it because there's no longer a Highlighter

Copy link
Member

Choose a reason for hiding this comment

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

We can get the highlighter with:

  const shiki = createSingletonShorthands<string, string>(createHighlighter)
  const highlighter = await shiki.getSingletonHighlighter()

But I don't mind removing it if no one uses it

@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 }),
Copy link
Member Author

@kermanx kermanx Jan 30, 2025

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.

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