framer / motion

Open source, production-ready animation and gesture library for React
https://framer.com/motion
MIT License
23.37k stars 783 forks source link

[BUG] v10 loads legacy js in commonjs module resulted in bundle size increase #2533

Open michaelchen-cb opened 6 months ago

michaelchen-cb commented 6 months ago

1. Read the FAQs 👇

2. Describe the bug

We recently bumped our app(commonjs) from v6.5.1 to v10.18.0 and noticed that in our app bundles, framer-motion bundle size has increased by ~100kb, mostly due to loading the index-legacy.js file in v10. Is this expected or something going wrong?

3. IMPORTANT: Provide a CodeSandbox reproduction of the bug https://github.com/michaelchen-cb/framer-bundle-repro

4. Steps to reproduce

Steps to reproduce the behavior:

  1. Clone this repo
  2. Run yarn install
  3. Run yarn start
  4. Open http://127.0.0.1:8888/
  5. See bundle analysis
  6. Run git checkout v10 and repeat steps 3-5.

5. Expected behavior Bundle should not include the legacy js file.

6. Video or screenshots

v6.5.1

framer-motiondistcjs

v10.18.0

framer-motiondistcjs

7. Environment details

If applicable, let us know which OS, browser, browser version etc you're using.

mattgperry commented 6 months ago

I’ll have to have a closer look when I’m back but your bundler or its setup is almost certainly at fault here, I’ve never even heard of this. It should only import code that’s been included through the entrypoint and it isn’t.