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

Version 1.6.0 increased size considerably #83

Closed
unindented opened this issue Feb 18, 2018 · 6 comments
Closed

Version 1.6.0 increased size considerably #83

unindented opened this issue Feb 18, 2018 · 6 comments

Comments

@unindented
Copy link

unindented commented Feb 18, 2018

I think caused by the addition of prop-types:

screen shot 2018-02-18 at 9 26 56 am

People using Flow/TypeScript don't use PropTypes. Would you consider removing them from dependencies, and stripping them out during build or similar?

@mjackson
Copy link
Member

Yes, thanks for bringing this to my attention. :)

Which build are you using?

@unindented
Copy link
Author

I think the one at the root, cause package.json doesn't specify a module key, so I'm pretty sure Webpack is picking the index.js and Media.js files at the root.

@theKashey
Copy link

Current bundle size is not 2kb, as bundle-phobia displays. It is 30 kb, as long all the used libraries, including prop-types, are inlined by rollup.

@edorivai
Copy link
Collaborator

@theKashey I think you're right! Even though package.json now specifies the module field, which points to the esm build, it seems that the esm build indeed does include all dependencies inline!

The bundle stats of our production build shows the following stats for react-media:

  • Stat size: 36.47 KB
  • Parsed size: 4.59 KB
  • GZipped size: 1.94 KB

I suggest we make prop-types a peerDependency, and add it to the external list in the rollup config. As for the remaining dependencies (invariant and json2mq), I think these are small enough to keep them inline.

@edorivai
Copy link
Collaborator

Just leaving this here for reference: facebook/create-react-app#209

tl;dr
Even if we specify prop-types as a peerDependency, it will still end up in the final bundle. There is a babel plugin that strips prop-types entirely, but I think that should be configured by consumers of this library, not by the library itself.

@edorivai
Copy link
Collaborator

An update as of v1.9.2:

image

v1.5.1

  • minified: 2.8 KB
  • gzipped: 1.2 KB

1.9.2

  • minified: 3.5 KB
  • gzipped: 1.6 KB

But...

Assuming you have your build process set up correctly (meaning you set NODE_ENV=production), and you are already using @babel/runtime in you app, we can leave out:
prop-types: ~800 B
@babel/runtime: ~300 B

Which should leave us with ~2.4 KB minified. I think that should close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants