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: use slim shiki build and pre-compiled languages #1519

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

Conversation

nperez0111
Copy link
Contributor

This significantly cuts down on the bundle size of the package by leveraging shiki's new slim builds and precompiled languages

Fixes #1487 #1213

This could probably be reduced further by completely separating the default languages, but for this would require a breaking change to the API for code blocks to properly work.

The ideal would be for the user to specifically pick which languages and themes for the code block feature, rather than us providing any defaults for this.

Perhaps we can have defaults built into a separate package? To make it easier for those already using us?

Either way, this would require some thought, while the current change would still be compatible with the current API

Copy link

vercel bot commented Mar 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
blocknote ❌ Failed (Inspect) Mar 16, 2025 1:18pm
blocknote-website ❌ Failed (Inspect) Mar 16, 2025 1:18pm

Copy link
Collaborator

@YousefED YousefED left a comment

Choose a reason for hiding this comment

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

This is great!

If I understand it correctly; this mostly makes sure unused languages that are not in our "defaultSupportedLanguages" don't appear in the app output. However, languages that are, of course still appear in the app output. correct?

The ideal would be for the user to specifically pick which languages and themes for the code block feature, rather than us providing any defaults for this.

Perhaps we can have defaults built into a separate package? To make it easier for those already using us?

I think it's worthwhile to tackle the issue completely and invest a bit more to also address this.

  • I think it's ok to make this a breaking changes as long as it's clearly documented
  • if it's not too much overhead (in code / docs / maintenance) I think having some sensible defaults easily available makes sense indeed
  • we should decide whether by default we don't want any syntax highlighting at all, or only support 1-3 langs
  • while we're at it, maybe we should also make it easy for consumers to load other themes

@flipvh
Copy link

flipvh commented Mar 13, 2025

Great news. My biased opinion would be to not add any and let the consumers decide to include one or multiple somehow. I would see the code block as a more 'advanced functionality' that will be used by consumers that should be fine with doing some config. If you throw in an example of that on your site, the first round of beers in de Biergarten are on me 🍻 😸.

@nperez0111
Copy link
Contributor Author

nperez0111 commented Mar 14, 2025

Alright, I've exposed the codeBlock configuration on the editor instance, and so this would let you configure the languages & themes that are supported by your app. By default, no languages or themes are bundled, to configure syntax highlighting, you can install the new package @blocknote/code-block which provides a decent set of languages and light & dark themes to use.

If you want more control than this, I'll write a guide on how easy it will be to integrate your list of languages, using the shiki-codegen tool.

This isn't completely ready yet, as I'll need to:

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.

BlockNote codeBlock's embedded Shiki significantly increases bundle size
3 participants