-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved tree-shakeability of the
@emotion/react
package (#2101)
Co-authored-by: Mitchell Hamilton <mitchell@hamil.town>
- Loading branch information
Showing
6 changed files
with
113 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@emotion/react': patch | ||
--- | ||
|
||
Improved tree-shakeability of the package. The main benefit is that bundlers should be able now to drop [`hoist-non-react-statics`](https://github.com/mridgway/hoist-non-react-statics) if you don't actually use our `withTheme` export. |
12 changes: 12 additions & 0 deletions
12
packages/react/isolated-hoist-non-react-statics-do-not-use-this-in-your-code/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"main": "dist/emotion-react-isolated-hoist-non-react-statics-do-not-use-this-in-your-code.cjs.js", | ||
"module": "dist/emotion-react-isolated-hoist-non-react-statics-do-not-use-this-in-your-code.esm.js", | ||
"umd:main": "dist/emotion-react-isolated-hoist-non-react-statics-do-not-use-this-in-your-code.umd.min.js", | ||
"browser": { | ||
"./dist/emotion-react-isolated-hoist-non-react-statics-do-not-use-this-in-your-code.cjs.js": "./dist/emotion-react-isolated-hoist-non-react-statics-do-not-use-this-in-your-code.browser.cjs.js", | ||
"./dist/emotion-react-isolated-hoist-non-react-statics-do-not-use-this-in-your-code.esm.js": "./dist/emotion-react-isolated-hoist-non-react-statics-do-not-use-this-in-your-code.browser.esm.js" | ||
}, | ||
"preconstruct": { | ||
"umdName": "emotionHoistNonReactStatics" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/react/src/isolated-hoist-non-react-statics-do-not-use-this-in-your-code.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// this file isolates this package that is not tree-shakeable | ||
// and allows it to be dropped - if it stays unused | ||
// it happens thanks to sideEffects: false in our package.json | ||
import hoistNonReactStatics from 'hoist-non-react-statics' | ||
|
||
// have to wrap it in a proxy function because Rollup is too damn smart | ||
// and if this module doesn't actually contain any logic of its own | ||
// then Rollup just use 'hoist-non-react-statics' directly in other chunks | ||
export default (targetComponent, sourceComponent) => | ||
hoistNonReactStatics(targetComponent, sourceComponent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters