Skip to content

Commit

Permalink
Add sideEffects flag to react-is for tree shaking (facebook#27701)
Browse files Browse the repository at this point in the history
## Summary

This PR:

- Adds the `"sideEffects": false` flag to the `react-is` package, to
enable proper tree-shaking

## How did you test this change?

React-Redux v9 beta switches its artifacts from separate JS files to
pre-bundled artifacts. While testing builds locally, I noticed that our
use of `react-is` was no longer getting tree-shaken from Vite builds,
despite `react-is` only being used by our `connect` API and `connect`
itself getting shaken out of the final bundle.

Hand-adding `"sideEffects": false` to the `react-is` package locally
convinced Vite (+Rollup) to properly tree-shake `react-is` out of the
bundle when it wasn't being used.

I'd love to see this published as v18.2.1 as soon as this PR is merged -
we're hoping to release React-Redux v9 in the next few weeks!
  • Loading branch information
markerikson authored and AndyPengc12 committed Apr 15, 2024
1 parent ac747d1 commit 6f77c9c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/react-is/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "18.2.0",
"description": "Brand checking of React Elements.",
"main": "index.js",
"sideEffects": false,
"repository": {
"type": "git",
"url": "https://github.com/facebook/react.git",
Expand Down

0 comments on commit 6f77c9c

Please sign in to comment.