greensock / GSAP

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

Module ''gsap'' has no exported member 'TextPlugin'. #279

Closed r0skar closed 6 years ago

r0skar commented 6 years ago

Is there a specific reason why the TextPlugin is not exported just like TweenLite, TimelineLite etc.?

I noticed that its there, but when trying to import it directly, it doesnt work.

import { TextPlugin } from 'gsap/TextPlugin'

 import { _gsScope } from "./TweenLite.js";
  ^

  SyntaxError: Unexpected token {
  at new Script (vm.js:73:7)
  at createScript (vm.js:245:10)
  at Object.runInThisContext (vm.js:297:10)
  at Module._compile (internal/modules/cjs/loader.js:657:28)
  at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
  at Module.load (internal/modules/cjs/loader.js:599:32)
  at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
  at Function.Module._load (internal/modules/cjs/loader.js:530:3)
  at Module.require (internal/modules/cjs/loader.js:637:17)
  at require (internal/modules/cjs/helpers.js:20:18)

While importing it as UMD module works, it causes webpack to bundle TweenLite twice.

jackdoyle commented 6 years ago

Well, the default "gsap" package is actually just TweenMax (and all of its contents) which doesn't include TextPlugin. So that's why it's not exported, but of course you can import it directly from "gsap/TextPlugin" as you said.

I didn't quite understand your question, though - are you asking why the UMD version would cause TweenLite to be bundled twice or were you saying you think there's a problem with TextPlugin or something else? It might help if you provided a reduced test case that I can run on my end to see the issue. I'd be happy to take a peek. And you are using the latest version, right? (2.0.1)

r0skar commented 6 years ago

Hey - thanks for the explanation. About my issue: after digging into it, i think it is actually related to my webpack config.

jackdoyle commented 6 years ago

Yeah, it kinda smelled like a webpack thing. Thanks for letting us know. Don't hesitate to post back here if/when you figure out a solution in case someone else runs into a similar problem.