-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
GSAP ScrollTrigger cannot be imported as module in build #2889
Comments
Is it works for you? import { gsap } from 'gsap';
import { ScrollTrigger } from 'gsap/ScrollTrigger';
gsap.registerPlugin(ScrollTrigger) |
No, same error all around. import { ScrollTrigger } from 'gsap/ScrollTrigger';
import { ScrollTrigger } from 'gsap/dist/ScrollTrigger';
import ScrollTrigger from 'gsap/ScrollTrigger';
import ScrollTrigger from 'gsap/dist/ScrollTrigger';
// all do not work
// only
import { ScrollTrigger } from 'gsap/ScrollTrigger.js';
import { ScrollTrigger } from 'gsap/dist/ScrollTrigger.js';
import ScrollTrigger from 'gsap/ScrollTrigger.js';
import ScrollTrigger from 'gsap/dist/ScrollTrigger.js';
// runs in production (build is fine, it's a runtime error) |
We may be able to improve this experience in dev (resolving to the id with But the core of this is a packaging issue with |
I tried it, this is the error I got:
|
Right now my solution for that is to use the script version of it like this in the nuxt.config.js/ts Also gsap is recommending this kind of, because the probability is high, that your user has already downloaded the script from another site. Downside is of course, if you only need in some specific components, but then you could also load it with useMeta there.
|
@chrispreisler I would say that this solution just goes back to the first issue that I have with ScrollTrigger. I need TS support, and that doesn't work if I import the js file. ScrollTrigger works perfectly otherwise. |
@StevenJPx2 you are correct, sorry I overread your need for TS support. |
This worked for me (combination of answers before): In nuxt.config.ts:
in app.vue:
|
Environment
Nuxt CLI v3.0.0-27383920.81ee59c
Nuxt project info:
Darwin
v17.3.1
3.0.0-27383920.81ee59c
yarn@1.22.15
Vite
build
-
-
Reproduction
npm i gsap
Describe the bug
Build errors
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: