Fork me on GitHub
#clojurescript
<
2020-05-06
>
ivana10:05:39

Hello! I need check some regex on frontend side, f.e. emails, phones, etc. I found out a lot of examples, but they are different for Java and JS. Which ones should I use in Clojurescript? Maybe there are some shared examples?

gklijs13:05:09

I tried using wasm from Clojurescript, using the new way from https://clojurescript.org/guides/webpack but it doesn't work as easily as react does. Does someone has a clue, current state at https://github.com/gklijs/cljs-gl-3d.

dnolen13:05:33

@ivana you should follow JavaScript regex examples

dnolen13:05:09

@gklijs you didn't include the package.json so it's a bit hard to tell what will happen

dnolen13:05:49

@noisesmith, @lilactown assessment is correct - you cannot share data between two independent JS contexts - this always true - it doesn't matter what JS environment you're talking aobut

✔️ 8
gklijs13:05:59

@dnolen added package.json

dnolen13:05:50

@gklijs I think the problem is that the file name doesn't correspond to the require - I have a feeling this is a case not covered in the Node module resolver - nothing really to do with WASM

dnolen13:05:59

I would just try a different dependency

dnolen13:05:26

feel free to open a ticket about the issue - about resolution (not WASM)

andrea.crotti13:05:33

I'm trying to set up smoke tests with etaoin on a clj/cljs project, that should be easily runnable both from the repl and as tests in CI and locally

andrea.crotti13:05:20

does anyone have some example set up I can look at (steal)? we are using to set up the whole system, which poses the first questions since I'd like to have both jetty servers running at the same time in the repl. So in general I was thinking that I could do something like

(defn fixture-driver
  "Executes a test running a driver. Bounds a driver
   with the global *driver* variable."
  [f]
  (e/with-firefox {} driver
    (binding [*driver* driver]
      (f))))

(defn config
  []
  (-> dev-config
      (merge (figwheel-config "automation"))
      ;; the port change is just for convenience locally
      ;; to avoid conflicting with the running jetty
      (assoc-in [:server/jetty :port] 3334)))

(defn start-everything
  [f]
  (ig.repl/set-prep! config)
  (ig.repl/go)
  (f)
  (ig.repl/halt))

(use-fixtures :once start-everything)
(use-fixtures :each fixture-driver)
but I have a few problems already, if anyone has done something similar I'd love to have a look how you did it

andrea.crotti13:05:02

the first weird thing is with figwheel-main

(figwheel.main/status)
------- Figwheel Main Status -------
Currently available: automation, dev
No builds are currently being built.
nil
but if I try to restart the build
1. Caused by clojure.lang.ExceptionInfo
   A build with id "automation" is already running.
   {}
so somehow it's running but I can't access it or it's just confused I'm not sure

dnolen14:05:10

@andrea.crotti might want to also ask in #figwheel-main

andrea.crotti14:05:47

yes thanks @dnolen, I asked here because I was just looking for the whole set up if anyone had suggestions, I can probably figure out the problems with the various pieces, just to check that my approach made sense

dnolen14:05:46

@andrea.crotti this looks pretty figwheel-main specific to me

dnolen14:05:15

one thought is that this seems like it could become overly complicated - I don't know why you would want figwheel running in your testing setup

dnolen14:05:02

build once, run your tests - seems like a removing a lot of unneeded complexity

andrea.crotti14:05:21

uhm well the pieces involved imho are kaocha+etaoin+figwheel-main+jetty+sassc (mostly managed via integrant) for example

andrea.crotti14:05:36

ah yes I probably can avoid running figwheel you're right

dnolen14:05:57

yes, just remove that bit - I think you can get it working just fine

dvingo15:05:48

i'd like to expose a javascript object that a js library requires to have certain functions on - what is the idiomatic way to do that in cljs?

dvingo15:05:42

current thought is to:

(def myobj
    #js {"apiFnOne" (fn [_] (println "hi"))})

dnolen16:05:39

that works

👍 4
Adrian Smith18:05:36

hey, I'm following the new webpack guide here: https://clojurescript.org/guides/webpack and was wondering once I have a repl up with the -r flag, what port/repl type do I need to connect to if I want to access it in Cursive?

dnolen18:05:20

@sfyire no port configuration is necessary

dnolen18:05:34

somebody recently asked this question on ClojureVerse, it's trivial to make it work

dnolen18:05:48

ClojureScript REPL is modeled after clojure.main

dnolen18:05:14

so you can literally use the clojure.main option in cursive and just pass the additional parameters from the guide

Adrian Smith18:05:06

Is my REPL configuration correct?

Adrian Smith18:05:57

ohh I've got to run with deps but can't select that for some reason, will try re-creating

dnolen18:05:04

right you probably need to import existing project using the deps template

👍 4
Adrian Smith18:05:47

cool got it working, is it possible with an emacs configuration?

dpsutton18:05:07

what is an emacs configuration?

dpsutton18:05:32

its straightforward in inf-clojure and should be straight forward with piggieback and nrepl but i haven't tried that route yet

dnolen18:05:21

@sfyire every REPL tool I'm aware of should work with standard ClojureScript REPL at this point

dnolen18:05:24

so that includes Emacs

ingesol20:05:17

I got https://github.com/Olical/cljs-test-runner working again with :bundle target. The problem is actually in https://github.com/bensu/doo, where I introduced an :output-to option in doo-opts . So you specify the post-webpack output file (`main.js`) there. This dep in your project adds support for the new doo-opt :output-to

doo {:git/url ""
     :sha     "6b23f6dda71576898e98a8c10188fa777b1af0b0"}
I might have got it all wrong in other ways, but at least that fixed my problem. Use at your own risk.