This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-26
Channels
- # beginners (145)
- # boot (19)
- # calva (61)
- # cider (33)
- # cljs-dev (15)
- # cljsrn (16)
- # clojure (35)
- # clojure-dev (39)
- # clojure-russia (2)
- # clojure-spec (10)
- # clojure-uk (7)
- # clojurescript (5)
- # cursive (14)
- # data-science (1)
- # datomic (3)
- # figwheel-main (9)
- # fulcro (46)
- # jobs (4)
- # off-topic (8)
- # quil (6)
- # re-frame (5)
- # shadow-cljs (70)
- # spacemacs (3)
- # speculative (2)
- # tools-deps (2)
Has anyone used jsPDF with shadow? doing this causes 14 identical errors in the JS console
(ns foo.bar
(:require ["jspdf" :as jspdf]))
(jspdf.)
jspdf.min.js:formatted:1787 jsPDF PubSub Error t.existsFileInVFS is not a function TypeError: t.existsFileInVFS is not a function
but if i load jsPDF from a CDN, then it works fine via (js/jsPDF.)
and the weird thing is, if i have the lib loaded from a CDN, then the shadow require version works without error also
could that mean shadow/npm is not pickup a transitive dependency, but it is loaded when i use the CDN?
@lilactown exactly. I can use the repl normally, but can’t pprint
@currentoor jsPDF looks like a terrible package. is leaks a bunch of stuff into the global scope
I suspect that jsPDF relies on those leaked globals in some way but closure decides to rename them at some point
which would explain why the CDN + require'd version work together since the CDN version creates those globals
hmm looks like it’s the leading PDF builder in JS, is there anything that can be done? (i guess using the CDN is the backup)
I'm think about ways to do this https://github.com/thheller/shadow-cljs/issues/173
but the package doesn't follow any established JS packaging standards and just does something random it seems
oh wow thanks for doing all this
you always go above and beyond, thank you so much!
the other option is pdfkit, but that was having browserify issues
it looks like it requires browserify to work
i do have the option of requiring either library in a script tag, so i might just do that
i didn’t know packages could be tied to browserify like that
seems like a weird thing to be tied down to
yeah it’s crazy 😅
don't know why it is trying to use that from the global or why its different in webpack
that is strange
@thheller I am writing a electron + shadow.cljs app and i have a particular use case where once the app is loaded i am trying to read some config written in cljs file that is not in the namespace. i.e
(defn load-global-config
([] (load-file “~/.b42/init.cljs”))
([config-file] (load-file config-file)))
I am getting an error goog.nodeGlobalRequire
is not a function. Also it seems the foreign-lib is also not supported. Could there be a possible way to to this in an electron app?@metacritical I have no idea what you are asking. that code snippet does not tell me anything. you can't load .cljs
at runtime unless you are using self-hosted CLJS
foreign-libs are not supported that is correct. https://shadow-cljs.github.io/docs/UsersGuide.html#cljsjs
by load-file
I assume you mean cljs.core/load-file
which is only for self-hosted CLJS and not usable otherwise
its a different story if the file you want to load is just EDN data you want to access
but actual CLJS code you want to evaluate will only work in a self-hosted environment
@thheller I understand what you are saying so my next question is can i have a self hosted clojurescript with a target
:node-script
Yes and i used it, and it is great!
https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/bootstrap/browser.cljs
Aha, the current shadow docs has :bootstrap as a target to support the self hosting in browser, how would node target be?
the bootstrap stuff is identical, the generated index is identical. no changes there.
I understand, so i should submit a patch for this?
not needed. you can do this in your app, nothing in shadow-cljs itself needs to change to support this
so making something general might not be optimal depending on what you are actually trying to do
Aah, sure thats actually helpful thankyou!
also things are a bit more complicated for electron if you want to support loading files from .asar
and stuff
Currently i am not considering .asar support! but what you suggested is quite helpful.