resend / react-email

💌 Build and send emails using React

Home Page:https://react.email

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bundle Size very large

brandon-pereira opened this issue · comments

Describe the Bug

The bundle size of our app increased by ~500 MB when we installed react-email. The reason for this is that the react-email package requires several large dependencies like next and framer-motion.

While it makes sense that these are required for the dev tools/build tools, they shouldn't be included if I make react-email a devDependency and keep @react-email/components a depenency.

The reason that react-email is still installed even when moving it to a devDependency is that @react-email/markdown has a dependency on md-to-react-email: 4.1.0 (here). The 4.x version of md-to-react-email has a peer dependency on react-email. Unfortunately, with yarn there is no way to ignore peer dependencies entirely, even when running with --production flag.

Solution

If the package @react-email/markdown bumps its dependency md-to-react-email to 5.x then the issue will be resolved because it is no longer listed as a peer dependency..

References

Which package is affected (leave empty if unsure)

@react-email/components

Link to the code that reproduces this issue

https://github.com/codeskills-dev/md-to-react-email/blob/v4.1.0/package.json#L50C1-L50C28

To Reproduce

  1. Install @react-email/components as a dependency in a new project
  2. Install dependencies via yarn install
  3. Check if react-email was installed via yarn why react-email
  4. Assert that react-email is installed

Expected Behavior

  1. Install @react-email/components as a dependency in a new project
  2. Install dependencies via yarn install
  3. Check if react-email was installed via yarn why react-email
  4. Assert that react-email is NOT installed

What's your node version? (if relevant)

20.10.0

Thank you so much for opening this issue, really good information throughout. Going to get that fixed for the next versions of @react-email/markdown and @react-email/components.

My docker image size doubled from 477MB to 1Gig and it took some head scratching to figure out what caused it. But I just downgraded to 0.0.14 and all is fine.

Seems like it changed a lot of big deps to prod deps. Please do a hotfix release.

Screenshot 2024-03-02 at 19 07 02

@hilja

Seems like it changed a lot of big deps to prod deps. Please do a hotfix release.

I do remember we changed them on the package for the CLI, but not on any of the components. Do you have any idea which package had these changes you mentioned?

In the end I installed only the components that I needed instead of components, which made my image 10MB smaller.

Here I better describe this issue (this issue impact on performance)

#1340 (comment)

In the end I installed only the components that I needed instead of components, which made my image 10MB smaller.

That's great!

Can you please share steps other need to do to achieve your result?