cljsjs

leontalbot 2016-04-28T13:09:14.000141Z

Hello! What do I do when js lib is only available minified?

leontalbot 2016-04-28T13:09:34.000142Z

Would this be fine?

leontalbot 2016-04-28T13:09:52.000143Z

(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")
   ...))

leontalbot 2016-04-28T13:10:16.000144Z

copy min source to development

leontalbot 2016-04-28T13:10:27.000145Z

minify again for production

leontalbot 2016-04-28T13:10:33.000146Z

??

leontalbot 2016-04-28T13:10:35.000147Z

Thanks!

leontalbot 2016-04-28T13:23:38.000148Z

when I boot prod a hoplon template (advanced compilation), it compiles fine.

juhoteperi 2016-04-28T14:05:55.000150Z

@leontalbot: Isn't stripe already packaged?

leontalbot 2016-04-28T14:06:15.000151Z

nope. task not completed

juhoteperi 2016-04-28T14:06:54.000152Z

https://github.com/cljsjs/packages/tree/master/stripe ?

leontalbot 2016-04-28T14:07:24.000154Z

(deftask package []
  (comp
    (pom)
    (jar)))

juhoteperi 2016-04-28T14:07:47.000155Z

So? It doesn't need to do anything else. It is just for the extern.

leontalbot 2016-04-28T14:08:07.000156Z

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

juhoteperi 2016-04-28T14:08:34.000157Z

you don't need such require, the extern is used always

leontalbot 2016-04-28T14:08:43.000158Z

oh

juhoteperi 2016-04-28T14:08:44.000159Z

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

juhoteperi 2016-04-28T14:09:04.000160Z

Stripe.js file can't be packaged in the jar because it must/should be loaded directly from stripe server.

juhoteperi 2016-04-28T14:09:16.000161Z

> Note: Stripe.js should be loaded directly from https://js.stripe.com/v2/. https://stripe.com/docs/stripe.js

juhoteperi 2016-04-28T14:09:50.000163Z

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.

leontalbot 2016-04-28T14:10:09.000164Z

Ok!

leontalbot 2016-04-28T14:10:35.000165Z

Not sure what "The Stripe js API will still need to be provided through some other mechanism." means

juhoteperi 2016-04-28T14:10:55.000166Z

you shuld add &lt;script type="text/javascript" src="https://js.stripe.com/v2/"&gt;&lt;/script&gt; to your html

leontalbot 2016-04-28T14:11:09.000167Z

ah ok

leontalbot 2016-04-28T14:11:36.000168Z

thanks a lot!

juhoteperi 2016-04-28T14:11:52.000169Z

This was discussed just few days ago, I'll write a wiki page about this

leontalbot 2016-04-28T14:11:59.000170Z

Cool!

leontalbot 2016-04-28T14:14:35.000171Z

one thing though

leontalbot 2016-04-28T14:17:12.000172Z

the extern.js file is way shorter then when I use https://github.com/jmmk/javascript-externs-generator

juhoteperi 2016-04-28T14:18:12.000175Z

It is written by hand. I don't know if it complete, but generator often includes unncesessary properties and methods.

juhoteperi 2016-04-28T14:19:13.000176Z

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.

leontalbot 2016-04-28T14:20:38.000177Z

good to know

leontalbot 2016-04-28T14:21:59.000178Z

The tool I used is tagged "recommended" in the wiki. Not sure if the other one would be less verbose

juhoteperi 2016-04-28T14:24:23.000182Z

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.