Jump to content
Search Community

Recommended Posts

Posted

Hi,

 

I'm a member of the GreenSock club and successfully downloaded and installed GSAP 3.0 and bonus plugins using the gsap-bonus.tgz method with YARN. I'm now trying to import the DrawSVGPLugin but it's throwing errors in my Terminal and then also in my browser.

 

This is the setup in my main app index.js:

 

import 'dom4'
import 'svgxuse'
import domready from 'domready'
import { gsap } from 'gsap'
import { DrawSVGPlugin } from 'gsap/DrawSVGPlugin.js'
import Swup from 'swup'
import SwupBodyClassPlugin from '@swup/body-class-plugin'
import SwupJsPlugin from '@swup/js-plugin'
import GlobalHeader from '../global-header'
import ProjectGallery from '../our-work/project-gallery'
import Contact from '../contact'
import GlobalFooter from '../global-footer'
import ScrollBtn from '../scroll-btn'
import InView from '../in-view'

gsap.registerPlugin(DrawSVGPlugin)

This is the error that is showing in my Terminal:

 

ERROR in bundle.js from UglifyJs
SyntaxError: Unexpected token: keyword (var) [./~/gsap/DrawSVGPlugin.js:208,0]

And this is the console error in my browser (Chrome):

Uncaught SyntaxError: Unexpected token 'export'

I can see the plugin inside the node_modules/gsap folder.

 

I'm also running [email protected]

 

Any help would be greatly appreciated.

 

Thanks,

Dayne

Posted

It definitely sounds like an issue in your build system. Perhaps your setup doesn't understand ES Modules? If that's the case, then just import the ES5 UMD files from the /dist/ directory like:

import { gsap } from 'gsap/dist/gsap.js'
import { DrawSVGPlugin } from 'gsap/dist/DrawSVGPlugin.js'

Does that help? 

  • Like 3
  • Thanks 1
Posted

Thanks so much for getting back to me. That method worked perfectly.

  • 1 year later...
Posted

I had this problem with Nuxt.js, and by adding :

build: {
  transpile: ['gsap']
}

in my nuxt.config.js file it worked correctly.

  • Like 1
  • Thanks 2
  • 9 months later...
Muzammil hasan
Posted

Importing UMD files like this, is throwing TypeScript error.

 

Posted

Sorry Muzammil is that a question?

If so could you elaborate a bit?

Posted

We do provide TypeScript definition files for the ES Modules. Perhaps you need to point your build system to those? I'm not much of a TypeScript expert, sorry. 

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...