Skip to content

Commit

Permalink
fix: createHighlighter instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Jul 16, 2024
1 parent 09e9e01 commit 66a0390
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/witty-crews-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vocs": patch
---

Fixed excessive \`createHighlighter\` instantiation.
4 changes: 2 additions & 2 deletions src/vite/plugins/rehype/inline-shiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export type RehypeInlineShikiOptions = RehypeShikiCoreOptions & {
langs?: Array<LanguageInput | BuiltinLanguage>
}

let promise: Promise<Highlighter>

export const rehypeInlineShiki: Plugin<[RehypeInlineShikiOptions], Root> = function (
options = {} as any,
) {
Expand All @@ -25,8 +27,6 @@ export const rehypeInlineShiki: Plugin<[RehypeInlineShikiOptions], Root> = funct
) as BuiltinTheme[]
const langs = options.langs || Object.keys(bundledLanguages)

let promise: Promise<Highlighter>

return async function (tree) {
if (!promise)
promise = createHighlighter({
Expand Down

0 comments on commit 66a0390

Please sign in to comment.