Fork me on GitHub
#clojurescript
<
2017-02-03
>
superstructor00:02:27

With 1.9.456 it appears that if you have JavaScript files in foreign-libs that use functions like require() but are NOT any of the common module types, its not possible to upgrade without breaking the build with errors like “something.js is not a relative path”. Its an unusual case for that project as the module system is a proprietary one that pre-dates commonjs/es6 etc by many years, its one that is loading JS from LDAP.

superstructor00:02:01

I guess in other words I can’t find a way to turn off the new foreign libs module behaviour as with .293 this project built fine.

dnolen00:02:56

@superstructor I’ve been aware that something like that may happen - it would be super useful to put together something minimal and open a ticket

dnolen00:02:39

I’d like anything than used to work to at least be supported even if it means a flag of some kind

dnolen00:02:06

@superstructor also this issue should really only be a problem for dev

dnolen00:02:35

the way the we bootstrap the Node.js environment for hot-loading and global require to preserve Closure semantics is highly unusual

dnolen00:02:08

if you create a single file all these problems of course just dissappear

superstructor00:02:22

ok thanks @dnolen, yeah its an unusual case as its not targeting Node.js. Its running inside SpiderMonkey threads within a C++ server, and that environment provides require() to load JavaScript from LDAP servers. The problem I guess is that it is now attempting to interpret require() in foreign-libs as meaningful at dev time, when in this case it is only meaningful at runtime ?

dnolen00:02:57

@superstructor hrm then the problem is not what I think

dnolen00:02:16

nothing should have changed about foreign libs as far as you are concerned

dnolen00:02:45

if you’re not using :target :nodejs there should not be any problem

bpicolo00:02:04

Has anybody toyed with 'eval'? I'm having trouble getting to work properly outside of figwheel

bpicolo00:02:14

that is, compiled context (including optimizations :none)

superstructor00:02:23

does not appear to be using :target :nodejs, it is using the default which is browsers according to docs @dnolen

dnolen00:02:51

@superstructor then there shouldn't be a problem

superstructor00:02:52

later I’ll try to cut it down to a minimal example, and raise a ticket? @dnolen

dnolen00:02:21

@bpicolo if you mean ClojureScript eval not possible

superstructor00:02:23

ok thanks 🙂

dnolen00:02:08

@bpicolo unless you use bootstrapped ClojureScript I mean of course

bpicolo00:02:31

@dnolen what do you mean?

dnolen00:02:50

bootstrapped ClojureScript supports eval

dnolen00:02:54

normal ClojureScript does not

bpicolo00:02:04

I'm not familiar with "bootstrapped clojurescript"

dnolen00:02:26

@bpicolo ClojureScript doesn’t include the compiler normally that’s why you can’t eval

dnolen00:02:35

if you need eval look at the cljs.js namespace

bpicolo00:02:38

Well, I can eval, so I'm apparently using bootstrapped clojurescript

bpicolo00:02:42

Yeah, cljs.js

bpicolo00:02:53

It just doesn't work quite the same outside of figwheel errr

bpicolo00:02:59

(fwiw, I wrap these all in (let [] ) behind the scenes

bpicolo00:02:27

because eval seems to only toss out the result of the first statement

bpicolo00:02:25

hmmm, maybe this isn't running optimizationless

dnolen01:02:20

I don’t have much time right now to look into this - but a quick look at that url doesn’t show a main entry point file

bpicolo01:02:31

not sure what you mean

dnolen01:02:32

it appears you’ve pushed non-optimized stuff

bpicolo01:02:49

it breaks much worse with advanced optimizations

dnolen01:02:58

you can’t used advanced optimizations

dnolen01:02:13

anyways, sorry can’t debug this right now with you

bpicolo01:02:29

so eval should fully work under simple optimiations?

bpicolo01:02:34

via cljs.js?

bpicolo01:02:56

alright, haven't tried that, have only tried whitespace and none

anmonteiro01:02:25

@bpicolo I might know what's wrong by looking at the example

anmonteiro01:02:57

did you (set! (. js/cljs -user) #js {}) somehwere?

bpicolo01:02:07

errr, not me personally

anmonteiro01:02:19

you may need to create that object

bpicolo01:02:29

Mind describing why?

bpicolo01:02:34

trying now though

bpicolo01:02:48

I figured it just doesn't know where to define bits but had no idea what that would mean 🙂

anmonteiro01:02:36

namespaces in Google Closure are reified as JS objects

bpicolo01:02:08

That doesn't seem to have changed it : (

anmonteiro01:02:09

and you need to create the cljs.user namespace upon starting

anmonteiro01:02:08

@bpicolo I just evaluated cljs.user = {} at Chrome devtools and the examples started working

bpicolo01:02:11

let me try a full recompile

bpicolo01:02:20

that's interesting

anmonteiro01:02:28

so that'll solve your issue

bpicolo01:02:34

You're right

anmonteiro01:02:35

check that builds are not cached etc.

bpicolo01:02:37

that's totally true

bpicolo01:02:53

anmonteiro Out of curiosity, how would I have gone about debugging that?

bpicolo01:02:01

pretty hard to follow cljs internals in the browser hah

anmonteiro01:02:04

I don't know 🙂

anmonteiro01:02:21

I just had the same problem before and remembered it

bpicolo01:02:39

Yeah, that's awesome, thanks. Being able to host a presentation so people can follow along and toy with examples seems well

bpicolo01:02:41

super dope

dnolen01:02:49

doing stuff with bootstrapped is still considered advanced - we should probably put together a guide to suss out stuff like this

dnolen01:02:02

it’s just hard to prioritize since there’s generally way more important stuff to work

bpicolo01:02:20

I'm not judging, glad this works at all hah

bpicolo01:02:37

I too have spent too much of my life wrestling the closure compiler

bpicolo01:02:50

It really does not enjoy making sourcemaps

bpicolo01:02:39

@anmonteiro @dnolen ^^ that made it compile perfectly under :simple

bpicolo01:02:47

Thanks a ton

vikeri08:02:42

A question about performance, is it true in clojurescript as well that protocols are faster than multimethods?

miikka09:02:32

vikeri: Looking at the generated code, I suppose protocols are faster, although I have no idea of how much.

miikka09:02:51

If you're concerned about the performance, you should probably benchmark it yourself.

val_waeselynck11:02:07

protocols are backed by JavaScript's native inheritance mechanism, so you can expect it to be well optimized by JS engines. ClojureScript's standard library is implemented with protocols at the bottom, so you can expect them to be fast 🙂

dnolen12:02:21

@vikeri much faster than multimethods, only slightly slower than a simple function

2812:02:08

I've attached a patch for CLJS-1868, can someone check it to see if it is ok.

2812:02:53

Should I maybe assign it to someone?

dnolen13:02:02

@28 #cljs-dev is the right place to talk about ticket/patches

2813:02:12

@dnolen Oh, okay, I will ask there.

2813:02:45

Thanks.

futuro13:02:54

I wrote an architectural overview of the nREPL, and I'd be chuffed as nuts if you read it. “If you give a mouse an nREPL” https://medium.com/@eniessenderry/if-you-give-a-mouse-an-nrepl-8f309faa6bc3

tankthinks14:02:28

then he'll ask for a glass of cider?

jondale15:02:24

Wondering if someone can help with the following...

;; Foo namespace
(ns app.foo)
(defn a [])
(defn b [])


;; Bar namespace
(ns app.bar
  (:require [app.foo :as foo]))

(def my-func-name "a")

;; How do you call the function a in the foo namespace
;; from a string or keyword. E.g. foo/a

;; Doesn't work
(foo/my-func-name)

jondale15:02:44

I’m trying to call a function in a different namespace constructed dynamically

Aron15:02:09

what's the fastest way to loop over a list and mutate its elements?

anmonteiro15:02:33

@ashnur lists in Clojure(Script) are immutable, they can't be mutated

Aron15:02:17

list as a list of items not list the datastructure, sorry

anmonteiro15:02:47

Do you mean a JavaScript array?

Aron15:02:43

no, i mean the abstract concept of grouping things together such that same element can be included multiple times and the group's elements have a well defined order relative to each other. the english meaning of the word list.

anmonteiro15:02:47

I don't understand what you want. We're back to my first point. You can't mutate things in CLJS

anmonteiro15:02:07

what you can do it apply a transformation to some or all elements of a list

anmonteiro15:02:23

Returning a new list

Aron15:02:49

look, if you don't understand, why you think repeating stuff we established is irrelevant will help me ? 🙂

bronsa16:02:52

ashnur: I don't want to speak for @anmonteiro here, but this wasn't exactly a respectful answer to somebody who's trying to help. Especially given that I suspect everyone here would've told you exactly the same thing

Aron16:02:15

I don't mean no disrespect, I was curious if they see something I didn't.

joost-diepenmaat15:02:19

ashnur what do you expect to happen when you mutate these things?

joost-diepenmaat15:02:33

doseq should work provided the things are mutable

joost-diepenmaat15:02:09

(doseq [item [thing1 thing2]] (some-mutating-call item))

moxaj15:02:26

@ashnur you won't find the list 'concept' in cljs, or anywhere else, there are implementations, like clojurescript lists, or javascript arrays

Aron15:02:42

well, more than one thing has to read it, it's in the higher scope.

Aron15:02:03

but i will try now the naive way and see how slow or fast is just using seq

Aron15:02:29

i think ultimately i will have to do some ugly stuff to reach this kind of performance though https://bl.ocks.org/ashnur/910a4fdc3556a32f435f248c04108c8f

joost-diepenmaat15:02:32

generally, just looping over a bunch of things is not the bottleneck.

Aron15:02:06

yeah, that's why i will check it first, now that i see it's not as straightforward as i hoped

Aron15:02:48

will try to not optimize before i have to

joshkh16:02:08

any idea why upper-case would get mangled during advanced compilation? they're functions known to clojure:

(:require [clojure.string :refer [join split upper-case]])

(defn uncamel [s]
  (join (update 0 (split (join " " (split s #"(?=[A-Z][^A-Z])")) "") upper-case)))
Uncaught TypeError: Cannot read property 'toUpperCase' of null

joshkh16:02:31

join and split don't have the same problem

bronsa16:02:28

@joshkh that's saying you're invoking upper-case on nil

bronsa16:02:37

upper-case defers to toUpperCase

joshkh16:02:26

uhg, that's totally right, i merged two errors together in my head. thanks for the reality check.

Aron16:02:05

so, actually, what i have to do is to give d3 a javascript array that it can mutate

Aron16:02:26

and i have to loop over it and read it, but not mutate it myself

joshkh16:02:59

are you trying to loop over javascript objects and mutate them?

Aron16:02:51

no. i am trying to create a javascript array that i can give to d3 so d3 will mutate it and then i will read the new values

joshkh16:02:05

okay, for the sake of argument (just trying to understand what you mean), can you give an example array and an example d3 function?

Aron16:02:28

"for the sake of argument". i love how only i am called out on being "disrespectful", yet every time I ask for help someone wants to ARGUE

Aron16:02:33

i don't want to argue

Aron16:02:49

this is what you asked (i hope)

joshkh16:02:54

hey! sheesh, it's just a saying

Aron16:02:02

yeah, that's also very "respectful", talking to me like i am child

joshkh16:02:42

alright buddy. was only trying to help. nevermind!

samueldev16:02:57

does anybody see anything immediately wrong with this cljsbuild profile & my directory structure?

samueldev16:02:26

& my entrypoint file is @ src/cxengage/sdk.cljs

Aron16:02:14

joshkh and who stopped you? 😛

Aron16:02:38

you asked something, i tried to give the best answer i could

joshkh16:02:16

ooookay. well, i'm not totally sure who/what conversation you were having before or what got you riled up, but maybe this will help show how d3 and clojurescript can work together: http://blog.getliquidlandscape.com/2015/01/08/practical-time-series-visualization-using-d3-om/

Aron16:02:44

joshkh that looks like using svg, i am using canvas

Aron16:02:07

svg can not give the required performance

Aron16:02:04

i am doing a clj->js now, seems to be working, will see later how fast it is

joshkh16:02:07

i don't think svg vs canvas matters, it's more of a cljs/js interop question

Aron16:02:24

well, i am sorry to tell you that in this respect you are very wrong.

Aron16:02:40

unless you are using firefox of course, because on firefox both are very slow

Aron16:02:30

but in IE, Edge and the webkit browsers canvas is at least a hundred times faster and that's not an exaggeration, you can join the d3 community and ask them too

joshkh16:02:26

yes, you're absolutely right that canvas is faster than svg! i meant your question about using d3 with cljs, that's all.

joshkh16:02:33

anyway, good luck

samueldev16:02:17

RE my above question around my cljsbuild:

samueldev16:02:23

the output of my compilation is

samueldev16:02:58

ClojureScript could not load :main, did you forget to specify :asset-path?

samueldev16:02:34

so it seems like it can't find my :main file but it's in the correct location (if I'm understanding the structure correctly)

henriklundahl16:02:36

@jondale Try (@(resolve (symbol "foo" my-func-name))).

jondale16:02:41

@henriklundahl Thanks, will try that

samueldev16:02:44

I think I misread that: I guess it can't find the google closure compiler?

dnolen16:02:08

@samueldev yes it can’t load goog/base.js

dnolen16:02:40

note the url - not sure how loading stuff from the file system works for Explorer on Windows

samueldev16:02:34

my last-48-hours switch to windows

samueldev16:02:41

thought that might have something to do with it ><

dnolen17:02:38

@samueldev seems like you need setup a webserver and specify :asset-path

deas17:02:58

Short question: If I want to leverage node modules on the web, I'll am likely stuck with webpack for the time beeing, right? In a cljs app that is.

dnolen17:02:18

@deas unless you want to live on the cutting edge, yes 🙂

deas17:02:23

@dnolen Cutting edge is fine with me. Got a rough vision how to get node modules working on the web?

joshkh17:02:05

regarding the recent clojurescript version announcement, is there anything that can be leveraged to facilitate asynchronous module loading?

dnolen17:02:33

@joshkh async module loading has always been possible via Google Closure

dnolen17:02:46

nothing about the new announcement has any effect on that

dnolen17:02:08

but note by “module” here Google Closure means code splitting - not loading an individual namespace

joshkh17:02:37

right, so it's how the shared code is split up?

dnolen17:02:55

yes and you can async load the splits

joshkh17:02:31

the last time i tried react threw a tantrum. i'll have to take another crack at it. thanks. 🙂

deas17:02:02

@dnolen On the web the "Node Modules" approach outlined ends up failing due to process undefined. 🙂

dnolen17:02:22

@deas this is what mean you are living on the cutting edge

dnolen17:02:49

fixing that stuff isn’t hard if you're willing to hack a bit

dnolen17:02:24

there are also deeper problems not so easily fixed like Google Closure’s handling of the hoisting semantics

deas17:02:25

@dnolen All fine. Was just asking if somebody has a clue where to go from there. 🙂

dnolen17:02:38

just polyfill process yourself

dnolen17:02:53

React doesn’t really do anything with it in the browser

deas17:02:13

@dnolen Thanks, that was the answer I was looking for. 🙂

dnolen17:02:21

var process = {env: “production”};

dnolen17:02:33

or make a process ns with a env goog-define and set it in your compiler build settings

currentoor19:02:34

How do I request my company be added to this list? https://clojurescript.org/community/companies We’ve been using CLJS and Om Next very happily for some time now.

currentoor19:02:30

Oh on the Clojure site it says > Below is a partial list of some companies using Clojure or ClojureScript. Most of this information comes from direct contacts, presentations, or other online resources. If you would like to be added or removed from this list, please contact <mailto:[email protected]|[email protected]>.

currentoor19:02:48

Maybe that should be on the Clojurescript site also?

anmonteiro19:02:19

@currentoor you can probably submit a PR to the clojurescript-site repo

naomarik20:02:46

how can I elide certain deps for prod compiles like loggers, devtools or whatever else I want?

naomarik20:02:58

perfect exactly what i needed

spinningtopsofdoom20:02:59

You make separate namespaces for you development files e.g. dev.logger or dev.tools and then load them into the development build via :preloads '[dev.logger dev.tools]

shader21:02:00

Are there any good libraries for generating and displaying QR codes with clojurescript? Or recommended js libraries that I could create bindings for?