Skip to content

Conversation

@mrgurdeep
Copy link

@mrgurdeep mrgurdeep commented Jul 28, 2018

Adding support so that each function of ReactIs is individually accessible

This solve the issue mentioned in #13250

And then finally provide a feature requested in #13272

What is the issue
Tree shaking not enabled with react-is.

import * as ReactIs from "react-is";
ReactIs.isValidElementType(<div />); // true

Expected behavior
Allow importing individual modules from the package.

import { isValidElementType } from "react-is";
isValidElementType(<div />); // true

Adding support so that each function of ReactIs is individually accessible
@pull-bot
Copy link

Details of bundled changes.

Comparing: 2a2ef7e...1655525

react-is

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-is.development.js +12.6% +10.1% 4.68 KB 5.28 KB 1.29 KB 1.42 KB UMD_DEV
react-is.production.min.js 🔺+18.8% 🔺+20.7% 1.89 KB 2.25 KB 789 B 952 B UMD_PROD
react-is.development.js +13.1% +11.2% 4.5 KB 5.09 KB 1.24 KB 1.38 KB NODE_DEV
react-is.production.min.js 🔺+17.5% 🔺+18.7% 1.84 KB 2.16 KB 722 B 857 B NODE_PROD
ReactIs-dev.js +12.9% +10.8% 4.58 KB 5.17 KB 1.27 KB 1.4 KB FB_WWW_DEV
ReactIs-prod.js 🔺+24.8% 🔺+17.9% 3.68 KB 4.59 KB 1006 B 1.16 KB FB_WWW_PROD

Generated by 🚫 dangerJS

@mrgurdeep
Copy link
Author

@gaearon as you suggested in reduxjs/react-redux#914 (comment)

'use strict';

export * from './src/ReactIs';
export {default} from './src/ReactIs';
Copy link

@pgarciacamou pgarciacamou Jul 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why you export it twice, I believe that is what is increasing the size of the build files.

@mrgurdeep
Copy link
Author

mrgurdeep commented Jul 30, 2018 via email

@gaearon
Copy link
Collaborator

gaearon commented Aug 2, 2018

Sorry, I don't see how this could help.
If you want tree shaking to work, you need to add an ESM build target in the Rollup settings.

@gaearon gaearon closed this Aug 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants