Fork me on GitHub
#clojurescript
<
2017-11-15
>
derpocious03:11:09

hey, if anyone could please help me with my issue in calling cljs files from the lein repl I just posted about it in the leiningen channel. thanks. 🙂

qqq04:11:26

without using core.async, is there a way to 'queue' messages on a websocket when it's in the "CONNECTING' state ?

gklijs10:11:54

I went to Devoxx and heard about Elm there. It seems like I might like static typing more, especially since it gives nice error messages compile time. Still have to finish a clojure(script) project before I can do something with Elm. But I wondered if maybe somebody here tried it. From what I read the javascript interop is slightly more work, but on other fronts it seems better.

thheller10:11:08

@gklijs never used Elm personally but this might be relevant https://www.youtube.com/watch?v=Q6Q5D6mI-34

gklijs11:11:38

Thanks, form a quick look it will give me some answers, one of things that’s very nice about clojurescript is the repl, but I hardly ever use it.

baptiste-from-paris10:11:08

hello friends, I am using Lumo and puppeteer to scrap some web pages. Some $ selectors returns a js Map object. Does anyone knows how can I use it in cljs ?

Roman Liutikov11:11:00

@baptiste-from-paris js/Map implements Iterable protocol, so you can unwrap it into js/Array of map entries using js/Array.from

baptiste-from-paris11:11:48

Yes, that’s what I was reading, I have to try that

lovuikeng12:11:59

@gklijs here is one answer... swannodette thinks elm and scala.js are awesome, but he'd rewrite ClojureScript if others took it away from him swannodette@defn#26

hkjels12:11:50

@gklijs I’ve done some work in Elm. Elm is really great if you don’t mind writing some javascript on the side

hkjels12:11:59

if you need to be pragmatic and you want to stay in one language, then Clojurescript is far better in my opinion

ajs12:11:57

@gklijs i spent some serious time last summer evaluating Elm as a replacement for Clojurescript in a project for a client. Having better confirmation of types in the program was the main reason. I concluded that Clojurescript is much more mature and stable overall, and you can solve the data shaping problem using Clojure.spec of any of the many other libraries out there. In general, you can also get work done faster in Clojurescript, and it involves a lot less code than Elm.

gklijs12:11:55

ok, less code is also less chance of errors, and I’m already quit familiar with spec. It just feels a bit cumbersome at times, but on the other side it’s nice you can do a lot of things without specs, and quickly see if it works,

ajs12:11:18

Elm has some notable downsides that may or may not matter to your case, but lack of support for advanced optimizations is one of them. Also, inability to easily write a program that integrates heavily with third-party libraries in JS. Elm devs overall tend to agree that Elm is not the best choice if you need the wider JS ecosystem because of the overhead in time to get things done.

ajs12:11:40

There are other tools than spec out there if you want less verbosity

ajs12:11:01

Clojure is ultimately more flexible since it has a fantastic macro system so you can add whatever features to the language you feel are missing

baptiste-from-paris12:11:44

Continuing with puppeteer I have to inject clojurescript into chrome instance with the addScriptTag in order to use clojure along with puppeteer. Is there a CDN for some kind of cljs.js with the whole language ?

derpocious13:11:41

Hey all, is it possible to load a clojurescript namespace from lein repl? Does anyone know how to do it?

vemv13:11:37

@derpocious are you familiar with figwheel?

vemv13:11:08

it gives you a repl where you can require things among other goodies

tmarble15:11:53

Hi all! Today I'm thinking about making a simple CLJS example to demonstrate JS (export module) interop -- just want to check: has anyone done this? (context is seeing António's talk at the Conj)

zalky15:11:38

@U0501UWML: I found that talk super interesting. Do you mean export to npm?

tmarble15:11:23

sure.. could be npm or any other conventional JS target.... the trick is our CLJS gurus are creating far to much cool stuff --- i just want to document it!

zalky15:11:20

Yeah, I was experimenting with consuming npm modules in cljs, and while I got it to work for a couple of libs (react, prosemirror... ), I couldn't get it to work for quite a few others.

zalky15:11:00

Hi all. I'm working on integrating cljs and js code in a project, and I have a build that is working well, except advanced compilation mode is throwing errors on ES6 features:

ERROR - this language feature is only supported for ECMASCRIPT6 mode or better: arrow function. Use --language_in=ECMASCRIPT6 or ECMASCRIPT6_STRICT or higher to enable ES6 features.
In the clojurescript docs it says that ES6 modules can be enabled by including the library as a foreign lib:
:foreign-libs [{:file "src/js"
                :module-type :es6}]
(as seen in: https://clojurescript.org/guides/javascript-modules) And while this also works with no optimizations, in advanced mode, it does not have the expected effect, and the same errors are thrown. Has anyone had experience including ES6 js code in their project?

thheller15:11:36

you might need to set :language-in :ecmascript6 in the compiler options

zalky15:11:16

@U05224H0W: I see, is that instead of the foreign-libs entry, or in addition to.

thheller15:11:51

in addition

zalky15:11:00

Hmm... while that works for the errors, I'm now seeing a lot of warnings about skipped compiler passes:

WARNING: Skipping pass optimizeToEs6

thheller15:11:33

I really have no idea how all this works in CLJS core. it works very differently in shadow-cljs as described here: https://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html

zalky20:11:47

Anyone ever seen the cljs compiler emit a bunch of warnings like:

WARNING: Skipping pass checkVariableReferences 
factory features:  [block function, getters, string continuation ... etc
I'm compiling a very simple build that includes es6 js, and for the life of me I can't get it to compile with advanced optimizations. The JS file being included:
goog.provide('js.lib');

js.lib.debugMessage = (x = "any old string") => {
  console.log(`Printing ${x} from cljs!`);
};
Compiler options:
{:asset-path     "js/main.out"
  :optimizations  :advanced
  :source-map     false
  :parallel-build true
  :language-in    :es6
  :foreign-libs   [{:file        "src/js"
                    :module-type :es6}]}
Minimal build here: https://github.com/zalky/integrated

r0man20:11:01

Hello, I was a bit out of the loop with ClojureScript recently but followed the announcement of :npm-deps and got quite exited. I would like to try the new apollo client via npm-deps with clojurescript in the browser. everything compiles and the node dependencies do get installed. but when I open my app in the browser I get errors like this "Uncaught ReferenceError: module is not defined" and "Uncaught ReferenceError: module$home$roman$workspace$apollo$node_modules$apollo_link$lib$index is not defined" telling me something is not right with my node dependencies. What's the state of :npm-deps? Are there still some restrictions with node modules, is this a bug, am I doing something wrong, or is trying to use a package like apollo-client via :npm-deps still a bit too ambitious? Any ideas? 🙂

zalky21:11:31

@U0CKBRBD2: I also experimented recently with :npm-deps, and my experience was that while I was able to get some libs to work, others libs had issues similar to what you saw. My understanding is that the compiler has trouble inferring externs from some of the more advanced code that some libraries use. If you want to test that your approach is correct, I recommend trying your build with one of the projects that is known to work via :npm-deps, like react or lodash.

r0man21:11:23

@U0HJK8682 ok, thanks! I'll verify with lodash next

r0man21:11:12

@U0HJK8682 react via :npm-deps is working, so maybe something with apollo 😕

thheller21:11:20

react-apollo definitely works with shadow-cljs if you want to try that.

r0man23:11:06

@U05224H0W ok, good to know. I'll try it. Thanks 🙂

escherize22:11:19

Is there a way to tell the cljs compiler to include deps with a chosen build, but not with other builds? (Ideallly via lein cljsbuild)? I've been looking for some docs regarding this process so if you could point me to it that'd be great too

danielcompton22:11:13

Probably need to use profiles to include/exclude deps

scknkkrer23:11:35

Any way to get an prop in a React Native app, with re-frame ?