Fork me on GitHub
#clojurescript
<
2017-08-19
>
anmonteiro00:08:24

@symfrog what do you mean by fails?

anmonteiro00:08:07

oh I can repro

anmonteiro01:08:13

@symfrog hah, figured it out. the processed file doesn’t export a namespace

anmonteiro01:08:33

there’s no goog.provide so we can’t figure out what it provides

symfrog08:08:03

@anmonteiro Would cljs or closure allow npm packages such as this to be consumed for their side effects (in the bootstrap.js case adding a plugin to jQuery) in the future or would I have to specify a foreign lib for it?

amitayh08:08:22

weekend project: implement a purely functional cljs app using the elm architecture

andreasklein09:08:15

@amitayh cool! How about a bit more explanation of your work on the github page 🙂

amitayh09:08:38

@andreasklein thanks 🙂 i will write a more detailed explanation soon. programmers enjoy writing the code better than the documentation 🙂

andreasklein09:08:10

@amitayh One thing I don’t get yet is how ->Increment or generally ->Message works. As far as I see this is the construction of a record. But how does this record end up in your messages channel?

amitayh09:08:19

this is handled in render.cljs. i’m transforming the view data into a react component

amitayh09:08:52

every callback (`onSomething`) is wrapped to send the resulting message to the messages channel

andreasklein09:08:55

Thanks I see it now. This is “react magic” happening in to-prop

amitayh09:08:15

yes.. i wanted to keep all effects away from the “user code”

amitayh09:08:25

so that event handlers are just producing messages

andreasklein09:08:43

I find ->Message very esthetically pleasing

amitayh09:08:27

yes, it’s similar to how it actually looks in elm: https://guide.elm-lang.org/architecture/user_input/buttons.html

amitayh09:08:38

view : Model -> Html Msg
view model =
  div []
    [ button [ onClick Decrement ] [ text "-" ]
    , div [] [ text (toString model) ]
    , button [ onClick Increment ] [ text "+" ]
    ]

andreasklein09:08:44

I think it’s even more clear because of the sending arrow ->

andrea.crotti10:08:50

is there some function that converts HTML into the equivalent hiccup style definition?

andrea.crotti10:08:11

it seems mostly a mechanical process anyway so should be possible I guess

pesterhazy10:08:38

@andrea.crotti yes search for html2hiccup on Google, you'll find two or three online services

paul93122412:08:50

Hello, I want to ask how can I put @ in hiccup attributes? [:div {:[email protected] "icon"}] won't work because @ wants to deref (UIkit)

andreasklein12:08:41

But the obvious question is: Why are you doing this? What benefit do you expect?

paul93122412:08:08

What do you mean? It is needed for responsive behaviour.

andreasklein12:08:36

Ah ok your library/framework/something forces you to do this.

paul93122412:08:18

yes, UIkit needs it. Btw data-uk-column-1-5 works, escapes the camelcase. But [email protected] still doesn't work, wants to dereference 😕

andreasklein12:08:30

Even when you wrap it into a keyword?

paul93122412:08:52

yea, it works, thank you, very much appreciated

andreasklein12:08:00

Cool I just tried it in sablono and it doesn’t work, react tell’s me it’s an unknown prop. Glad to be able to help you.

paul93122412:08:39

well, you may need the framework to initialize these specific props, anyway it works now

qqq13:08:52

cljs numbers are js doubles. does cljs also have arbitrary precision integers ? (I think they're called 'bigints')

andrea.crotti13:08:48

I just found out about webjars (by looking at an example luminous project) https://www.webjars.org/

andrea.crotti13:08:31

how do they differ from packages on cljjs?

andrea.crotti13:08:56

maybe they are simply packaged css/js with 0 Clojure extra mapping?

mfikes14:08:14

@qqq There is no arbitrary-precision arithmetic capability in the core runtime. I haven't tried https://github.com/gfredericks/exact

mv14:08:05

Is there any issue in the cljs community in regards to the license that React operates under? I was looking for a similar library that implements Vue.js, purely for licensing reasons, but it doesn’t seem to exist

mfikes14:08:36

@mv I haven't seen a community-wide issue or stance. It seems to be up to individuals or companies take a decision.

mv14:08:38

@mfikes Yea, but if you are advocating cljs it seems like you are forced to lean into the worse licensing situation

mv14:08:00

Was hoping there was another option

dnolen14:08:04

@mv lots of people and companies are simply not concerned and never going to be

dnolen14:08:18

there’s just no need to take a stance

dnolen14:08:35

back to the your other point - not aware of Vue.js bindings - seems like somebody should work on that

mv14:08:50

@dnolen any ideas how that would best be implemented? Seems like an interesting project

dnolen14:08:04

no idea, I’m not familiar with Vue.js

sundarj14:08:13

might be easier to wrap Preact or Inferno, Vue is kind of complicated

dnolen14:08:28

part of the reason React got popular in ClojureScript is because it’s easy to write a functional wrapper for

dnolen14:08:51

prior to React most JS frameworks were mutable state funhouses

dnolen14:08:12

if Vue.js is amenable to FP patterns then it won’t be hard

dnolen14:08:18

if it isn’t then probably not worth it

mv14:08:35

Yea, this was all assuming it’s as much of a drop in replacement for React as I have heard

sundarj14:08:47

yeah it's not, it's a mutability haven

dnolen14:08:47

Preact is a dropin

mv14:08:08

Well, that explains that

dnolen14:08:18

oh yeah Inferno too as @sundarj said

nagarajan17:08:55

hi. I am facing some issues in using npm-deps feature in clojurescript "1.9.908"

dnolen17:08:50

@nagarajan there’s lot of known issues - describe your problem and someone can let you know if it’s been addressed

nagarajan17:08:00

For every react component I tried to install via npm, I get Uncaught ReferenceError: require is not defined in browser console

dnolen17:08:38

“every react component” is not useful information 🙂

dnolen17:08:47

just name one specific one that leads to that issue and someone can repro

dnolen17:08:01

it’s important to understand that different components are packaged differently

dnolen17:08:15

and there could be completely different issues for different packages

dnolen17:08:29

in general if you’re trying :npm-deps you are on the very bleeding edge 🙂

dnolen17:08:42

we are trying to address things as quickly as we find them though

nagarajan17:08:18

I tried react-player "0.20.0" and react-date-range "0.9.4". For both of these , I got the similar error

nagarajan17:08:55

But when I tried for lodash npm package, it worked fine

nagarajan17:08:16

Both of those components were appear to be es6 (atleast in github)

nagarajan18:08:56

:npm-deps {:react-date-range "0.3.0"} in the project.clj. after building, if I include react-date-range or "react-date-range" namespace, I get Uncaught ReferenceError: require is not defined error. I also get WARNING: JSC_JS_MODULE_LOAD_WARNING. Failed to load module "react" at ..../node_modules/react-date-range/lib/Calendar.js line 19 : 4 msg while compiling

anmonteiro18:08:47

@nagarajan looks like you’re not adding :react to your :npm-deps

nagarajan18:08:51

@anmonteiro I included :react "15.6.1" :react-dom "15.6.1" . Still same errors and warnings

anmonteiro19:08:06

@nagarajan so first problem. react-date-range 0.3.0 doesn’t exist in NPM

anmonteiro19:08:13

which version do you really want to use?

anmonteiro19:08:34

oh you said 0.9.4 above

nagarajan19:08:10

might have made the mistake while copying

nagarajan19:08:40

:react-date-range "0.9.4" is in profile.clj

anmonteiro19:08:00

what is profile.clj?

anmonteiro19:08:10

so it works for me with current master

anmonteiro19:08:22

trying with 1.9.908

nagarajan19:08:29

I am using lein as build tool.

anmonteiro19:08:49

works for me with 1.9.908 too

anmonteiro19:08:29

;; build.clj
(require '[cljs.build.api :as b])

(b/build "src"
  {:output-dir "out"
   :asset-path "/out"
   :output-to "out/main.js"
   :main 'foo.core
   :npm-deps {:react-date-range "0.9.4"
              :react "15.6.1"
              :react-dom "15.6.1"}
   :install-deps true
   :optimizations :none
   :verbose true})
;; foo/core.cljs
(ns foo.core
  (:require react
            react-dom
            react-date-range))

(enable-console-print!)

(println "hi" react-date-range)

anmonteiro19:08:56

and I’m running the above with java -cp cljs.jar:src clojure.main build.clj

anmonteiro19:08:13

hope that helps

nagarajan19:08:18

ok. I 'll try this directly. I am uploading my project.clj

anmonteiro19:08:58

sorry I’m not going to look at a lein thing

anmonteiro19:08:24

all I’m interested in is verifying all this works with the minimum amount of variables

anmonteiro19:08:37

which I did above

nagarajan19:08:57

ok. I understand.

nagarajan19:08:41

@anmonteiro Thanks for your help. I am gonna try directly like this and then try to incorporate some lighter build systems

anmonteiro19:08:06

@nagarajan let me know if it still doesn’t work

alexdong20:08:37

are there any way we can rewrite part of our js code in cljs and make it still available for the rest of the js code base?

alexdong20:08:32

for example, say we have a js file called 'catalogue.js' where we export its functions through export function get_product_attr(...)

alexdong20:08:51

and in the rest of the app, we do import * as Catalogue from "catalogue"

alexdong20:08:38

would be a fun rainy day exercise for me to rewrite catalogue.js in cljs without affecting the rest of the code base?

alexdong20:08:46

i.e. a gentle migration path

shzhng20:08:39

^i've been curious about this too - specifically if there's a way to compile up a cljs project and publish to npm for consumption by a JS project

shzhng20:08:01

i want to write a React component but using cljs/reagent - i want the end result to be a dev library to be consumed by a JS app, and not necessarily a standalone CLJS app compiled with optimizations

mfikes20:08:24

@alexdong See ^:export described here https://clojurescript.org/reference/advanced-compilation#access-from-javascript As long as the arguments and return values are simple enough (i.e. not persistent data structures), then JavaScript can easily call into your ClojureScript code.

mfikes20:08:31

This will make the code callable, hanging off of Closure "namespace" objects. It doesn't do anything with respect to the export, module system stuff you provide in your example.

mfikes20:08:10

You could have catalog.js preserve its API, but delegate to ^:export ed ClojureScript functions for implementation

alexdong21:08:32

super @mfikes I'll give it a whirl and report back.

lumpy21:08:15

having trouble calling external library that is loaded statically. getting error Uncaught TypeError: is not a function

lumpy21:08:50

seems like the minimization is changing (js/cxApi.chooseVariation) to (js/cxApi.ph)

mfikes21:08:06

@lumpy sounds like missing externs for :advanced

lumpy21:08:29

awesome, I will look into that

lumpy21:08:19

is there a good resource for these? I’m guessing cxApi has already been done?

mfikes21:08:54

http://cljsjs.github.io is a community effort for externs