Migration
We suggest you to migrate step by step, following each version's migration guide.
Migrate from v2.0
If you are on v2.0 and there is no warning in your usage, you should be able to directly bump to v3.0, read Shiki v3.0 for more details.
Migrate from v1.0
We recommend you to migrate to v2.0 first, then to v3.0.
Migrate from v0.14
The v1.0 release of Shiki is a major rewrite that we took the chance to revise every design decision we made in the past. We originally had a separate package name as Shikiji to experiment with the new design, now it's merged back to Shiki as v1.0.
Learn more
Interested in the story behind v1.0? Check out this blog post for more details.
Compare to shiki@0.14.3, the list of breaking changes are:
Hard Breaking Changes
Breaking changes that you need to migrate manually:
- CJS and IIFE builds are dropped. See CJS Usage and CDN Usage for more details.
codeToHtmluseshastinternally. The generated HTML will be a bit different but should behave the same.css-variablestheme is no longer supported. Use the dual themes approach instead, or learn more at the Theme Colors Manipulation page.
Soft Breaking Changes
Breaking changes applies to main package shiki, but are shimmed by the compatible build @shikijs/compat:
- Top-level named exports
setCDN,loadLanguage,loadTheme,setWasmare dropped as they are not needed anymore. BUNDLED_LANGUAGES,BUNDLED_THEMESare moved to@shikijs/langsand@shikijs/themesand renamed tobundledLanguagesandbundledThemesrespectively.themeoption forcreateHighlighteris dropped, usethemeswith an array instead.- Highlighter does not maintain an internal default theme context.
themeoption is required forcodeToHtmlandcodeToTokens. codeToThemedTokensis renamed tocodeToTokensBase, a higher levelcodeToTokensis added.codeToTokenssetsincludeExplanationtofalseby default..ansiToHtmlis merged into.codeToHtmlas a special language,ansi. Use.codeToHtml(code, { lang: 'ansi' })instead.lineOptionsis dropped in favor of the fully customizabletransformsoption.LanguageRegistration'sgrammarfield is flattened toLanguageRegistrationitself, refer to the types for more details.
Ecosystem Packages
shiki-twoslashhas been completely rewritten. It's no longer a wrapper around Shiki highlighter, but instead, it's now a Shiki transformer that can be plugged in any integrations that supports SHiki transformers. The package is now@shikijs/twoslash.- Integrations of
shiki-twoslash, likegatsby-remark-shiki-twoslashetc, will be slowly moved to a general Shiki version. Before that, you can use@shikijs/rehypeor@shikijs/markdown-itto integrate Shiki into those meta-frameworks. - New official integrations like
@shikijs/monaco,@shikijs/cli,@shikijs/rehype,@shikijs/markdown-itare introduced. shiki-renderer-pathandshiki-renderer-svgpackages are being deprecated due to low usage. If need them, please open an issue with your use case, we are open to bring them back.vuepress-plugin-shikiis deprecated as VuePress is no longer recommended. Its successor VitePress has a built-in Shiki integration.
Migrate from Shikiji
If you are already using Shikiji, first make sure you are on the latest minor v0.10. Then the migration should be very straightforward by renaming the packages:
shikiji->shikishikiji-core->@shikijs/coreshikiji-twoslash->@shikijs/twoslashshikiji-transformers->@shikijs/transformersshikiji-monaco->@shikijs/monacoshikiji-cli->@shikijs/climarkdown-it-shikiji->@shikijs/markdown-itrehype-shikiji->@shikijs/rehype