-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue with using svelte-fusioncharts in sapper(framework for svelte) #5
Comments
I was able to get the library to work with sveltekit by disabling ssr, I do still occasionally get this error message though
Another way of preventing sapper or sveltekit from trying to use the library on the serverside would be to dynamically import the library on mount using the promise form of import but that kind of defeats the purpose of it being a component import('svelte-charts').then(...) |
@odama626 do you have any tip? thanks |
that sounds like it is trying to call some fusioncharts code on the server and it's failing because "document" doesn't exist. I just realized I forgot to mention that using the module context only works in routes, added a note to the comment try wrapping your relevant code in a browser check import { browser } from '$app/env'
if (browser) {
// fusionChart code
} |
thanks for the reply, i was trying, but still document is not defined, if i refresh the page it works, but on console still the error, which indeed seems to be running on the server this is my code
|
yeah, it looks like you need to use the dynamic import, something like this
|
Thanks a Lot, manage to get the charts working! |
While using it with sapper I get the below error:
/home/satyam/my-app/node_modules/fusioncharts/fusioncharts.js:13
"function"!=typeof Object.assign&&(Object.assign=function(e){"use strict";var t,r,n,a;if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(t=Object(e),r=1;r<arguments.length;r++)if(null!=(n=arguments[r]))for(a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a]);return t}),Function.prototype.bind||(Function.prototype.bind=function(e){"use strict";var t,r,n,a;if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");return t=Array.prototype.slice.call(arguments,1),r=this,n=function(){},a=function(){return r.apply(this instanceof n?this:e,t.concat(Array.prototype.slice.call(arguments)))},this.prototype&&(n.prototype=this.prototype),a.prototype=new n,a}),!document.head&&(document.head=document.getElementsByTagName("head")[0]),function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define(
ReferenceError: document is not defined
The text was updated successfully, but these errors were encountered: