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(perf): lazy embed languages bundle for SFCs and Docs #791

Merged
merged 5 commits into from
Sep 29, 2024

Conversation

antfu
Copy link
Member

@antfu antfu commented Sep 27, 2024

This PR introduces an optimization to load and bundle embedded languages lazily for some languages.

For example, in Vue SFC, you can have <script lang="tsx">, <template lang="pug">, <style lang="scss"> to embed different languages in Vue files. This means to support properly support them, when loading Vue's grammar, it will also load tsx, jsx, pug, coffee, scss, sass, less... as it's dependencies - even you might not need most of the languages.

In this PR, we make those embedded languages as lazy dependencies, meaning they are not initiated along with vue. Instead, you need to load the corresponding languages alongside them to get those embedded blocks properly highlighted. We consider this as a performance improvement on both runtime and bundle size, as this would only affect fine-grain bundle, and users should already loading the languages they needed in those cases.

The same optimization applies to vue, vue-html, astro, svelte, pug, haml, wikitext, latex, asciidoc. And markdown, mdx already worked that way.

Copy link

netlify bot commented Sep 27, 2024

Deploy Preview for shiki-next ready!

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

Copy link

netlify bot commented Sep 27, 2024

Deploy Preview for shiki-matsu ready!

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

@antfu antfu changed the title feat(perf): improve embedded languages bundle feat(perf): lazy embed languages bundle for SFCs and Docs Sep 27, 2024
Copy link

codecov bot commented Sep 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.88%. Comparing base (92fec4a) to head (e696387).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #791      +/-   ##
==========================================
+ Coverage   92.79%   92.88%   +0.08%     
==========================================
  Files          76       76              
  Lines        4597     4597              
  Branches     1020     1020              
==========================================
+ Hits         4266     4270       +4     
+ Misses        322      318       -4     
  Partials        9        9              
Flag Coverage Δ
92.88% <ø> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@antfu antfu merged commit c8accc9 into main Sep 29, 2024
13 checks passed
@antfu antfu deleted the feat/lazy-embbeded branch September 29, 2024 00:51
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.

1 participant