Jump to content
Search Community

TweenMax not defined; TweenLite Module not defined; ScrollToPlugin + Webpack

Tech Nomad test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hey guys, 
I'm getting suddenly issues with TweenMax in my project. It has worked fine for a while after following up this post. But recently I've got TweenMax variable not defined errors when running  "build" / production npm script. So I've made the same thing with TweenMax as suggested for the ScrollToPlugin in the post: 

const TweenMax = require("gsap/umd/TweenMax");

Worked indeed. But now I get:

ERROR in ./src/vendor/greensock-js-business-green/src/minified/plugins/ScrollToPlugin.min.js
Module not found: Error: Can't resolve 'TweenLite' in '/Path/to/project/src/vendor/greensock-js-business-green/src/minified/plugins'

When I include the ScrollToPlugin like this:

const ScrollToPlugin = require("gsap/umd/ScrollToPlugin");

... then I don't get any errors when compiling the app bundle. But the problem is TweenLite gets included on the top of TweenMax, which adds 30kb more to the already huge app. 
I've tried then to in include the plugin from the greensock-js-business-green minified folder. But then I get this  module not found error mentioned above. 

So how can I include the ScrollToPlugin in a Webpack app without having to include TweenLite on the top of TweenMax? 

Thank you in advance! 

 

P.S.

MorphSVGPlugin seems not to cause these troubles when including from the "umd" folder :

const MorphSVGPlugin = require("~/vendor/greensock-js-business-green/src/bonus-files-for-npm-users/umd/MorphSVGPlugin.js");

 

Link to comment
Share on other sites

Sorry to hear about the trouble, @Tech Nomad. A few thoughts...

  1. We haven't changed anything recently, so I'm not sure what changed on your end that may be causing the problem. The way things are packaged hasn't changed for well over a year. 
  2. I'm not sure why TweenLite would add 30kb - it should be something like 9kb gzipped and minified. 
  3. Can your build system handle ES modules? If so, I'd strongly recommend switching away from the UMD files because the imports/exports are cleaner and your bundle will likely be smaller. Due to some of the complexities in the way UMD works and the way GSAP works, it's sometimes impossible to avoid the bundler pulling in TweenLite AND TweenMax (which already has TweenLite in it). 
  4. I think you're gonna be REALLY happy with the upcoming release. As a Club GreenSock member, you'll be getting early access later this week. I'm pretty confident that the issue you're running into here is addressed quite well in the next release. There's a lot to be excited about. Keep an eye on your email for the announcement later this week ;)

 

Link to comment
Share on other sites

Hey Jack,

thank you for the quick response! 

1. Difficult to say - I am changing all the time something in the project. 

2. I mean 30kb without gzip (as showed in my local project folder)

3. In fact it works!  :) The total size is exact 30kb smaller and no errors are produced. I don't remember why I switched to UMD I've just only noted this link in the comments of my code:

 

4. Sounds great! Now I'm curious :) 

Thank you again! 

 

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...