Fork me on GitHub
#clojurescript
<
2017-02-20
>
michaelstalker00:02:42

I've been using ES6 and Babel on a project for a few months now, and I like fetch's syntax. That may not be a good enough reason to use fetch and a polyfill, though.

thheller00:02:14

you can use Babel as sort of a companion to CLJS

michaelstalker00:02:14

I'm starting to wonder if I'm approaching this the wrong way. fetch isn't the only ES6 feature that's not universally supported, but that I've gotten accustomed to using.

thheller00:02:10

compile your es6 related things to a lib.js and include that in your page manually or via :foreign-libs

michaelstalker01:02:42

I think I've been treating CLJS as a really thin wrapper around JS, rather than as a language in its own right.

michaelstalker01:02:12

I should probably start looking for more ways to do things that are idiomatic to CLJS.

danielstockton14:02:27

michaelstalker: https://github.com/r0man/cljs-http is a good library that can also handle serialization/deserialization into the format of your choice.

michaelstalker20:02:52

Thanks so much! I'll check it out.

michaelstalker20:02:22

I'll do some reading on core.async, as well.

tbaldridge01:02:22

That's what I would recommend, if the syntax of fetch is nicer to you, wrap up XhrIo to make it look like fetch.

qqq09:02:38

is latest stable of core.match still 0.3.0-alpha4 ?

borkdude11:02:07

I upgraded React Virtualized to 9.0.0-rc.0 in cljsjs (locally) and I get: https://www.dropbox.com/s/ovgbpj1x368yhfd/Screenshot%202017-02-20%2012.51.37.png?dl=0

borkdude11:02:37

already when loading this library

borkdude12:02:47

Super expression must either be null or a function, not undefined

pleasetrythisathome13:02:04

i think i’m seeing a regression in the way the cljs compiler produces paths for sources in source maps starting at version 1.9.198

pleasetrythisathome13:02:56

in version 1.9.89, sources are relative to the map file, and in 1.9.198, they are relative to output-to directory

pleasetrythisathome13:02:41

but they are still relative paths, not absolute, so they’re loaded by the browser with a doubled relative path since they’re being loaded from the relative path of the .js file in the same dir as the .js.map

pleasetrythisathome13:02:52

for example, if i have (ns sourcemap.demo) in src/sourcemap/demo.cljs, i’ll see target/main.out/sourcemap/demo.js and target/main.out/sourcemap/demo.js.map

darwin13:02:15

@pleasetrythisathome have you tried to play with :source-map-asset-path and :source-map-path compiler options?

pleasetrythisathome13:02:43

in 1.9.89, demo.js.map has ”sources”: [”demo.cljs"]

pleasetrythisathome13:02:52

in 1.9.198, demo.js.map has ”sources”: [”main.out\/sourcemap\/demo.cljs"]

pleasetrythisathome13:02:03

yes, :asset-path works as i expect, but :source-map-path and :source-map-asset-path seems to be ignored by both versions

pleasetrythisathome13:02:22

in 1.9.198, if you log something from the cljs file, you’ll see the correct line number mapped in the console, but the path to the source will be doubled as /main.out/sourcemap/main.out/sourcemap/demo.cljc

lwhorton13:02:29

with clojure.spec, is there a way to define a more “human-readable” spec for nested maps?

(s/def ::my-domain-entity (s/keys :req-un [:a :b])
(s/def :a (s/keys :req-un [:c :d]))
(s/def :b boolean?)
(s/def :c number?)
(s/def :d string?)
My complaint is that it becomes hard(er) to read a spec if it has any sort of nested maps or any deep structure… because you are chasing keys up and down a file and they aren’t “in place” declarations. Rather than something like schema which would allow
(m/defschema my-domain-entity {:a {:c sc/number :d sc/string} :b sc/bool}}

darwin13:02:48

looking at the blame view, looks like david touched the relevant code about 8 months ago: https://github.com/clojure/clojurescript/blame/master/src/main/clojure/cljs/compiler.cljc#L1225-L1250

pleasetrythisathome13:02:54

which would be at that commit

pleasetrythisathome13:02:10

ok, let me see if i can fix the issue with :source-map-asset-path in the newer versions

pleasetrythisathome13:02:27

has everyone else’s source maps not broken?

pleasetrythisathome13:02:29

commit also claims to fix :source-map-path support under optimizations none

darwin13:02:36

by reading it you should be able to figure out what is going wrong in your case, it looks to me that you have to make sure :source-map-asset-path is not set and :source-map-url is also not set, then you trigger the code path which will produce relative names to generated cljs files not :output-dir

darwin13:02:36

where (:source-map-url opts) is nil

darwin13:02:51

opts being compiler options

pleasetrythisathome13:02:56

hmm ok let me play around

darwin13:02:36

please try that at home 🙂

pleasetrythisathome14:02:44

:source-map-path was broken, and boot-cljs had been passing :source-map-path incorrrectly for the apparently intended behavior

pleasetrythisathome14:02:44

should be the absolute :output-dir, not relative, currently “main.out"

pleasetrythisathome14:02:56

should be “/main.out” in the standard case

risto14:02:54

is there some way to write specs for a protocol?

risto14:02:21

something like:

(defprotocol Foo []
  Bar
  (s/fdef bar ...)
  (bar [this x] ...))

danielstockton14:02:08

@risto (bar [this x] (-bar this x)) is the usual convention and then spec -bar.

danielstockton14:02:39

This issue suggests the other way, wrapping the protocol fn with a global one and spec-ing that. I find other advantages to this pattern. For example, I usually can't add breakpoints with the Cider debugger in protocol methods, I get 'method too large'.

danielstockton14:02:05

Actually, that isn't much help seeing as we're in #clojurescript

risto14:02:29

thanks, that makes sense

risto14:02:44

btw what's does the convention mean with the - prefix? ie -bar?

risto14:02:53

does it mean it's internal and therefore don't mess with it?

danielstockton14:02:11

risto: You would usually do that with (defn- which defines a private method (adds a tag to the metadata).

risto15:02:52

ah thanks

danielstockton14:02:30

No special meaning afaik. It's just a convention, probably made popular because Clojurescript uses it for built-in protocols.

danielstockton14:02:52

Generally, I use it in cases like this where I can't think of a good name for the inner function that is different from the wrapper.

amy_lowe14:02:37

Has anyone used compassus as a routing library with om-next? I'm wondering how to set query parameters when setting the route. Can anyone help?

dnolen15:02:31

@amy_lowe might want to ask in #om

thegeez15:02:33

@dnolen I'd like to add http://crepl.thegeez.net to https://github.com/clojure/clojurescript/wiki/Bootstrapping-the-Compiler Can I edit the wiki myself or do I need to make a PR somewhere?

jtkdvlp15:02:34

Hi there, I got a cljsbuild error using compiler modules. See https://github.com/bhauman/lein-figwheel/issues/527#issuecomment-280915218 Hope you can help me 🙂

dnolen15:02:03

@thegeez we should probably be updating the main website at this point not the wiki

thegeez15:02:48

ok, I'll make a pr to the main website

qqq21:02:57

I have foo.edn, which I want src/g/bar.cljs to read in at compile time, not run time -- is there a easy way to do this?

dnolen21:02:42

@qqq you can splice the contents of that file into your code by writing a macro do that

risto23:02:16

I'm not sure what I'm doing wrong here

risto23:02:39

I'm trying to get my function spec working, but it doesn't check the return value:

(s/fdef hello
   :args (s/cat :name string?)
   :ret string?)
(defn hello [name]
  ;(str "Hello, " name)
  (+ 1 2)
  )

(stest/instrument [`foob `fooob `hello])

risto23:02:57

it's returning an integer, but it should be a string

risto23:02:00

but it's not complaining

risto23:02:11

I'm running clojurescript version [org.clojure/clojurescript "1.9.229"]

risto23:02:32

is it because stest/instrument only checks the function arguments?

risto23:02:18

answered my own question, lol

risto23:02:22

"Instrumentation validates that the :args spec is being invoked on instrumented functions and thus provides validation for external uses of a function"

risto23:02:02

"Note that the :ret and :fn specs are not checked with instrumentation as validating the implementation should occur at testing time."

risto23:02:24

makes sense

qqq23:02:09

read-string only seems to read the first sexp

qqq23:02:14

is there something which reads all sexps from a string?

dergutemoritz23:02:32

@qqq Pragmatic solution: (read-string (str "(" x ")"))