[Feature Request] Reduce bundle size + dependencies?
See original GitHub issueIs your feature request related to a problem? Please describe.
Building RS throws bundle size warnings. Looking at the vendor bundle, there are a few packages that can definitely be replaced. The two standouts to me are react-helmet
and axios
. Both have much smaller alternatives.
For react-helmet
, react-head
would save 4.5k after compression.
https://bundlephobia.com/result?p=react-helmet@6.0.0
https://bundlephobia.com/result?p=react-head@3.3.0
And for axios
, isomorphic-unfetch
would save 4k after compression.
https://bundlephobia.com/result?p=axios@0.19.2
https://bundlephobia.com/result?p=isomorphic-unfetch@3.0.0
There are other to look into. For instance, history
v5 looks like it will be much smaller. Something to keep an eye on. The intersection observer polyfill is also really big. It might be worth considering producing that functionality some other way.
Describe the solution you’d like
I’d like to see the vendor bundle reduced down to the bare essentials.
Describe alternatives you’ve considered
The deps all look critical to RS functionality, so this is the only solution I see.
Additional context
I am open to submitting PRs, if you’re open to merging them! 😁
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:6 (4 by maintainers)
Axios: Unless axios itself switches to fetch, I don’t see them being able to cut too much code. I took a look a year or so ago, and nothing stood out. While I think a fetch polyfill would be the best call, there’s also
redaxios
, which preserves the axios api, but uses fetch under the hood. However, it adds almost 1k zipped on top of the polyfill to preserve all the transformers and stuff.React-Helmet: Do you mean not-bundled in the
export
code? That’s good to know, though one of my use cases requires bundling once, and exporting multiple times in serverless, so I would still be interested in pulling it out. On the topic, why no out-of-the-boxexport
bundle-analyzer? Have I simply missed it?IntersectionObserver: What does it get used for other than prefetch visibility? For that, a hook/handler leveraging one window.onScroll that does the math for each element (with scrollY, viewport height, etc) would totally replace the need.
In any case, thanks for getting back so quickly. I’m eager to hear what you think.
FWIW (as I’m trying to use RR v6) I think it’s worth calling out.
That said, it does look like I’ll need to dig into
react-static-plugin-react-router
and look at updating it locally. Maybe if I find time to do so, I can submit a PR…