I am refactoring and running cleanup on a production app, and optimizing dependencies.
We have a React component that uses GSAP for some transition-related stuff, but only the TimelineLite library. It's all simple stuff, without any eases or anything, so we have no need for any of the more complex GSAP items and can now scrub them out to optimize.
Originally, we just imported the whole GSAP library via NPM like so:
import 'gsap';
Per the GSAP npm docs (https://www.npmjs.com/package/gsap)...
Now, I'd like to trim the fat off our import, and switched to:
import { TimelineLite } from 'gsap';
However, this is compiling correctly but throwing the following client-side error:
Uncaught TypeError: _gsap.TimelineLite is not a constructor
Does anyone know why this is? Our weight savings from importing `TimelineLite` alone aren't huge, but they are worth doing. Do I need to import other parts of the GSAP libraries specifically?
----------
NOTES:
I have also tried this with no luck.
import { TweenLite, TimelineLite } from 'gsap';
Strangely, this does not work either:
import { TweenMax, TimelineLite } from 'gsap';
but this does (for obvious reasons):
import { TweenMax } from 'gsap';
Here is the animation we are using, super basic:
new TimelineLite()
.to('#urlCopyMessage', 0, { visibility: 'visible', opacity: 1 })
.fromTo('#urlCopyMessage', 0.35,
{ opacity: 0, y: 20 },
{ opacity: 1, y: -30 }
)
.to('#urlCopyMessage', 0.35,
{ opacity: 0, delay: 0.25 }
)
.to('#urlCopyMessage', 0, { visibility: 'hidden' });