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

[Not for Merge] Remove legacy context #13420

Closed
wants to merge 5 commits into from
Closed

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Aug 16, 2018

This is not for merge or review.

I'm just curious how much supporting legacy context affects bundle size.

@pull-bot
Copy link

pull-bot commented Aug 16, 2018

ReactDOM: size: -2.9%, gzip: -2.5%

Details of bundled changes.

Comparing: d5edc1f...65cce78

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js -2.7% -2.3% 651.66 KB 633.82 KB 152.93 KB 149.34 KB UMD_DEV
react-dom.production.min.js -2.9% -2.5% 97.25 KB 94.47 KB 31.43 KB 30.65 KB UMD_PROD
react-dom.development.js -2.8% -2.4% 647.8 KB 629.96 KB 151.82 KB 148.21 KB NODE_DEV
react-dom.production.min.js -2.9% -2.6% 97.24 KB 94.43 KB 31.04 KB 30.23 KB NODE_PROD
react-dom-server.browser.development.js -1.9% -1.3% 104.21 KB 102.25 KB 27.82 KB 27.46 KB UMD_DEV
react-dom-server.browser.production.min.js -2.8% -2.5% 15.42 KB 14.99 KB 5.88 KB 5.73 KB UMD_PROD
react-dom-server.browser.development.js -2.0% -1.6% 100.34 KB 98.38 KB 26.84 KB 26.42 KB NODE_DEV
react-dom-server.browser.production.min.js -2.8% -2.7% 15.32 KB 14.88 KB 5.82 KB 5.67 KB NODE_PROD
react-dom-server.node.development.js -1.9% -1.6% 102.27 KB 100.3 KB 27.37 KB 26.95 KB NODE_DEV
react-dom-server.node.production.min.js -2.7% -2.5% 16.13 KB 15.69 KB 6.13 KB 5.97 KB NODE_PROD
ReactDOM-dev.js -2.9% -2.5% 655.16 KB 636.29 KB 149.96 KB 146.23 KB FB_WWW_DEV
ReactDOM-prod.js -3.5% -2.9% 285.53 KB 275.55 KB 53.06 KB 51.51 KB FB_WWW_PROD
ReactDOMServer-dev.js -2.4% -2.2% 101.48 KB 99 KB 26.52 KB 25.93 KB FB_WWW_DEV
ReactDOMServer-prod.js -3.9% -3.3% 33.27 KB 31.96 KB 8.03 KB 7.76 KB FB_WWW_PROD
react-dom.profiling.min.js -2.9% -2.6% 98.45 KB 95.63 KB 31.43 KB 30.63 KB NODE_PROFILING
ReactDOM-profiling.js -3.4% -2.9% 287.97 KB 278.08 KB 53.7 KB 52.15 KB FB_WWW_PROFILING

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js -4.1% -3.6% 441.69 KB 423.78 KB 99.9 KB 96.33 KB UMD_DEV
react-art.production.min.js -3.2% -3.0% 86.61 KB 83.82 KB 26.7 KB 25.9 KB UMD_PROD
react-art.development.js -4.8% -4.3% 374.23 KB 356.31 KB 82.81 KB 79.28 KB NODE_DEV
react-art.production.min.js -5.4% -5.0% 51.59 KB 48.81 KB 16.08 KB 15.28 KB NODE_PROD
ReactART-dev.js -5.2% -4.9% 364.64 KB 345.7 KB 77.62 KB 73.84 KB FB_WWW_DEV
ReactART-prod.js -6.1% -5.5% 159.76 KB 149.96 KB 27.08 KB 25.58 KB FB_WWW_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer.development.js -4.8% -4.1% 370.88 KB 353 KB 81.32 KB 77.99 KB UMD_DEV
react-test-renderer.production.min.js -5.5% -5.0% 50.74 KB 47.95 KB 15.52 KB 14.74 KB UMD_PROD
react-test-renderer.development.js -4.9% -4.4% 367.01 KB 349.13 KB 80.36 KB 76.8 KB NODE_DEV
react-test-renderer.production.min.js -5.5% -5.3% 50.44 KB 47.66 KB 15.35 KB 14.53 KB NODE_PROD
react-test-renderer-shallow.development.js -39.8% -38.6% 24.46 KB 14.73 KB 6.63 KB 4.07 KB UMD_DEV
react-test-renderer-shallow.production.min.js -6.1% -4.5% 7.17 KB 6.74 KB 2.34 KB 2.24 KB UMD_PROD
react-test-renderer-shallow.development.js -35.3% -35.6% 19.65 KB 12.71 KB 5.45 KB 3.51 KB NODE_DEV
react-test-renderer-shallow.production.min.js -24.7% -26.2% 7.88 KB 5.94 KB 2.61 KB 1.93 KB NODE_PROD
ReactTestRenderer-dev.js -5.0% -4.6% 372.03 KB 353.43 KB 79.2 KB 75.56 KB FB_WWW_DEV
ReactShallowRenderer-dev.js -32.9% -34.0% 17.97 KB 12.06 KB 4.72 KB 3.11 KB FB_WWW_DEV

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js -5.0% -4.7% 355.24 KB 337.33 KB 76.86 KB 73.29 KB NODE_DEV
react-reconciler.production.min.js -5.7% -5.2% 49.07 KB 46.28 KB 14.71 KB 13.95 KB NODE_PROD
react-reconciler-persistent.development.js -5.1% -4.7% 353.86 KB 335.98 KB 76.3 KB 72.74 KB NODE_DEV
react-reconciler-persistent.production.min.js -5.7% -5.2% 49.08 KB 46.29 KB 14.72 KB 13.95 KB NODE_PROD

react

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react.development.js -0.1% -0.1% 59.68 KB 59.65 KB 16.71 KB 16.7 KB UMD_DEV
react.development.js -0.1% -0.1% 53.87 KB 53.84 KB 14.87 KB 14.86 KB NODE_DEV
React-dev.js -0.7% -1.1% 51.54 KB 51.18 KB 14.24 KB 14.09 KB FB_WWW_DEV

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js -3.8% -3.4% 490.43 KB 471.95 KB 108.26 KB 104.62 KB RN_FB_DEV
ReactNativeRenderer-prod.js -4.7% -4.1% 219.36 KB 209.13 KB 38.14 KB 36.59 KB RN_FB_PROD
ReactNativeRenderer-dev.js -3.8% -3.4% 490.16 KB 471.69 KB 108.2 KB 104.55 KB RN_OSS_DEV
ReactNativeRenderer-prod.js -4.9% -4.3% 209.41 KB 199.17 KB 36.55 KB 34.99 KB RN_OSS_PROD
ReactFabric-dev.js -3.8% -3.5% 480.49 KB 462.01 KB 105.83 KB 102.16 KB RN_FB_DEV
ReactFabric-prod.js -5.1% -4.4% 201.56 KB 191.31 KB 35.02 KB 33.48 KB RN_FB_PROD
ReactFabric-dev.js -3.8% -3.5% 480.52 KB 462.04 KB 105.84 KB 102.18 KB RN_OSS_DEV
ReactFabric-prod.js -5.1% -4.4% 201.6 KB 191.35 KB 35.04 KB 33.49 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js -4.8% -4.2% 212.84 KB 202.61 KB 37.2 KB 35.63 KB RN_OSS_PROFILING
ReactFabric-profiling.js -5.0% -4.4% 204.57 KB 194.33 KB 35.59 KB 34.03 KB RN_OSS_PROFILING
ReactNativeRenderer-profiling.js -4.6% -4.0% 222.77 KB 212.54 KB 38.79 KB 37.24 KB RN_FB_PROFILING
ReactFabric-profiling.js -5.0% -4.4% 204.53 KB 194.29 KB 35.57 KB 34.02 KB RN_FB_PROFILING

Generated by 🚫 dangerJS

@sebmarkbage
Copy link
Collaborator

The key is that a lot of this code is also in hot paths that are hit whether you use it or not. That's what makes it so insidious.

@gaearon
Copy link
Collaborator Author

gaearon commented Aug 17, 2018

If we do the contextType = proposal wouldn't that still leave some of those code paths? Or are providers specifically the worst?

@acdlite
Copy link
Collaborator

acdlite commented Aug 17, 2018

The contextType proposal is nice because it requires almost nothing extra relative to what we're already doing for new context:

+ if (contextType !== null) {
+   instance.context = useContext(contextType);
+ }
instance.render()

@acdlite
Copy link
Collaborator

acdlite commented Aug 17, 2018

plus the equivalent for passing to lifecycles

@sebmarkbage
Copy link
Collaborator

It's the isLegacyContextProvider and hasLegacyContextChanged checks that happens for everything.

@sebmarkbage
Copy link
Collaborator

You should remove renderSubtreeIntoContainer too. Tangentially related.

@oliviertassinari
Copy link
Contributor

the old context is more powerful than the new Context API, please don't remove it.

@lin With the Hook context API and the static contextType API, it's no longer true. It's 👌.

@necolas necolas added the React Core Team Opened by a member of the React Core Team label Jan 8, 2020
@gaearon gaearon closed this Jan 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants