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

Is there a way to only load certain languages? Bundle size is large #23

Open
jacobedawson opened this issue Dec 22, 2020 · 5 comments
Open
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@jacobedawson
Copy link

Hi, react-code-blocks is very nice! However, it would be useful if there was a way to only load the required languages, as currently the bundle is very large and in most cases will be loading many more languages than the client likely needs.

@rajinwonderland
Copy link
Owner

Hey @jacobedawson, that's an interesting point you bring up. Currently, the languages are called using the PrismAsyncLight component offered by react-syntax-highlighter which should optimize the build size.

But the availability of languages might be a reason for the large package size.

Perhaps we can split the packages into a light version that would require the language to be a peer dependency?

I'm open to suggestions here

@jacobedawson
Copy link
Author

Yeah, I'm using react-syntax-highlighter and I'm able to require only the languages that I need, I think it makes sense since there are a lot of language files that will never be used.

@insaneintenti0n
Copy link

I second the request for a 'light' version with a way to select only the languages needed. I wanted a quick option for some JS highlighting and while the display looks great, my chunked build went from 10 files to 310.

@rajinwonderland rajinwonderland self-assigned this Feb 18, 2021
@rajinwonderland rajinwonderland added enhancement New feature or request help wanted Extra attention is needed labels Feb 18, 2021
@hulto
Copy link

hulto commented Oct 8, 2023

Just wanted to bump this issue. 💯 would be great to have a light build option.

@peacechen
Copy link

The prod build creates hundreds of react-syntax-highlighter_languages*.chunk.js files even though it's only using the React highlighter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants