Fork me on GitHub
#clojurescript
<
2019-02-19
>
VSRΞV00:02:00

Thin wrapper around Ant Design React components using Reagent https://github.com/hypaer/ant-man

myguidingstar07:02:34

is there a one-liner to start cljs node repl with cli (`clj`)?

myguidingstar07:02:07

found it: clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.520"}}}' -m cljs.main --repl-env node

👍 5
gekkostate08:02:40

Quick question. If I want to translate const { specificComponent } = require('some-library') into ClojureScript, how would that work?

pradyumna08:02:22

@gekkostate you can try (def SpecificComponent (.-specificComponent (js/require 'some-library')))

gekkostate08:02:53

Ok, sweet! I’m trying to basically grab this: https://electronjs.org/docs/api/dialog

gekkostate08:02:02

I tried the what you said above (replaced js/require with nodejs/require) and I get “Can’t access property of undefined.”

pradyumna08:02:37

ok, this is what i used for re-natal

pradyumna08:02:07

in your case, the (js/require '..') returns nil

pradyumna08:02:27

so mostly its unable to find the package

pradyumna09:02:27

something to do with how you are adding your foreign libs to cljsbuild spec

gekkostate09:02:47

Interesting! So, I’m using the (def Electron (nodejs/require "electron")) and the app runs successfully (meaning it found the package) but doesn’t work for a component? 😛

pradyumna09:02:28

is that component in "electron" or in a different library

gekkostate09:02:58

It’s in electron but according to the link above, it says we have to reference .remote

pradyumna09:02:14

oh that is one more level deep

gekkostate09:02:27

So I tried (def dialog (-.dialog (.remote Electron)))

pradyumna09:02:52

or .-remote.dialog

gekkostate09:02:22

No, it’s not working. 😞 I’m eventually calling it as (.-showOpenDialog dialog)

pradyumna09:02:04

ok, there is two different type of access

pradyumna09:02:13

for property access use ".-"

pradyumna09:02:20

but for function call just "."

pradyumna09:02:32

so it should be (.showOpenDialog dialog)

pradyumna09:02:49

and (def dialog (.-remote.dialog Electron))

gekkostate09:02:11

YES! It works 😄 WOOO. So I referenced Electron directly. I did (.showOpenDialog (.-remote.dialog Electron)

gekkostate09:02:30

Thanks a ton!

borkdude10:02:07

what’s a good alternative for println when debugging macros in CLJS node?

darwin11:02:02

@borkdude macros are clojure code so usual tools should apply, when having complex macros I tend to refactor a macro to just call into a clojure function, this function then can be debugged from plain clojure, if you really need printing during a macro call System/out should work

darwin11:02:58

also macroexpand-1 is your friend (at REPL)

borkdude11:02:04

yeah. I have some problem with a macro in a .cljc file which does something depending on an env variable. it’s very finicky to see when it’s called.

borkdude11:02:32

the macroexpansion etc is correct, I just want to see why it’s being triggered while it shouldn’t be

borkdude11:02:04

I’m undefining some specs in a test, but CLJS spec also does some things at macro-expansion time, so they are undefined in other tests too

borkdude11:02:03

I guess I’ll just have to write a different test suite for that one test, since I can’t dynamically switch between defined and undefined

gekkostate13:02:54

Any recommendations on csv parsers? I’m using https://github.com/testdouble/clojurescript.csv but it’s severely lacking on the read functionality. I was using clojure/data.csv but can’t seem to use it with Clojurescript.

joelsanchez13:02:17

why isn't :parallel-build true the default?

abdullahibra14:02:03

is there anybody experienced any problem with font-awesome icons in clojurescript project?

dnolen14:02:23

@joelsanchez historically there were some bugs so wasn't enabled by default

abdullahibra14:02:35

i'm not able to access resources/public/fonts/ content using http calls, actually i proxyed the jar behind nginx

manutter5114:02:26

We’re using the public CDN for FontAwesome, but even so, it seems like you ought to be able to access the files in your local resources directories. I assume you’re not having problems with things like resources/public/css and resources/public/js, etc?

manutter5114:02:54

Actually, I’m looking at the setup instructions, and it has a webfonts directory instead of just a fonts directory, maybe there’s something misconfigured? https://fontawesome.com/how-to-use/on-the-web/setup/hosting-font-awesome-yourself

abdullahibra14:02:21

@manutter51 so you only refer to CDN urls in your index.html ?

abdullahibra14:02:54

is it working with https or http ? are you using jar directly or as proxy with apache or nginx ?

manutter5114:02:09

Actually, what we’re currently using is just one line in the basic index.html page:

<script defer src=""></script>

manutter5114:02:58

It’s working fine both in local dev and in our “production” jar, which we have behind nginx

manutter5114:02:24

(but of course the fontawesome stuff is coming directly from fontawesome, we’re not getting it through nginx)

abdullahibra14:02:08

in production you are using https ?

abdullahibra14:02:34

it was working fine with me in http mode , when i cconverting to use https i got lost icons

manutter5114:02:05

Yeah, if you’re going direct to http://fontawesome.com via https, it should work fine when your app server also goes to https.

manutter5114:02:59

Let me double-check if our “prod” server is https

abdullahibra14:02:39

btw which is better to use the url like above or download it at js dir and use it like static file ?

manutter5114:02:46

ah, ok, no, we’re not behind https yet — I remember now, nginx was so we could put it on port 80

manutter5114:02:27

We use the http://fontawesome.com url on the theory that they’ve got more powerful servers than we do.

abdullahibra14:02:32

that's really good, thanks 🙂

sparkofreason15:02:41

What I want: representation of HTML DOM as CLJS data structures, PLUS a relationship to navigate to/from those data structures and the corresponding DOM object references. Don't really care how I get there, whether starting with hiccup and generating DOM or walking existing DOM and generating hiccup (or whatever). Just for purposes of experimentation. Anybody know of some existing code that does this? Doesn't seem hard, but it's for a side project, and it would be great if this was already done and could save me a little time.

darwin15:02:57

not sure if I fully understand, but one way from DOM->cljs could be done by extending cljs protocols on DOM types: https://github.com/binaryage/dirac/blob/master/src/shared/dirac/shared/dom/shim.cljs#L14-L36

darwin15:02:18

it is a bit dangerous, but if you have js env fully under your control it could be a way to go

john17:02:18

Might be reasonable to implement a datify navigator over dom nodes?

john18:02:15

I guess that doesn't do the 2 way thing

john18:02:10

But you could at least navigate the Dom as data

tavistock17:02:16

what is the closest cljs thing to java.io.OutputStream? I'm working on porting the [bencode](https://github.com/nrepl/bencode) library to cljs.

jaide17:02:08

Would it be process.stdout?

tavistock18:02:32

that seems like it would be to node specific and its an instance, i probably want a class/interface

tavistock18:02:11

it seems like <Stream> may be what i want

jaide18:02:09

Ah sorry, I misunderstood.

jaide18:02:59

[redacted snippet]
I’ve put a macro in a .cljc file, but I don’t understand why the compiler is giving me such sass.

jaide18:02:37

Ok I figured out the immediate issue: When in cljc\cljc you don’t need :require-macros, only in .cljs files. However, that code wouldn’t work or solve the problem anyway since I’m relying on clj->js.

misha18:02:40

Greetings! I'm trying to use some :npm-deps. However (:require ["some-npm-module" :as xx]) does not work. But on the page served by figwheel required module is available as someNpmModule$$module$Users$myusername$Desktop$myproject$node_modules$some_npm_module$dist$commands. Help :)

misha18:02:30

yes, :install-deps true

misha18:02:58

basically, this variable in chrome dev console contains everything module provides, so it is downloaded and visible, but in a funky way

misha18:02:54

package-lock.json and package.json got generated as well

jaide19:02:10

Does (def xx (js/require "some-npm-module")) work for you @misha?

misha19:02:13

require is not defined

misha19:02:17

I used js/require in lein + re-natal setup ~2years ago, and it worked there. Here I am trying to get away with tools.deps + :npm-deps (+ figwheel-main), and understand nothing

dnolen19:02:51

@misha are you sure you need to use :npm-deps?

misha19:02:35

no clue, David, what would be preferred way? Module in question is prosemirror, e.g. but more recent versions: https://github.com/braintripping/re-view/blob/master/prosemirror/src/deps.cljs#L1-L10

misha19:02:58

if cljsjs would have it – I'd use that.

rakyi19:02:01

:npm-deps is an advanced feature, more reliable option is to use https://clojurescript.org/guides/webpack or shadow-cljs

dnolen19:02:48

@misha yeah I would avoid :npm-deps and things will get a lot simpler

misha19:02:04

@dnolen @jayzawrotny it turned out default settings (or I messed it up at some point) of figwheel-main put compiled main.js in project root, and I had some stale main.js in target/public/cljs-out/

jaide19:02:24

Good detective work

dnolen19:02:36

it's possible :npm-deps could seem to work - but remember no guarantee advanced compilation will actually work

dnolen19:02:20

@rakyi's suggestions are the most reliable ways

misha19:02:39

so I got page with stale imports, and was chasing my tail. cursive highlighted aliases as unresolved, which did not help either :)

misha19:02:29

I'll check webpack guide and shadow out, thank you @rakyi @dnolen