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

feat(vitepress-twoslash): cache type informations to improve performance #798

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nakasyou
Copy link

@nakasyou nakasyou commented Oct 4, 2024

Description

VitePress Twoslash takes a long time to render large Types.
This PR solves part of this.

This PR can cache type information with the following code:

export default defineConfig({
  markdown: {
    codeTransformers: [
      transformerTwoslash({
        typesCacheDir: './my-custom-cache-dir'
      })
    ]
  }
})

This will cache the type information in the specified directory.
Use a cache such as GitHub Actions with this to speed up your builds

Linked Issues

Nothing

Additional context

ElysiaJS appears to have cut back on Twoslash because it took 30 minutes to build the documentation. This PR may resolve it.
https://x.com/saltyAom/status/1842140132897615963

Copy link

netlify bot commented Oct 4, 2024

Deploy Preview for shiki-matsu ready!

Name Link
🔨 Latest commit 74575bc
🔍 Latest deploy log https://app.netlify.com/sites/shiki-matsu/deploys/66fffb190951ef000910cf20
😎 Deploy Preview https://deploy-preview-798--shiki-matsu.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

netlify bot commented Oct 4, 2024

Deploy Preview for shiki-next ready!

Name Link
🔨 Latest commit 74575bc
🔍 Latest deploy log https://app.netlify.com/sites/shiki-next/deploys/66fffb195a9ad60008c78f72
😎 Deploy Preview https://deploy-preview-798--shiki-next.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.

@nakasyou nakasyou changed the title feat(vitepress-twoslash): cache type infomations feat(vitepress-twoslash): cache type informations to improve performance Oct 6, 2024
@antfu
Copy link
Member

antfu commented Oct 24, 2024

Sorry it might take a bit longer for me to refactor it a bit to make the logic a bit decoupled - if you want to help with that, could you make typesCacheDir a generic map like typesCache where users could provide their own implementation of how to handle the cache, and then refactor the current logic to a standalone createFilesystemTypesCache(options) factory? Thanks

@nakasyou
Copy link
Author

Hi @antfu, thank you for commenting.

You mean

const typesCache = createFileSystemTypesCache(options)

transformerTwoslash({
  typesCache
})

, right?

@antfu
Copy link
Member

antfu commented Oct 26, 2024

Yes, something like that

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