Hello! What do I do when js lib is only available minified?
Would this be fine?
(deftask package []
(comp
(download :url "<https://js.stripe.com/v2/>"
:name "v2.js"
:checksum "781618FEB2DA41191A8AB37D3EF5B674"
:unzip false)
(sift :move {#"v2.js" "cljsjs/stripe/development/stripe.inc.js"})
(minify :in "cljsjs/stripe/development/stripe.inc.js"
:out "cljsjs/stripe/production/stripe.min.inc.js")
...))
copy min source to development
minify again for production
??
Thanks!
when I boot prod
a hoplon template (advanced compilation), it compiles fine.
@leontalbot: Isn't stripe already packaged?
nope. task not completed
(deftask package []
(comp
(pom)
(jar)))
So? It doesn't need to do anything else. It is just for the extern.
When I try I get
ERROR: No such namespace: cljsjs.stripe, could not locate cljsjs/stripe.cljs, cljsjs/stripe.cljc, or Closure namespace "cljsjs.stripe" in file /Users/leontalbot/.boot/cache/tmp/Users/leontalbot/Dropbox/Sites/hoplon-stripe/1d8/62mkia/hoplon/app_pages/_index_DOT_html.cljs at file hoplon/app_pages/_index_DOT_html.cljs
you don't need such require, the extern is used always
oh
"The jar only provides an extern file required for advanced compilation. The Stripe js API will still need to be provided through some other mechanism."
Stripe.js file can't be packaged in the jar because it must/should be loaded directly from stripe server.
> Note: Stripe.js should be loaded directly from https://js.stripe.com/v2/. https://stripe.com/docs/stripe.js
This is because the library is not versioned, they update the code anytime and you might be vulnerable if you are using old version from the package.
Ok!
Not sure what "The Stripe js API will still need to be provided through some other mechanism." means
you shuld add <script type="text/javascript" src="https://js.stripe.com/v2/"></script>
to your html
ah ok
thanks a lot!
This was discussed just few days ago, I'll write a wiki page about this
Cool!
one thing though
the extern.js file is way shorter then when I use https://github.com/jmmk/javascript-externs-generator
It is written by hand. I don't know if it complete, but generator often includes unncesessary properties and methods.
E.g. methods prefixed with underscore are "private" and should not be called by application using the lib, thus they are not needed on the extern.
good to know
The tool I used is tagged "recommended" in the wiki. Not sure if the other one would be less verbose
https://github.com/cljsjs/packages/wiki/Extern-only-packages
The externs shoud be fine even if they include unncessary stuff. It might cause minor size increase in optimized output file, but the effect is probably minimal.