Fork me on GitHub

is it possible to compile a self-contained js snippet from a clojurescript snippet in the browser? i would like to make a collaborative coding environment with an iframe’d output window like codepen or jsbin. i feel like the best way would be to have a fully self-sufficient string of js that i just inject into an iframe. there are other ways around this if it’s not possible, though.


just thought i’d check before i went too deep down the compiler rabbit hole


right now i have something that will translate (println "hey”) to,"hey”); but obviously cljs.core.println is not defined within this output.


oh wow, i see there is a lot of discussion in this channel of similar things not too long ago. apologies if this question is redundant


I never used the search function before


So I'm taking a look at silk right now for routing, and I think it looks like a better, more flexible solution than secretary. Has anyone else found that to be the case? or would you recommend something else?


Actually, bidi looks good, too:


I think I'm going to go with bidi. Looks relatively simple and it will fit all of my needs


what makes it more flexible?


ooh i like that it is not macro-based


@akjetma: Type (println "hey”) into the Compilation box at and you’ll see that,"hey”); is dropped into the box on the right.


@akjetma: If you want to be able to evaluate it, just look at how some of the online REPLs like are built.


Oh, wonderful! thank you I will take a look at this. I am looking for output that includes the definition of, e.g. cljs.core.println but this might be the wrong way to go about it


I suppose is a bad example—it doesn’t appear to have print output hooked up. But does. simple_smile


@akjetma: If you evaluate js/cljs.core.println in those two online REPLs you will see the JavaScript. employs :simple and employs :none


hey guys how to do smooth scrolling in clojurescript ?


ahh, yeah, so the problem i’m running into is: if i want to have a sandboxed environment (iframe with a separate window from the context in which the clojurescript is compiled) to evaluate the compiled clojurescript, i need to have all of the core functionality of clojurescript available to both sections. i am thinking i will split the code-writing/compiling section and iframe/sandbox section into closure modules and they can both have the common/core parts of clojurescript in a tertiary script.


thank you for pointing out that dnolen post and the js/cljs.core.println bit though, that is very helpful


@akjetma: Yeah, what you are describing sounds doable. Just up to your imagination and how you want to implement something like that.


@akjetma: I’ve also pondered if it is possible to produce a compiler that is built with :advanced (to keep it small), but then evaluate the generated JavaScript in an environment that has the standard library JavaScript generated using :none. (Not really what you are doing, but I was wondering about that nonetheless.)


Ah yeah, that would be perfect/the ideal clean solution


Is it possible to get any information about what is defined in various namespaces in a repl context in cljs? Like ns-interns in jvm Clojure ideally but interested in any ways this may be possible.


@noonian: ns-interns works, dir works, etc.


What is the best way to package a javascript library inside the clojurescript one? I'd like to avoid the situation where people have to install the js lib separately to be able to use my cljs lib


@nxqd: Look into goog.dom.fx.Scroll, worked great for me the other day


@nullptr: Thanks, will check out their docs


Has anyone used JSPM with ClojureScript. Looks to me like a nice, easy way to use :foreign-libs, using SystemJS to do the heavy lifting, then just ES6 imports from there...


I see, the obvious way moving forward is to use cljsjs I guess? 😉


@roberto: with secretary, I couldn't find a way to pass in anything custom to my route handler. For example, I might want to pass in some service to all of my route handlers. With silk or bidi, this is easy, since they just translate the (partial) URL to a handler or whatever data you want and then it is up to you to actually call the handler.


@roberto Keechma has a pure data processing based router so that might work for you too


@mihaelkonjevic: I was actually the one looking for the router. Thanks for the suggestion simple_smile


hey guys, does cljs have any support for ES6 syntax beyond module import?


@kmandrup: there are the :language-in and :language-out compiler options ( The description in the wiki is outdated, meaning you can also set :language-in to :ecmascript6. Will update them in a bit.


Nice to see you here @maria simple_smile I'm just curious how to interop with popular modern JS frameworks, where many now leverage new ES6 syntax...


Yeah, we need some better docs on modern JS interop


@maria any examples on using :ecmascript6 ??


@kmandrup: so the foreign-libs you want to include use ES6 features?


I'd like to write an ES6 compatible class from within cljs, is that possible?


@kmandrup: no, I don’t think so, since all the code that the ClojureScript compiler generates is ES3 compatible


@kmandrup: not sure what advantage that would offer you … ES6 classes are mostly about syntactical sugar over existing functionality


there's very little reason to support any ES6 syntactical feature in ClojureScript at this time


I understand that, just simplifies not having to "reverse engineer"... say I'd like to integrate with Angular, Aurelia, Ember or whatever... all requiring ES6.


@kmandrup: “requiring”


assuming everybody has to compile to ES5 anyway - I don’t know what that really means


Just curious if I have to work with prototype directly... what about getters/setters and all the other "magic spells" of ES6, would that still be simple in CS?


no but there’s no real need


another advantage of Closure Compiler is you can write whatever bits of JS you actually need and compile it all together


Sure, I watched @maria presentation on compiler internals... but not sure where I would "write whatever bits of JS you actually need"? except by direct compiler extension/integration?


just write a JavaScript file


Sure, but that's what I was hoping to avoid. The whole point... escaping mutability hell while writing and leveraging ES6 code and not having to use Immutable.js etc.


the later part of your statement seem contradictory


why does ClojureScript need sugar for making mutable classes when you can just write them directly?


Just trying to avoid having to reverse engineer latest libraries/frameworks to ES5, such as:


I get the general gist, I'd have to find ES5 or ES3 equivalent syntax to achieve the same functionality and then wrap it with CS macros? Thanks simple_smile


ClojureScript avoided all class sugar in the past because there wasn’t a standard way to create “classes” in JavaScript just various competing patterns


ES2015 class sugar will eventually dominate but I don’t think we’re really there yet especially since most MVC frameworks are just fundamentally incompatible with ClojureScript wrt. mutability


a vast majority of ClojureScript people use React which doesn’t have these problems and doesn’t really require ES6 classes in any deep way


eventually the demand for other ES6 stuff may be great enough to desire some kind of defclass patch, but I would say we are not there yet


I see your valid points simple_smile Thanks for your time, I know you must be busy! I'm trying to write a book on native app dev with ClojureScript while learning it... since most of the resources in the wild seem to be out dated and don't delve into using React Native, Ambly, Electron etc.


Yeah, exactly my point. Since React still support the old ES5 syntax simple_smile I'm also exploring reagent and for the same reason! Cheers simple_smile I owe you a beer!!


I also much prefer the pure functional/reactive approach of React, my questions were more "on principle"


right I just want to see wider acceptance and more “pressure” before pursuing it


but my suspicion is the tail of the jQuery JS world is very, very long


No worries, was just curious what was currently possible. Would be nice to meet up in a pub in Brooklyn sometime... Cheers!


@kmandrup: or swing by LispNYC or ClojureNYC in the city, I often attend simple_smile


@dnolen: Awesome! See you around simple_smile


For experimental support (fork?) of select ES6 constructs, couldn't we make the compiler's Emission step optionally be configured to perform an additional transformation step (such as running through a transpiler), then have class, extends etc. "fall through" and be transpiled to ES5?


@kmandrup: it’s not that simple - this discussion probably belongs in #C07UQ678E