This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # admin-announcements (90)
- # beginners (36)
- # boot (169)
- # cider (18)
- # clojure (84)
- # clojure-australia (1)
- # clojure-brasil (20)
- # clojure-czech (2)
- # clojure-france (5)
- # clojure-germany (1)
- # clojure-india (8)
- # clojure-italy (39)
- # clojure-japan (14)
- # clojure-korea (2)
- # clojure-russia (9)
- # clojure-sg (1)
- # clojure-spain (16)
- # clojure-ukraine (1)
- # clojurebridge (20)
- # clojurescript (146)
- # code-reviews (48)
- # core-typed (1)
- # datomic (24)
- # editors (59)
- # euroclojure (6)
- # ldnclj (25)
- # off-topic (6)
- # onyx (3)
- # reagent (7)
hello everyone a cljsc question. I want to generate a standalone js file from my cljs. Is there a way to do this with lein cljsbuild ?
@shriphani: that’s just simply how ClojureScript works if you use any optimization setting other than
@dnolen: okay, I thought that was the purpose of the cljs.*.api namespaces, to indicate stable public APIs. which other namespaces are public?
@dnolen: another question. Can I get a minified js file with only my stuff and everything else that I can throw into a CDN ?
@shriphani: when using any optimization level other than
@shriphani: if you haven’t gone through the Quick Start I highly recommend it. It covers all the basics.
@dnolen: can you confirm these parsed cljs.repl symbols should be public: https://github.com/cljsinfo/api-refs/tree/catalog#cljscompilerapi
@shaunlebron: well probably need to go in there and mark some helper things private. A lot of it is public but not everything.
@dnolen: okay, I’ll cherry-pick symbols from cljs.repl for the reference until then
@dnolen What is the end goal exactly of being able to compile the cljs compiler to js? Since the Closure compiler is a big part of cljs compilation, I'm curious how that could be used from within cljs.
is anyone using cljc and Prismatic Schema together? i’m really struggling with can’t-find-var compilation errors for this library when i use it in a
its not cljc, you’re right. for some daft reason, i’m getting this:
java.lang.RuntimeException: No such var: s/EnumSchema
when i try
(require ‘[schema.core :as s]) s/EnumSchema
i should totally be able to do this but i’m not. clj and cljs both bugging out
@danielcompton: thanks for your awesome reader conditionals post. helped me switch very easily! http://danielcompton.net/2015/06/10/clojure-reader-conditionals-by-example
^:const prevents redefining and also facilitates use in
case. See CLJS-806.
for some applications JVM requirement is burden or non-starter - Electron or Raspberry Pi
for online tutorials it’s nice to drop evaluator service component - just static files
also for simple scripting, while it’s unclear yet, I suspect a bootstrapped ClojureScript will just start / run, use less memory faster for very short lived processes.
@mfikes: Ok. But it doesn't influence the way the code is compiled — no need to use it for optimization purposes, then.
@dnolen: I'm curious. How come you stick with the separate ns for macros pattern (ie. cljs.env.macros) instead of putting them in cljs.env now that that is a .cljc?
you cannot mix macros into ClojureScript source, and a bootstrapped compiler isn’t going to change that
I'm aware of that. But you can put them behind $?(:clj ...) and (:require-macros [cljs.env :refer ...])?
I don't see why you shouldn't be able to mix macros in as long as they are hidden for cljs
thheller: hrm actually the problem with that is if the body of the macro is different, which in this case they are slightly different.
and macros just see
:clj there’s no way to communicate that the macros are being loaded into a
@dnolen not sure I understand what you mean? as long as its behind #?(:clj ...) cljs doesn't see it at all and it would be the same like it is now in cljs/env/macros.clj
@thheller: what you showed about shows loading the same ns with
:require-macros to get the macros.
ah this is confusing. One macro expands to clojure and one to cljs. Didn't notice that.
well once cljs can compile itself (and do macro expansion) you should be able to put them behind #?(:cljs ...)
@dnolen IIRC the closure library is prominent in compiled cljs code. What if the cljs-in-cljs->js target code depends on closure lib code that was compiled away (or had their names minified) by the initial cljs->js compile (using :advanced optimization)? Perhaps you've thought of this and are taking care of it, but that's the part that seems non obvious to me.
@aengelberg: closure lib is not really all that prominent in cljs.core. goog.base, goog.string, goog.object, goog.array. That’s about it.
@thheller: right only works if you are already bootstrapped, but really that makes it generally unusable
that is if you’re using bootstrapped compiler you probably don’t care about the size of the generated code
this is why bootstrap will always be optional - it’s a benefit with significant tradeoffs at odds with how ClojureScript is leveraged today.
So will goog.string (etc) always be there in the "host environment" without closure compiler obfuscation?
Curious about @jrychter ’s earlier question; wrote up some exposition on
case: http://blog.fikesfarm.com/posts/2015-06-15-clojurescript-case-constants.html Hope it helps!
@mfikes: hey, cool! This is a great explanation. My (uninformed) thinking was more along the lines of "make something ^:const and avoid var lookups when it's used".
mfikes just posted an article about seeing emitted js for a cljs expression in the repl: http://blog.fikesfarm.com/posts/2015-06-15-see-js-in-cljs-repl.html
Just published a small post for GSoC week 3 : http://mneise.github.io/posts/2015-06-15-week-3.html 😉
@maria: Awesome! One question brewing in my mind: How do we reference symbols in the resulting generated Closure libs from ClojureScript? I succeeded by using a “fully qualified” munged symbol that bakes in the file path, but was wondering if shorter names can be used. If this hasn’t been sorted yet—cool—am just curious.
@mfikes: You can refer to the module as if it would be a regular Google Closure module, e.g.:
(ns hello-world.core (:require [greeting :as g] [goog.string :as string])) (enable-console-print!) (println (string/startsWith "Hello" "H")) (println (g/hello "Welt!"))
or you can even use
(ns hello-world.core (:require [greeting :refer [hello]])) (enable-console-print!) (println (hello "Welt!"))
@maria: does this mean that we’ll need to recursively reference all dependencies of a lib we want to use?
Also, what will happen if you depend on a library which has two versions of the same package somewhere in its dependency tree?
@danielcompton: not quite sure how this could happen. Do you mean in case the user specifies two different versions of the library in the compiler options?
@danielcompton: that's not really a problem as we just rely on Maven to prevent stuff like that.
Sorry, I’ll rephrase my question. I don’t fully understand everything that’s going on so maybe this isn’t an issue. If we have a commonjs JS library
query which relies on
libb both depend on different versions of
promise-lib, will this cause any issues?
but if we’re interoperating with common JS, won’t we have two
:foreign-libs entries with the same
:provides but from different versions?
And more or less why we don’t use either for the most part and the quick rise of CLJSJS to popularity
So does that mean you won’t be able to just use arbitrary NPM packages in CLJS with this patch?
@meow: only insofar as that’s a bit weird as Google Closure encourages inlining scripts into body for latency reasons
things are getting serious now https://github.com/clojure/clojurescript/commit/a65f7b75b592691c314f378559cdd2a43936b3cc
but the really you still want to insert the script tag exactly when enough of the page has loaded
early days of closure they were loading script in iframes and controlling the dom of the parent -- not sure that's still common ...
Everybody: Don't bother David for the next four hours and a self-hosting ClojureScript will pop out the other end. :)
@shaunlebron: Just ran across this, very nice. Some really good links at the end, too. (One has a minor typo - the "ClojureScript Style Guide" is the "Clojure Style Guide") Thanks for putting it together! https://github.com/shaunlebron/ClojureScript-Syntax-in-15-minutes