greensock / GSAP

GSAP (GreenSock Animation Platform), a JavaScript animation library for the modern web
https://gsap.com
19.56k stars 1.72k forks source link

Webpack bundles TweenLite when importing MorphSVG & DrawSVG #253

Closed joepagan closed 6 years ago

joepagan commented 6 years ago

Hey,

Thank you for GSAP, long time user, got a premium license & all.

Been using MorphSVG & DrawSVG plugins, though when importing them, it appears to add TweenLite to my vendors.chunk.js bundle, despite me never including it anywhere.

import 'gsap/TweenMax';
import '../../vendor/gsap/MorphSVGPlugin';
import '../../vendor/gsap/DrawSVGPlugin';

Investigating the files reveals that it is requireing gsap/TweenLite at the bottom of each. I appreciate that you probably know about this already, and you may address this in the future.

Though for anyone else in the mean time I altered these lines to reference TweenMax & TweenLite was no longer included like so.

}); if (_gsScope._gsDefine) { _gsScope._gsQueue.pop()(); }
//export to AMD/RequireJS and CommonJS/Node (precursor to full modular build system coming at a later date)
(function(name) {
    "use strict";
    var getGlobal = function() {
        return (_gsScope.GreenSockGlobals || _gsScope)[name];
    };
    if (typeof(module) !== "undefined" && module.exports) { //node
        require("gsap/TweenMax");
        module.exports = getGlobal();
    } else if (typeof(define) === "function" && define.amd) { //AMD
        define(["gsap/TweenMax"], getGlobal);
    }
}("DrawSVGPlugin"));
jackdoyle commented 6 years ago

Indeed, thanks for sharing this, @joepagan. It's a tricky issue because technically you don't need TweenMax in order to use MorphSVGPlugin/DrawSVGPlugin - TweenLite and CSSPlugin are adequate. So I didn't want to force a TweenMax dependency. But yeah, we're working on a more ES6-ified version that should smooth out these things better in the future.

Thanks for being a longtime user and supporter! Let us know if you need anything else at all. Happy tweening!

jackdoyle commented 6 years ago

This should be resolved in 1.20.5 due to the ES module structuring. Let us know if not, though, and we'd be happy to take a peek.