GSAP ScrollTrigger cannot be imported as module in build
See original GitHub issueEnvironment
Nuxt CLI v3.0.0-27383920.81ee59c Nuxt project info:
- Operating System:
Darwin
- Node Version:
v17.3.1
- Nuxt Version:
3.0.0-27383920.81ee59c
- Package Manager:
yarn@1.22.15
- Bundler:
Vite
- User Config:
build
- Runtime Modules:
-
- Build Modules:
-
Reproduction
npm i gsap
<script setup lang="ts">
import {gsap} from 'gsap'
// even though importing gsap like "import gsap from 'gsap'"
// is valid, it throws the error gsap.registerPlugin is not a function
// when running the production build
import ScrollTrigger from 'gsap/dist/ScrollTrigger'
// over here, the error is "Did you mean to import gsap/dist/ScrollTrigger.js?"
// Once it's done, it works, but there no longer is any typescript support
gsap.registerPlugin(ScrollTrigger)
</setup>
Describe the bug
Build errors
Additional context
No response
Logs
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Problems importing ScrollTrigger - GSAP - GreenSock
I'm confused about how to import ScrollTrigger into my svelte app. I tried: ... Cannot use import statement outside a module
Read more >Getting error `Cannot use import statement outside a module ...
This is a common issue for frameworks that do SSR because of past limited support for ES Modules in a node environment. import...
Read more >GSAP 3.10.3 not importing ScrollTrigger/ ScrollSmoother ...
I am importing in gsap, ScrollTrigger & ScrollSmoother but I am getting ... Have you tried importing the UMD modules from the dist...
Read more >Import ERROR with ScrollTrigger in Next JS - GSAP
whenever I use on simple GSAP it works brilliant in NEXT JS but with ScrollTrigger it gives an import error. My code is:...
Read more >Unable to import plugins... - GSAP - GreenSock
Hey, Whenever I try to import a plugin the build fails with this ... module' (758:0) while parsing /node_modules/gsap/ScrollTrigger.js while ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This worked for me (combination of answers before):
In nuxt.config.ts:
in app.vue:
@StevenJPx2 you are correct, sorry I overread your need for TS support.