Duo Posted July 14, 2020 Posted July 14, 2020 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
GreenSock Posted July 14, 2020 Posted July 14, 2020 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? 3 1
Duo Posted July 16, 2020 Author Posted July 16, 2020 Thanks so much for getting back to me. That method worked perfectly.
FlyingZipper Posted September 20, 2021 Posted September 20, 2021 I had this problem with Nuxt.js, and by adding : build: { transpile: ['gsap'] } in my nuxt.config.js file it worked correctly. 1 2
Muzammil hasan Posted July 8, 2022 Posted July 8, 2022 Importing UMD files like this, is throwing TypeScript error.
Cassie Posted July 8, 2022 Posted July 8, 2022 Sorry Muzammil is that a question? If so could you elaborate a bit?
GreenSock Posted July 8, 2022 Posted July 8, 2022 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now