react-workspaces / react-workspaces-playground

⚛️ 🐈 Zero Config Create-React-App Monorepos with Yarn Workspaces, Lerna and React Storybook.
https://react-workspaces.github.io/react-workspaces-playground/
764 stars 128 forks source link

Tree shaking #17

Closed andrewmclagan closed 4 years ago

andrewmclagan commented 4 years ago

-- This issue is theory and has not been tested --

From a first inspection of this monorepo setup it seems that components would not be tree shakable. Importing <CompOne /> also imports <CompTwo /> as there is nothing specifying webpack (any bundler) should do otherwise.

If we have two apps that both use components, and only need to use portions of these components, we have allot of dead code. In any real-world app/team not all components would be used.

Prime use-case for sideEffects.

Im making allot of assumptions:

Jordan-Gilliam commented 4 years ago

@andrewmclagan do you know if this project is still being maintained?

F1LT3R commented 4 years ago

I tried tree-shaking with this a while back, and it worked. Have you checked the output of the build?

F1LT3R commented 4 years ago

@andrewmclagan - I tested tree shaking just now and it still seems to work just fine.

CleanShot 2019-12-22 at 22 16 33@2x

F1LT3R commented 4 years ago

Anyone: feel free to reopen this if you find a case where tree-shaking is not working.

dangnelson commented 3 years ago

I'm experiencing an issue where a dependency that a shared component needs will be included in the projects that don't use that component.

So if CompOne imports some-package then that package gets included in the build for some-app even though CompOne isn't used by some-app.