You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If theme or themes is empty when using getHighlighter, then the nord theme will be loaded by default. This results in an unnecessary theme load for situations where the theme needs to be loaded dynamically (or an unnecessary theme resource request in the browser environment).
For example:
// Here there will be an unwanted `nord` theme load.// Because later the required theme will be loaded dynamically depending on the situation.consthighlighter=awaitshiki.getHighlighter({})exportasyncfunctionhighlight(code,lang,theme){// Here the real theme will be loaded, e.g. `github-dark`awaithighlighter.loadTheme(theme)returnhighlighter.codeToHtml(code,{ lang, theme })}
Can we remove the default theme logic here? Or a way to disable it in the above situations. Thanks :)
Give that this would be a massive breaking change, it probably shouldn't happen this way unless it ends up in the 1.0 changes in #424 and is very well documented
Perhaps passing null could be accepted as the theme and have this behavior instead
I agree that removing the logic here directly may produce incompatible changes, although the documentation doesn't explicitly mention that the default theme will be loaded, it may be the default behavior when the user relies on not passing theme.
If, as you say, we remove the loading of the default theme when the user is shown using theme: null or themes: null, would this be acceptable as a patch version of v0.14?
If
theme
orthemes
is empty when usinggetHighlighter
, then thenord
theme will be loaded by default. This results in an unnecessary theme load for situations where the theme needs to be loaded dynamically (or an unnecessary theme resource request in the browser environment).For example:
Can we remove the default theme logic here? Or a way to disable it in the above situations. Thanks :)
shiki/packages/shiki/src/highlighter.ts
Lines 43 to 45 in b8e88e6
(Willing to contribute a PR for this)
The text was updated successfully, but these errors were encountered: