Jump to content
Search Community

SVGMorph import showing "SyntaxError: Cannot use import statement outside a module" on React

Wired Avenue test
Moderator Tag

Recommended Posts

That must be an issue in your build process or something. It sounds like maybe you're using modules in an environment that doesn't permit that. Very difficult to troubleshoot blind, though. If you still need help, please provide a reduced test case so that we can replicate it on our end. A few things to try:

  • Import from the /dis/ directory because those are ES5 files (UMD). So like: 
    import { gsap } from "gsap/dist/gsap.js";
    import { MorphSVGPlugin } from "../gsap/dist/MorphSVGPlugin.js";

     

  • Maybe set up your build process to transpile earlier in the process. Like...if you're using the ES module files from GSAP, transpile those too. 
  • Remember that if you've got a <script> tag with imports inside of it, you must set type="module", like <script type="module">...</script>
  • Like 3
  • Thanks 2
Link to comment
Share on other sites

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