Fork me on GitHub
#clojurescript
<
2016-04-09
>
darwin01:04:58

(clj->js args) should not be needed if you use cljs-devtools: https://github.com/binaryage/cljs-devtools

george.w.singer05:04:15

Does anybody know how to get static typechecking into ClojureScript? Typed clojure doesn't work with CLJS. I found a dialect of lisp called Shen which transpiles to JS but is evidently horrendously slow. You can interop with Haskell from CLJS via GHCJS or Haste (which I'm experimenting with now). I was curious if anyone here had tried anything else.

borkdude08:04:39

@george.w.singer: you probably already know Schema, which is runtime schema validation

borkdude08:04:25

@george.w.singer: do you want to embed a statically typed piece of JS into cljs?

george.w.singer09:04:55

I am familiar with it, yes; however, I was under the impression that it couldn't catch pre-compilation errors, and -- in addition -- adds a performance hit to your program since it runs at run-time

george.w.singer09:04:27

But perhaps the performance hit shouldn't worry me; and maybe it could be good enough?

borkdude10:04:42

@george.w.singer: it's either run time checks or a type system (core.typed)

darwin10:04:52

@george.w.singer: you could also look into Google Closure Compiler annotations, it is usable, but must be done on javascript level, so you have to know how cljs compiler emits stuff.

borkdude10:04:14

@george.w.singer: you can however disable the checks in production if performance worries you

darwin10:04:04

I have a project in mind, which would provide a clojurescript-ish DSL which would emit closure externs annotations

darwin10:04:15

it is gradual type checking, you don’t have to use it everywhere, where you do Closure Compiler then gives you additional feedback and error checking

george.w.singer10:04:00

@borkdude: core.typed doesn't work with clojurescript AFAIK

george.w.singer10:04:47

@darwin: thanks for the GCC suggestion. It's a deal breaker for my use case if I have to annotate at the JS level.

anmonteiro12:04:54

@george.w.singer: there's also PureScript if you are looking for non-CLJS alternatives

reefersleep12:04:10

@octo221: a bit late here simple_smile But no, I don't think Reagent updates derived atoms. If you want global undo with Reagent, I think the simplest (and possibly only really viable) solution is to use one global atom. Re-frame ( https://github.com/Day8/re-frame ) is a pattern that makes the concept of a single r/atom more elegant, I think, though I haven't had the chance to use it yet. But depending on the size of your application, you may get by with just "vanilla" Reagent simple_smile

anmonteiro12:04:32

Smaller than GHCJS, and also a subset of Haskell

bpicolo15:04:25

Hi friends, I'm adding an :optimizations advanced build script to my project. Most things seem normalish but...the compiled code includes comments

bpicolo15:04:31

which are the most obvious thing the be stripped

bpicolo15:04:41

So I have to imagine my build isn't...complete

borkdude15:04:06

@george.w.singer: I've also seen people be enthusiastic about ScalaJS, but if you're not using Scala already, then I'd go for something else

bpicolo15:04:20

it's also 436k for what I believe is still a pretty small project, which seems high (but might not be)

borkdude15:04:45

@bpicolo: a gist of your project.clj?

bpicolo15:04:42

that's the build / what I don't expect in the source heh

bpicolo15:04:37

then again, if it weren't doing DCE, this file would probably be 50x as big

bpicolo15:04:26

That's really bizarre

borkdude15:04:13

@bpicolo: when I'm running it through Optimus the comments get stripped away

bpicolo15:04:20

On another note: I'm using lein-figwheel for dev reloading and such. It seems when I set a trace on the frontend, I can't actually execute code in the repl during the breakpoint

bpicolo15:04:34

is there a way to exec during breakpoint

bpicolo15:04:42

@borkdude: link to optimus?

bpicolo15:04:57

ah found it

dm315:04:06

IIRC, GCC doesn't run optimizations on your foreign libs

dm315:04:22

code has to be written in a certain way to be optimized

bpicolo15:04:30

dm3 it did do optimizations on react there though

borkdude15:04:30

@bpicolo: ah, it's a setting in google closure

borkdude15:04:41

@bpicolo: because it is a LICENSE comment

dm315:04:48

which ones?

bpicolo15:04:06

dm3 all, advanced

bpicolo15:04:10

someone wrote an externs file for it

bpicolo15:04:19

@borkdude interesting, what's the setting?

bpicolo15:04:36

Guess it doesn't matter if I run optimus though

bpicolo15:04:27

> adds cache-busters to your static asset URLs

bpicolo15:04:48

ahh that won't work for me perhaps

bpicolo15:04:52

I am backend python

dm315:04:51

externs just make sure the references to the library don't get mangled under advanced optimization

bpicolo15:04:04

dm3 Right, the goal being that you can advanced optimize them

dm315:04:24

yep, so I still don't think GCC touches React code, no?

bpicolo15:04:31

oh you know what

bpicolo15:04:33

this might just be

bpicolo15:04:38

react minified on it's own

borkdude15:04:48

@bpicolo: optimus has an option to output static files

bpicolo15:04:49

not that a externs file wouldn't let you compile it

borkdude15:04:58

@bpicolo: but you might as well use another uglifyer

bpicolo15:04:14

@borkdude: I mean, I need -something- to hash my assets and dump them to s3 at some point

dm315:04:17

if you're using React bundled in cljsjs/react

dm315:04:23

then it's already minified

bpicolo15:04:28

That makes sense then

bpicolo15:04:17

hmm, I'm going to have to compile asset paths into my frontend too

bpicolo15:04:12

cache busting not quite as important for image assets I suppose

bpicolo15:04:08

> CSS files that reference images are rewritten so that they point to cache busting URLs.

bpicolo15:04:16

@borkdude++ optimus seems great

bpicolo15:04:27

I'm sure I can get it doing something without needing the backend

darwin16:04:11

@bpicolo: some libraries can have comments with special annotation @license which prevents their removal, those licenses should stay there, not sure if it is the case of your build, but react license should stay there

bpicolo16:04:25

Perhaps, pretty marginal though

darwin16:04:22

@bpicolo: now when I think about it, it probably was simply prepended before your advanced build as is. it came directly from https://fb.me/react-13.0.1.min.js

bpicolo16:04:35

that's what we determined

slester17:04:01

is there something special I need to do to get goog.history to actually update the location bar in the browser?

slester17:04:14

The routing with secretary is working, but the URL doesn't actually change

borkdude18:04:48

@slester: there is a snippet in the README.md of secretary

slester18:04:37

that's what I'm using. it's not updating the location bar.

lsenta18:04:14

Hola cljs'ers, I have a polyfill that won't work when the html is produced by cljs+figwheel+react+reagent

lsenta18:04:49

Do you guys have an idea where that might come from? (if I copy the generated html and put it in a "dummy page" it works)

Roman Liutikov19:04:42

Does anybody know why ClojureScript fails to load a foreign lib if it is ES6 module which imports CommonJS module? Closure Compiler allows mixing of different module types https://github.com/google/closure-compiler/wiki/JS-Modules I actually tried to compile this directly with GCC and it compiles fine with —process_common_js_modules flag specified. Not sure, but it seems like compiler settings in ClojureScript lacks this flag.

Roman Liutikov19:04:56

it also fails to compile CJS module which imports ES6 module

Yehonathan Sharvit20:04:14

I need help with replumb

Yehonathan Sharvit20:04:27

I’m trying to require macros

dnolen20:04:42

@roman01la: let’s move that conversation into #C07UQ678E

mfikes21:04:50

@viebel: Are you encountering an issue loading macro namespaces, or are you just trying to figure out how to do it?

Yehonathan Sharvit21:04:22

@mfikes: I’m trying to figure out how to do it when the macros are defined in a clj file

richiardiandrea21:04:48

@viebel: importing core.async in bootstrapped doesn't work for now, @mfikes tried a port but it was not complete IIRC

Yehonathan Sharvit21:04:15

what about core.match?

richiardiandrea21:04:26

Usually you need the classic clj files wish macros in the class path for it to work (in replumb it is :src-paths)

richiardiandrea21:04:51

I am not aware of any port for core.match

richiardiandrea21:04:18

But I totally agree that they should be supported

richiardiandrea21:04:23

Mike last post on macros brought to the light a possible simplification of macros calling macros (the towering problem) in bootstrap

Yehonathan Sharvit21:04:36

and what about importing macros that are implemented in a file that is part of my project?

richiardiandrea21:04:13

In replumb, you macro files must be on src-paths

mfikes21:04:54

I'm aware of a port of core.logic that was working, but not core.match or core.async. I ported cljs.test (but didn't make the port generally available).

Yehonathan Sharvit21:04:30

why a port is required?

mfikes21:04:34

@viebel: the main reasons have to do with Clojure macro code making use of facilities only available to Clojure. In self-hosted ClojureScript, macro code is compiled as ClojureScript. Some of the things encountered in the port of cljs.test are documented here: https://gist.github.com/mfikes/4e9e78753a0d406da873 (but as @richiardiandrea indicated, a recent discovery that a tower is not always required simplifies things).

Yehonathan Sharvit21:04:01

thanks @mfikes I will look at the articles and gist

sbondaryev22:04:15

how can i create a future in clojurescript?

mfikes22:04:53

@sbondaryev: there's only one thread, this drives what's possible and available

sbondaryev22:04:38

@mfikes: actually, I need to make 2 async calls and wait for result

mfikes22:04:51

I suppose core.async might be worth investigating.

mfikes22:04:25

Otherwise, you can roll your own solution with callbacks and a little state management.

sbondaryev22:04:57

yes, I hoped to avoid solution with core.async by using something from clojure.core

mfikes22:04:10

@viebel: Are you adding the ability to define macros in KLIPSE?

taylor.sando23:04:38

You could potentially use http://funcool.github.io/promesa/latest/ -- though it is also not in clojure.core

sbondaryev23:04:11

Thanks for the link, I think i will try to make a simple/custom solution with goog.Promise