Fork me on GitHub
#clojurescript
<
2018-10-24
>
fabrao00:10:53

Hello all, I´m trying to use clojure.string/upper-case and I´m getting this s.toUpperCase is not a function

fabrao00:10:29

is there any change in clojurescript?

Dormo00:10:26

There shouldn't be

Dormo00:10:29

"foo".toUpperCase() is valid JS

frenata00:10:38

@fabrao

$ planck
ClojureScript 1.10.339
cljs.user=> (clojure.string/upper-case "foo")
"FOO"
I get that error with non-strings fed to the function though.

fabrao00:10:08

Oh. Can be the case

attentive00:10:46

Is cljs.reader/read-string still the accepted way to read EDN data in cljs-land?

mfikes01:10:42

I think the cool kids are now using cljs.tools.reader/read-string

andy.fingerhut01:10:56

Does cljs have a separate 'safer' EDN reader the way Clojure/Java does? Sorry I'm only echoing your question with slightly more detail. Clojure/Java has a code-reader that can do arbitrary side effects, and a safe EDN reader that cannot.

andy.fingerhut01:10:34

If tools.reader has a cljs version in a namespace with edn as part of the name, I would recommend that one if you don't need something more powerful.

mfikes01:10:21

Yeah, there is indeed a cljs.tools.reader.edn/read-string

mfikes01:10:18

And, as Andy recommends, the docstring for cljs.tools.reader/read-string includes the sentence:

To read data structures only, use clojure.tools.reader.edn/read-string
(Writing a quick JIRA to have the proper namespace in that docstring.)

richiardiandrea02:10:29

Is there an alternative to Throwable->map in ClojureScript?

mfikes03:10:02

@richiardiandrea perhaps cljs.stacktrace/parse-stacktrace or other fns in that namespace might be useful

richiardiandrea03:10:07

Do you think it should be added for feature parity with Clojure?

thheller09:10:05

No. JS exceptions are not standardized so every browser has a different format.

thheller09:10:21

also JS exceptions need to be source mapped to be useful.

richiardiandrea14:10:57

The statk trace is custom but maybe message and stack trace string could go in a map

awb9903:10:11

I am trying to use Material-UI within Reagent. I found cljsjs/material-ui which seems to be the most recently updated library, but I cannot find any example. Is anyone using Material-UI in reagent apps?

pradyumna09:10:01

hi, anyone knows about the :global-exports option. I have added [cljsjs/react "16.4.1-0"] to project.clj and tried the below code. But it throws error that cljsjs.react/createElement var not defined. I checked in the jar file in m2. It had a deps.clj which has the proper declarations for :foreign-libs including :global-exports. Am I missing something?

thheller09:10:23

@pradyumna not sure but I think you must use react instead of cljsjs.react in the require

pradyumna09:10:57

thanks, i'll try that

pradyumna10:10:18

yes, it worked, a bit strange though..

pradyumna09:10:16

@hoertlehner an example of MaterialUI. basically, you need to adapt the component classes like Input, Button. then you can pass the almost most property by specifying simply in the map. Just careful with special values type Object, there you should pass a js-object not a clojure map.

witek09:10:19

Hi. Inspired by Stuart Halloway's latest talk, I have released a live coding tool I have used for some while in my hobby projects. https://github.com/witek/bindscript

witek09:10:25

Now I would like to leave my "bindscripts" in my source files. But disable them in production. Since def-bindscript is a macro, it should be possible to emit nothing for production. But how does the macro check, if it is a production build? Thanks for a hint!

dnolen09:10:26

in general macros based on compiler options is very discouraged

dnolen09:10:42

it breaks caching (faster builds)

dnolen09:10:47

the better way is to put them behind a Google Closure define - then you can use that same code for dev / prod builds and Closure can DCE that stuff based on some flag of your choosing

🙏 4
dangercoder11:10:30

How good is Figwheels hot reload compared to JS https://webpack.js.org/concepts/hot-module-replacement/? I didn't really find any good posts on the internet..

lukas.rychtecky12:10:04

Probably as good as you don’t need to you anything from JS to do FE development in ClojureScript.

dangercoder12:10:41

I read a post that said that it existed in CLJS before JS.

lukas.rychtecky12:10:59

That’s possible, I didn’t read it.

artur13:10:34

Works like a charm for me out of the box

surendran12:10:32

I am including npm-library in clojurescript.

surendran12:10:32

:npm-deps {:intro.js "2.0.0"} :install-deps true

surendran12:10:19

after including this when I try to run 'lein doo phantom test', our tests are failing with "ReferenceError: Can't find variable: module"

mfikes12:10:44

@dsuren :npm-deps should be considered an experimental / advanced feature, which requires expertise and a decent amount of effort to sort through problems

mfikes12:10:23

In other words, if you're up for it, I would recommend start digging through where the train left the tracks

surendran12:10:04

@mfikes sure I can look into. please let me know where to start

mfikes12:10:53

For something like this I'd try to find the code in the output directory that seems to be defining module

mfikes12:10:31

An alternative is to not use :npm-deps and use something like https://clojurescript.org/guides/webpack

surendran12:10:03

sure... I was searching all over in src code. never thought of looking into output folder 😛

mfikes12:10:05

Yeah, you will see that Google Closure rewrites stuff and then the rewritten code is loaded. Sometimes the issue is in Closure, sometimes it is something that can be tweaked in the library, and sometimes it is a defect in ClojureScript.

dnolen13:10:01

@coderdanger CLJS is probably better in the hot-reloading department, largely due to the Lispy-ness of Clojure

dnolen13:10:43

@dsuren also a good question is whether what you have already assessed the webpack support

polymeris13:10:37

I am trying NPM dependencies (`:npm-deps`/`:install-deps`), but the deps are only downloaded when I cljsbuild, not on lein deps. Is there any way I can force the dependencies to be downloaded?

4
polymeris13:10:13

Only solution I have found is to have a dummy "download-deps" cljsbuild id

surendran13:10:54

@dnolen not yet, I will look into webpack support

dnolen13:10:11

it's much simpler and there's far fewer complications

dnolen13:10:42

so much less likely to get stuck on something that even a ClojureScript compiler dev can't explain quickly

gklijs16:10:51

Has somebody tried out using web assembly with clojurescript yet? Webpack 4 supports it, but not sure it would be the easiest way.

gklijs05:10:28

Interesting

Braden Shepherdson16:10:40

it feels more like ClojureWASM is another top-level target, like ClojureCLR, with only a passing relationship to the ClojureScript world.

Braden Shepherdson16:10:49

maybe borrowing some of the JS interop syntax.

shaunlebron17:10:58

@gklijs you can interface with wasm modules with the usual js interop in cljs

gklijs17:10:53

@shaunlebron but how to load them, npm-deps or shadow-cljs? Maybe it's simpler, I did some js interop with cljs, but not with libraries.

shaunlebron17:10:38

@gklijs just looked into how to load them in js, and it’s a bit of a mess right now with manual compilation of each .wasm file when loading

shaunlebron17:10:04

but it looks like they’re planning to make loading wasm modules as easy as loading ecmascript modules, via <script type="module" src="foo.wasm"> or import "./foo.wasm"

shaunlebron17:10:56

my guess is that shadow-cljs might add a custom loader if you ask for one

shaunlebron17:10:33

but cljs core will probably wait for google closure compiler to do it (probably after the linked proposal is settled)

shaunlebron17:10:38

in the meantime—you’ll have to load them manually yourself: https://webassembly.org/getting-started/js-api/

gklijs17:10:38

Doing it like that would be great. I will try out shadow-cljs soon. Even with webpack it's not all working great yet, even with just typescript and a wasm module I could not get a production build working easily.

reset22:10:54

Any chance anyone here has an example of a functioning ClojureScript/Electron/Figwheel-Main application? I've run up to a block where exposing electron to the global context (`window.Electron = Electron;`) doesn't work for the main electron process since window isn't available

reset19:10:26

Thanks for the link!

reset19:10:32

Especially interested in the Rust integration bit work you're doing here. I'm a Rust developer coming into Clojure since this last July

pat19:10:27

👍 that was tons of fun to write