I've been using Vue.js a lot lately, and working with the webpack template. Importing GSAP after `npm install -s gsap` works correctly, but the ScrollToPlugin has some oddities.
In one of my Vue components, I have this:
import "gsap";
import ModifiersPlugin from "../../../node_modules/gsap/src/uncompressed/plugins/ModifiersPlugin.js";
And ModifiersPlugin works great.
But when I try to do the same for ScrollToPlugin...
import ScrollToPlugin from '../../../node_modules/gsap/src/uncompressed/plugins/ScrollToPlugin.js';
I get this error in Vue/Webpack
./~/gsap/src/uncompressed/plugins/ScrollToPlugin.js
Module not found: Error: Cannot resolve module 'TweenLite' in /Users/shaw/Sites/green-mountain/node_modules/gsap/src/uncompressed/plugins
resolve module TweenLite in /Users/shaw/Sites/green-mountain/node_modules/gsap/src/uncompressed/plugins
looking for modules in /Users/shaw/Sites/green-mountain/node_modules
/Users/shaw/Sites/green-mountain/node_modules/TweenLite doesn't exist (module as directory)
resolve 'file' TweenLite in /Users/shaw/Sites/green-mountain/node_modules
resolve file
/Users/shaw/Sites/green-mountain/node_modules/TweenLite doesn't exist
/Users/shaw/Sites/green-mountain/node_modules/TweenLite.js doesn't exist
/Users/shaw/Sites/green-mountain/node_modules/TweenLite.vue doesn't exist
looking for modules in /Users/shaw/Sites/green-mountain/node_modules
/Users/shaw/Sites/green-mountain/node_modules/TweenLite doesn't exist (module as directory)
resolve 'file' TweenLite in /Users/shaw/Sites/green-mountain/node_modules
resolve file
/Users/shaw/Sites/green-mountain/node_modules/TweenLite doesn't exist
/Users/shaw/Sites/green-mountain/node_modules/TweenLite.js doesn't exist
/Users/shaw/Sites/green-mountain/node_modules/TweenLite.vue doesn't exist
[/Users/shaw/Sites/green-mountain/node_modules/TweenLite]
[/Users/shaw/Sites/green-mountain/node_modules/TweenLite]
[/Users/shaw/Sites/green-mountain/node_modules/TweenLite]
[/Users/shaw/Sites/green-mountain/node_modules/TweenLite]
[/Users/shaw/Sites/green-mountain/node_modules/TweenLite.js]
[/Users/shaw/Sites/green-mountain/node_modules/TweenLite.js]
[/Users/shaw/Sites/green-mountain/node_modules/TweenLite.vue]
[/Users/shaw/Sites/green-mountain/node_modules/TweenLite.vue]
@ ./~/gsap/src/uncompressed/plugins/ScrollToPlugin.js 181:2-34
Looking at ScrollToPlugin.js, it seems to be triggered by this section of code at the very end, starting at line 174, which ModifiersPlugin does not have.
//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(define) === "function" && define.amd) { //AMD
define(["TweenLite"], getGlobal);
} else if (typeof(module) !== "undefined" && module.exports) { //node
require("../TweenLite.js");
module.exports = getGlobal();
}
}("ScrollToPlugin"));
Looks like the `require` on line 183 is triggering the error.
If I remove that block of code, the ScrollToPlugin works as expected.
I haven't tested all the other plugins, but I would assume if they have that block, they will produce a similar error.
Any idea what's going on?