Closed olignyf closed 2 years ago
That error sounds like an issue in your setup not recognizing ES Modules (unrelated to GSAP). I'm not familiar with Jest but it sure sounds like you just need to tweak something in your environment so that you're either using the standard ES5 files (in the /dist/ directory) or make sure your tooling is configured to allow ES Modules ("import" and "export" are hallmarks of ES Modules).
Thanks for your reply to narrow down the issue to ES modules. But I have 36 main packages dependencies and gsap is the only one producing this error. I am importing with "import" and "export" in hundreds of files with other packages and it works well.
Hi @olignyf It's virtually impossible for us to troubleshoot blind. I'm relatively confident this has nothing to do with GSAP because thousands of people are using it every day (11+ million sites) and nobody else is reporting something similar.
Like I said, that error sure sounds like an indication that your particular environment isn't set up to handle ES Modules. Perhaps the other libraries you're using aren't using ES Modules by default(?) Have you tried importing the ES5 files instead for GSAP (in the /dist/ directory) like:
import gsap from "gsap/dist/gsap"; import ScrollToPlugin from "gsap/dist/ScrollToPlugin"; ...
?
Just because you are using import does not mean you are importing an ES Module. Tools like webpack and babel have really blurred the lines of what is actually an ES Module or just CommonJS module.
According to this, it says that ES Module support is experimental.
https://jestjs.io/docs/ecmascript-modules
So if you're getting that error, you should import the UMD/CommonJS files from the dist folder.
I've been having this error and wonder if someone found a fix for it? gsap 3.9.1 This happens in Jest unit tests