Skip to content

Why is react-dom so big? Why can't we tree-shake it? #16173

@SGudbrandsson

Description

@SGudbrandsson

Do you want to request a feature or report a bug?
Request a feature

What is the current behavior?
Bundling react-dom with the current CJS module is HUGE - 124KB of stuff we don't use.
The bundle can be so much smaller by adding the source files into the npm package and enabling users to do a proper tree-shaking by defining the file in webpack

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
image

What is the expected behavior?
When bundling with webpack, we should be able to properly tree-shake the unused code automatically.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React 16.8.6
Browser Chrome 75
Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions