Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Thomas Popoff

Unable to import DrawSVGPlugin inside a generator-webapp project

Recommended Posts

Hello everyone !

 

I'm working on a project generated with https://github.com/yeoman/generator-webapp

I added GSAP with npm, and added this line to my index.html

<!-- build:js scripts/vendor.js -->
// Here is where I usually add plugins and dependancies
<script type="text/javascript" src="/node_modules/gsap/dist/gsap.min.js"></script>
<!-- endbuild -->

But when I do the same with my DrawSVGPlugin.min.js file, I have this error on my browser :

Cannot set property window of #<Window> which has only a getter

 

I'm also using ScrollTrigger plugin on this website, and everything works fine...

 

Do you have a better idea to import this plugin to my project ?

 

Thank you !

Link to comment
Share on other sites

Welcome to the forums @Thomas Popoff

 

I haven't seen that before. Have you tried other files in the package to see if it throws the same error with them? And how did you install using npm?

Link to comment
Share on other sites

Actually, I only import GSAP with NPM. Because DrawSVGPlugin is a premium plugin, I need to import it "manually" 

<script type="text/javascript" src="/scripts/DrawSVGPlugin.min.js"></script>

I tried different files from the plugin folder

 

when I use the DrawSVGPlugin.min.jo from minified, I have the error above. Same for /umd/ folder file.

 

I tried the file in /esm/ folder, and then I have this error

DrawSVGPlugin.js:3 Uncaught ReferenceError: exports is not defined at DrawSVGPlugin.js:3

 

same for /src/ folder...

 

Don't know if I can perform other tests...?

Link to comment
Share on other sites

It seems like you're loading the correct file via the <script> tag, DrawSVGPlugin.min.js - I've never heard of anything like this before. Can you please provide a minimal demo that allows us to reproduce the issue? Based on the error you mentioned, it sounds like something is literally trying to set window.window = ?? (something) which DrawSVGPlugin definitely doesn't do. And nobody else has reported a similar issue, so I'm perplexed. Sounds like maybe an issue in your particular environment which is why a minimal demo would help. If we can reproduce the issue on our end, I'm sure we can figure out a solution if it's GSAP-related. 🤷‍♂️

Link to comment
Share on other sites

I found my issue !

 

Because of my JS pre-processor, every file inside the /script/ folder is pre-processed, and it generate this issue.

I created a folder and I include my file from this folder, and everything is fine !

 

Thanks for your help, and sorry for the time you lost, it was my bad

Have a nice day !

  • Like 1
Link to comment
Share on other sites

No problem - glad you figured it out! Thanks for letting us know. 

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