question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Significant bundlesize increase with framer-motion@5 while using LazyMotion

See original GitHub issue

1. Read the FAQs 👇

2. Describe the bug

With the upgrade to framer/motion@5 we’re seeing a significant bundle size increase. I understand that the new version offers lots of cool functionality so that there is an increase in bundle size could be expected. I wouldn’t expect his however when using LazyMotion,

Page Size old Size new Size diff First load old First load new First load diff
/ 2.1kB 2.1kB 242kB 249.0kB +7kB🚨
/_app 152kB 164.0kB +12kB🚨
/[…url] 4.3kB 4.3kB 260kB 266.0kB +6kB🚨
/404 6.4kB 6.3kB -0.1kB 228kB 235.0kB +7kB🚨
/about/[url] 2.7kB 2.7kB 223kB 230.0kB +7kB🚨
/account 15.0kB 13.6kB -1.4kB 210kB 220.0kB +10kB🚨
/account/addresses 12.5kB 9.8kB -2.7kB 220kB 224.0kB +4kB⚠️

We’re already using the LazyMotion feature and I would thus expect for the bundle size not too increase significantly.

4. Steps to reproduce

Steps to reproduce the behavior:

  1. Upgrade to framer motion 5
  2. See the difference in bundlesize
  3. See error

5. Expected behavior

Bundle size is not increased, and the additional features are loaded lazily

6. Video or screenshots

Not applicable

7. Environment details

Not applicable

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:11

github_iconTop GitHub Comments

1reaction
paalescommented, Jul 11, 2022

This fixed the issue! https://github.com/graphcommerce-org/graphcommerce/pull/1550#issuecomment-1180401005

Page Size old Size new Size diff First load old First load new First load diff
/ 0.9kB 2.6kB +1.7kB⚠️ 268kB 258.0kB -10kB🔥
/_app 195kB 180.0kB -15kB🔥
/[…url] 5.5kB 3.7kB -1.8kB 285kB 275.0kB -10kB🔥
/404 4.4kB 6.1kB +1.7kB⚠️ 258kB 249.0kB -9kB🔥
/account 12.8kB 12.8kB 242kB 230.0kB -12kB🔥
/account/addresses 14.4kB 14.4kB 246kB 236.0kB -10kB🔥
/account/addresses/add 5.4kB 8.4kB +3.0kB⚠️ 261kB 251.0kB -10kB🔥
/account/addresses/edit 1.0kB 1.0kB 264kB 254.0kB -10kB🔥
/account/authentication 9.7kB 12.4kB +2.7kB⚠️ 259kB 249.0kB -10kB🔥
0reactions
paalescommented, Jul 7, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

LazyMotion | Framer for Developers
The LazyMotion component can help you reduce bundle size by synchronously or asynchronously loading some, or all, of the motion component's features.
Read more >
Framer-Motion: New And Underestimated Features - Shakuro
Documentation states, that default use of motion component adds around 25kb to the bundle size vs under 5kb for LazyMotion and m components....
Read more >
Sebastien Lorber • ⚛️ ThisWeekInReact.com on Twitter ...
Reducing bundle size by extracting error messages from code, similarly to ReactJS. Redux Toolkit Query is being added to Redux Toolkit This will...
Read more >
Error importing Framer Motion v5 in React (with create-react ...
I downgraded the Framer motion version to "4.1.17" by changing the package.json file and running npm install and it works for me.
Read more >
How to Reduce Your Webpack Bundle Size for Web App ...
If you have been in Web Development for a quite some time for now especially as a Front-End Developer and you use Webpack...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found