Undistraction / cssapi-mq

Media Query Utils For Styled Components
MIT License
15 stars 3 forks source link

Bundle size #3

Open oyeanuj opened 6 years ago

oyeanuj commented 6 years ago

Hey again from the Spectrum chat. I was finally testing moving from styled-media-queries to styled-mq. One thing which was giving me a little pause as I was testing was the bundle size.

I was wondering if the bundle size would be reduced if -

  1. React, and SC were made peer dependencies instead of dependencies? Essentially, it would mean BYO React and SC and not risk being duplicated in the developer's builds.

  2. It seems like ramda supports tree-shaking and if the imports could reflect the specific function/feature being imported from Ramda rather than the entire library?

Thoughts?

Undistraction commented 6 years ago

Hi Anuj,

I'm going to be looking at this next week. I've just been working on some new utilities to go alongside this one and I'm going to do an optimisation pass over all of them.

React, and SC were made peer dependencies instead of dependencies? Essentially, it would mean BYO React and SC and not risk being duplicated in the developer's builds.

This shouldn't be a problem when using a bundler and the UMD version shouldn't include Ramda, React or SC. Are you talking hypothetically or are you having issues with multiple versions of React being included?

It seems like ramda supports tree-shaking and if the imports could reflect the specific function/feature being imported from Ramda rather than the entire library?

From the Ramda docs:

use babel-plugin-ramda to automatically cherry pick methods

I'll take a look next week unless you fancy having a dig?