Jump to content
Search Community

NextJS and gsap

benjeske test
Moderator Tag

Recommended Posts

Hi I'm trying to load gsap into my nextjs project. I've got it nearly completed but I am getting this error from the package:

 

SyntaxError: Unexpected token 'export'

/node_modules/gsap/ScrollTrigger.js:534

line 534:

export var ScrollTrigger = /*#__PURE__*/function () {

Any advice for getting this to work? I've been searching but haven't been able to find any solutions to this problem.

Link to comment
Share on other sites

3 minutes ago, elegantseagulls said:

What does your import look like? For nextjs you'll need to import the umd version:


import gsap from 'gsap';
import { ScrollTrigger } from "gsap/dist/ScrollTrigger";

 

 

import ScrollTrigger from 'gsap/ScrollTrigger';

^ was what I was using

 

This was exactly the problem, thank you!!

Link to comment
Share on other sites

1 hour ago, elegantseagulls said:

What does your import look like? For nextjs you'll need to import the umd version:


import gsap from 'gsap';
import { ScrollTrigger } from "gsap/dist/ScrollTrigger";

 

I would assume that gets the UMD version of ScrollTrigger, but the ES Module of GSAP (the core). Shouldn't it look like this?

import { gsap } from 'gsap/dist/gsap';
import { ScrollTrigger } from "gsap/dist/ScrollTrigger";

 

  • Like 2
Link to comment
Share on other sites

6 minutes ago, GreenSock said:

I would assume that gets the UMD version of ScrollTrigger, but the ES Module of GSAP (the core). Shouldn't it look like this?


import { gsap } from 'gsap/dist/gsap';
import { ScrollTrigger } from "gsap/dist/ScrollTrigger";

 

Can confirm, I updated the gsap import as well to the /dist/ directory and it's working. Tested successfully locally and in my production environment.

  • Thanks 1
Link to comment
Share on other sites

5 hours ago, GreenSock said:

I would assume that gets the UMD version of ScrollTrigger, but the ES Module of GSAP (the core). Shouldn't it look like this?


import { gsap } from 'gsap/dist/gsap';
import { ScrollTrigger } from "gsap/dist/ScrollTrigger";

 

 

I think import { gsap } from 'gsap' gets the umd version in nextjs based on the main field in the package.json.

 

 

  • Like 4
Link to comment
Share on other sites

  • 11 months later...
  • 1 year later...

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