Hi, amazing library! Would fine-grained bundling be complicated to integrate into rehype as well?
Thank you! Unfortunately, the approach I used in the Astro integration (which uses a custom Vite plugin to rewrite the imports on the fly) can't be replicated in the Rehype integration as I can't even rely on Vite being present in the toolchain at all.
Now that Shiki offers a custom bundle generator on their website, I could imagine that you can create your own bundle including only the themes and languages you need, add it to your project, and use your package manager's overrides feature in package.json to replace the Shiki package imported by plugin-shiki with your custom bundle. I didn't test this approach, but in theory it should work!
Another idea could be to use your package manager's patch functionality to manually comment out the unused languages directly inside the existing Shiki bundle and store the required modifications alongside your project.
Originally posted by @hippotastic in #251
Fine-grained bundle support was added in version 0.39, however it is limited to Astro currently. In order to reduce bundle size, the above seems like a viable workaround but it's not a clean approach and introduces additional maintenance and risk. For our use case of client side only processing (no SSR), adding the entire shiki bundle (~6.9MB) is a non-starter for being able to use expressive code unfortunately.
I'm not familiar enough with the internals of expressive code, but would it be possible to expose a shiki option to provide a highlighter similar to the way rehype-shiki does?
If so, this should provide all use cases of expressive code to control bundle size as their needs require.
Thank you for your consideration!
Originally posted by @hippotastic in #251
Fine-grained bundle support was added in version 0.39, however it is limited to Astro currently. In order to reduce bundle size, the above seems like a viable workaround but it's not a clean approach and introduces additional maintenance and risk. For our use case of client side only processing (no SSR), adding the entire shiki bundle (~6.9MB) is a non-starter for being able to use expressive code unfortunately.
I'm not familiar enough with the internals of expressive code, but would it be possible to expose a shiki option to provide a highlighter similar to the way rehype-shiki does?
If so, this should provide all use cases of expressive code to control bundle size as their needs require.
Thank you for your consideration!