Reduce size of react-syntax-highlighter dependency
See original GitHub issueWhen built, the manager + preview are around 2.6 MB excluding the user’s code. Even for a development tool, this is quite a hefty amount.
I’ve been investigating different ways this can be reduced, and by far the largest contributor to the bundle size is react-syntax-highlighter
. It’s an astronomical 1.2 MB 😲 https://bundlephobia.com/result?p=react-syntax-highlighter@12.2.1
This is a picture of just the manager, broken down into dependencies by size:
highlight.js
and refractor
are both dependencies of react-syntax-highlighter
, and as you can see the configuration for many different languages is loaded.
The docs explain the size can be reduced by using a light build or an async build.
The async build looks ideal and doesn’t introduce breaking changes, but I don’t know if you guys want to include dynamic imports in storybook. The light build can also work, but might require the user to load the languages or provide configuration of languages to include.
I’m happy to work on this if this is something you guys want.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:9 (5 by maintainers)
Top GitHub Comments
I think esm + this would get a nice win with no breaking changes. Should have something next week
@LarsDenBakker I will buy you a beer (or the beverage of your choice) if you can do something about this. Coming to Amsterdam in April and can actually follow through on this threat!