Fork me on GitHub
#clojurescript
<
2017-09-06
>
ag01:09:27

unfortunately I can't even require it. All dependencies: react react-dom react-test renderer are installed, importing enzyme in node repl works. doing this:

(require 'cljs.repl)

(require 'cljs.repl.node)

(def repl-env (cljs.repl.node/repl-env))

(cljs.repl/repl repl-env)

;; and then 
cljs.user=> (require '[enzyme :refer [shallow]])

ag01:09:32

doesn't ;(

ag01:09:20

strangely enough, the following works:

(def enzyme (js/require "enzyme"))

hparyani4904:09:39

does anybody know of a good payment gateway that can be integrated in my react-native app and also that works in India

Roman Liutikov08:09:43

@ag I guess your cljs build config should have :target :nodejs

pesterhazy12:09:05

@hparyani49 I've used both braintree and stripe in a cljsrn app, both worked fine. Not sure if they work in India

pesterhazy12:09:38

stripe is much better than braintree but customers in Europe often want Paypal

hparyani4912:09:46

Ya they don't work here, anything else that you might be aware of?

hparyani4913:09:33

Thanks sir, I'll check and revert back

pesterhazy13:09:45

@hparyani49 there's also #cljsrn for all your react-native needs 馃檪

hparyani4913:09:25

I'll join that , thanks a lot:smile:

Aron15:09:14

wow, lots of frameworks

marciol16:09:25

Hi all, There is something similar to https://github.com/babel/babel-standalone in clojurescript world?

marciol16:09:56

So that one can put small bits of clojurescript on the page.

dnolen16:09:17

@marciol ClojureScript optional bootstrapping can let you do that - but it does requires some effort

marciol16:09:31

hmmm, good to know @dnolen. There is a repo called cljs-bootstrap. Should I start with it?

tomc16:09:29

When compiling a prd build of a clojurescript app, I'd like some warnings to cause the build to fail - things like :undeclared-var and :undeclared-ns - is that possible/are there any plans to make it possible?

anmonteiro16:09:39

@marciol it鈥檚 in ClojureScript proper

anmonteiro16:09:42

cljs.js is the namespace

anmonteiro16:09:47

be aware that this is an advanced feature, so you鈥檒l be on your own for the most part

ag18:09:59

Does anyone know how to wrap piggieback around clj.repl/repl?

(require 'cljs.repl)
(require 'cljs.repl.node)
(def repl-env (cljs.repl.node/repl-env))
(cljs.repl/repl repl-env)

ag19:09:35

found the way:

(require 'cljs.repl)
(require 'cljs.repl.node)
(require 'cemerick.piggieback)
(def repl-env (cljs.repl.node/repl-env))
(cemerick.piggieback/cljs-repl repl-env)

ag19:09:50

I can't believe how amazing Clojurescript has become... awesome times!

deg20:09:28

Is there any way in ClojureScript to declare that a function must not be optimized away? I need to define something like (defn null-op [x] "") so that it will remain a function call even under any future advanced compilation, rather than optimize down to "".

hlolli20:09:42

@deg you could try adding extern var null-op = function(){}; and export the function (defn ^:export null-op [x] "") not sure if the export is needed, but extern is.

mfikes20:09:35

@deg If you are attempting to prevent inlining, that may be difficult. Hrm.

mfikes20:09:15

It may be sufficient to (def null-op (constantly "")), but that鈥檚 just a guess

cemerick20:09:36

Is there a recipe somewhere for using cljs.pprint for print-fn (presuming console.log underneath)? I'm stumbling on it.

pesterhazy21:09:54

@cemerick I'm curious, how would that help?

cemerick21:09:05

AFAICT, it's the only way I'll be able to eliminate type tags from (some) printed records

anmonteiro21:09:39

@cemerick is your problem that cljs.pprint/pprint takes a single argument?

cemerick21:09:31

@anmonteiro at the moment, my problem is that my set!'ing print-fn appears to have no effect at all! 馃槢

anmonteiro21:09:07

need more information

anmonteiro21:09:14

is that before or after enable-console-print!?

anmonteiro21:09:38

and perhaps there鈥檚 another way

anmonteiro21:09:55

can you give me an example of something that prints tags that you don鈥檛 want to see?

cemerick21:09:39

@anmonteiro I'm doing all my fiddling after enable-console-print As an example, loom graphs are records that have a long-ish fqn for their type, which leads to pretty unpleasant wrapping for most outputs.

anmonteiro21:09:07

gotcha, so the #cljs.user.Foo tags, for example

anmonteiro21:09:14

if there was a record Foo

mfikes21:09:11

IIRC, Figwheel has its own *print-fn* that you cannot replace

cemerick21:09:26

Yeah, this is outside of figwheel

cemerick21:09:45

but actually, its print-fn routes through pprint, and so I have all the control I want when I'm there

mfikes21:09:32

Hmm鈥 *print-fn* and *print-err-fn* are usually where things bottom out for env-centric stdout and stderr

cemerick21:09:00

Yeah, I've been fiddling with it for 20 minutes and haven't gotten anywhere, so I figured I'd ask

cemerick21:09:00

The tags aren't suppressable at runtime (baked in by emit-record). I've not had to bother with this in CLJS because I've generally done all my dev work in Clojure, then just tested in CLJS. No longer. 馃檪

ag21:09:44

maaan, I can't believe nobody has ever wrote a cljs wrapper for Enzyme (Airbnb testing lib - remember, the one they initially called Reagent and made a lot of our people angry. LOL). I'm trying to search on github and only biotech stuff popping up.... sigh

anmonteiro21:09:03

@cemerick so, this might not be what you want

anmonteiro21:09:08

but it works

anmonteiro21:09:11

(defrecord Foo [])

(extend-protocol IPrintWithWriter
  Foo
  (-pr-writer [o writer opts]
    (-pr-writer (into {} o) writer opts)))

cemerick21:09:37

hah, in through the backdoor

anmonteiro21:09:54

there are probably more clever solutions..

cemerick21:09:18

That's clever enough for now, thanks for the reminder

cemerick21:09:50

@anmonteiro I wonder if this isn't something anyone's necessarily tried to do, using pprint for *print-fn*?

cemerick21:09:59

@anmonteiro confirmed win :thumbsup:

anmonteiro21:09:06

@cemerick so the problem with cljs.pprint is that it calls out to *print-fn*

anmonteiro21:09:30

so you鈥檒l end up making an infinite loop *print-fn* -> cljs.pprint/pprint -> *print-fn*

deg21:09:17

@mfikes @hlolli Thanks, I'll try both ideas.

dnolen21:09:12

@hlolli @deg extern is not the way to do that, that pattern is discouraged in Closure鈥檚 own docs

dnolen21:09:19

only define externs for externs

dnolen21:09:25

^:export is what you want

dnolen21:09:39

or goog.exportSymbol if you need more control

mfikes21:09:13

It is not clear to me what @deg really wants. :export has clear semantics, but @deg's "not optimized away" could also be interpreted as prevent inlining.

dnolen21:09:05

@mfikes right but 鈥減reventing inlining鈥 isn鈥檛 really a reasonable expectation when dealing with Closure Compiler IMO 馃檪

mfikes21:09:05

Right. Perhaps a silly way to achieve that would be to make it鈥檚 body artificially large so the resulting code would be bigger if inlined. (Perhaps you鈥檇 also have to call it many times.) Hah

dragoncube22:09:00

How safe is to set :static-fns and :fn-invoke-direct to true, with :optimizations = :simple ?

dragoncube22:09:29

Pretty much the question is: Are there known set of flags which could be enabled for :optimizations = :simple and would give perfromance improvements 鈥渇or free鈥 (no potential runtime errors)?

anmonteiro22:09:48

@dragoncube :static-fns, :optimize-constants, :fn-invoke-direct, :elide-asserts