This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-10
Channels
- # beginners (40)
- # boot (307)
- # boulder-clojurians (2)
- # carry (3)
- # cljs-dev (3)
- # cljsjs (16)
- # clojure (42)
- # clojure-greece (3)
- # clojure-russia (10)
- # clojure-uk (3)
- # clojurescript (116)
- # community-development (1)
- # component (5)
- # conf-proposals (2)
- # core-async (1)
- # crypto (2)
- # cursive (3)
- # devcards (1)
- # events (1)
- # hoplon (123)
- # om (28)
- # onyx (17)
- # pedestal (3)
- # proton (1)
- # re-frame (18)
- # reagent (26)
i'm trying to compile a project that has macros under src/clj
and clojurescript under src/cljs
it works in lein-cljsbuild
as I can specify multiple :source-paths
, but I can't figure out how to run it with the normal build api
when I (require '[cljs.build.api :as b])
, and (b/watch "src" ...)
, I get an error saying java.io.FileNotFoundException: Could not locate utils/helpers__init.class or utils/helpers.clj on classpath
any insight on how lein-cljsbuild
combines sources from multiple paths for compilation? not using lein-cljsbuild
since I have a lot of foreign deps that I can't require across a bunch of different builds I have without repeating myself a bazillion times due to limitations in lein
wait a second, even putting the .clj files into the cljs directory doesn't solve the problem
@jiangts are you missing a :source-paths for clojure (not clojurescript) as well in your project.clj?
can I somehow stop lein from polluting target/ dir with it's stuff? or it is totally ok to just output to different dir?
i only need main and renderer
project.clj is
(defproject eion "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url ""
:license {:name "MIT"
:url ""}
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.9.229"]]
:plugins [[lein-cljsbuild "1.1.4"]]
:cljsbuild {
:builds [{
:source-paths ["src/eion/main"]
:compiler {
:output-to "target/main/core.js"
}
} {
:source-paths ["src/eion/renderer"]
:compiler {
:output-to "target/renderer/core.js"
}
}]
})
@yury.solovyov you can specify :output-dir
and :output-to
to point to an independent directory, I tend to point them into resources/public/_compiled
so they are visible by my dev web server
now I have a different problem
files that are coming out are not actually complete bundles
they refer to goog ns
I need to somehow embed this info
also I would recommend you to not use vector in :cljsbuild > :builds
but a map instead, using vector prevents further composing via lein profiles feature
I think this is somewhat typical error
(advice) I tend to explicitly declare empty :cljsbuild :builds at the root level, and then use profiles to “merge” ad-hoc configurations, and usually prepare common configurations via aliases. see the example here: https://github.com/binaryage/cljs-oops/blob/master/project.clj#L37
yup, but let me just get started first 🙂
replaced array with map
from the gist it looks like you are not using :main
, this is a quirk in the cljs compiler in my opinion, :advanced and :none modes behave completely differently depending if :main was provided or not
you mean main in build maps?
you have to specify :main if you want to get “bootable” script out: https://github.com/clojure/clojurescript/wiki/Compiler-Options#optimizations
in other case you have to include goog/base.js prior your script and then manually goog.require your main namespace(s) after
actually, output chanesg as soon as I changes output
I'll make a gist
ok, optimizations :simple behave like :advanced, :output-to will be a “bootable” script
in case of :none optimizations (which is the default AFAIK), you will get just a script with dependencies and you have to some manual work as I described above
:main
key maps to ns
right?
yes, read the docs: https://github.com/clojure/clojurescript/wiki/Compiler-Options#main
core.js will be a self-contained “bootable” script, which won’t depend on some prior setup
it works, but throws an error now cljs.core/*main-cli-fn* not set
, I guess I need to use some repl?
hey guys so I am running into some problems when using transducers and NodeJS calls. if I understand correctly transducers expect their functions to return synchronosly, but a lot of the NodeJS calls are themselves an async call that return a channel. Does any one have any experience unsing transducers with NodeJS API?
your question should be transducers + core.async, and answer is “they should play well"
@darwin under node
@yury.solovyov you have set main-cli-fn to some function, it will be called as your command-line app entrypoint
@stbgz there was a recent article: http://blog.venanti.us/using-transducers-with-core-async-clojurescript/
if you already have a transducer, you can create your returning channel with transducer applied, xform param here: https://clojuredocs.org/clojure.core.async/chan
if you don’t have transducer and want to apply a simple transformation function, you can just wrap your resulting channel in a core.async/map: https://clojuredocs.org/clojure.core.async/map
@darwin thank you, I've managed to get everything working
new to clojurescript. I have data in a clojurescript datastructure on the client. And now want to save it somewhere on the server. What's a simple way? serialize to json on client? or use some other format/transport. Not sure if EDN would be easier if i want to use the same structure on the server. To avoid the double serialization. Any tips appreciated. otherwise i'll power through. thanks
if you have clojure on the backend, I would recommend: https://github.com/cognitect/transit-clj
here is the cljs counterpart: https://github.com/cognitect/transit-cljs
And should i even try to get figwheel and my compojure handlers running on the same port?
it's own nrepl port right? But diff http port? haven't read all the figwheel docs yet to see
figwheel port is the port where figwheel file-system watcher notifies client in the browser that it should reload something
ok. thanks. so i'll start up two processes, and work on that whole CORS prevention.
btw. and the CORS problem of figwheel http server is already resolved if I remember correctly
ok. thanks for the advice. Ok. not sure if it's a problem with figwheel. might be the ajax lib i used. didnt' like requesting something on 3000 with figwheel ui on 3449
@darwin is there any special plugin I need to install to support sourcemaps? I can't see the mapping file to be generated at all https://gist.github.com/YurySolovyov/16fdcec3fe39765e439b8dd8d55b6ca1
I tried setting :source-map-path
and :asset-path
no effect
d'oh, it seems like lein cached compiled files all this time and didn't reported any errors, but whn I changed file, I now see them
I mean errors
can I just somehow have core.js.map
and not all the other dirs there?
my understanding is that source maps are generated by default and their location is determined by :output-dir in :none mode, and :output-to in all other modes
so in your case of :simple optimizations, just point :output-dir into some temp folder and you get only core.js and core.js.map as your resources
yeah, it seems to be a hard requirement here:
Compiling "out/main/core.js" failed.
java.lang.AssertionError: Assert failed: :output-dir "/media/yury/MYMEDIA/Projects/eion-clojurescript/target/cljsbuild-compiler-0" must specify a directory in :output-to's parent "/media/yury/MYMEDIA/Projects/eion-clojurescript/out/main" if optimization setting applied
(or (nil? (:output-to opts)) (:modules opts) (same-or-subdirectory-of? (absolute-parent output-to) output-dir))
maybe just copy it as build step?
but this would be brittle
ah, ok, yes post-build step is always a solution, but I think there must be a better way
I'm ok with having them, but I need some way to extract relevant files afterwards to distribute the app
yes, that is another story, I would recommend a plain shell script if you are under an unix system
if I'm into shell scripts, I'd better just copy the source map
a tip: I tend to use lein-shell plugin to allow executing arbitrary shell files from lein aliases, it is pretty flexible
like here: https://github.com/binaryage/dirac/blob/3de0266873aaa1c83be44a4f5068aa2e76d370f8/project.clj#L418
https://github.com/binaryage/dirac/blob/3de0266873aaa1c83be44a4f5068aa2e76d370f8/scripts/release.sh
I don't get the reuirement though, if we have this https://github.com/clojure/clojurescript/wiki/Compiler-Options#source-map-path
why not just allow users to provide their own paths?
in general case your cljs compiler could produce multiple js files, see :modules feature
that is why you configure it via directory locations and not by specifying a single path
now when I’m reading the docs, you can specify a path to source map: https://github.com/clojure/clojurescript/wiki/Compiler-Options#source-map
yes, it does not work
will try modules
I tried setting the path like :source-map "out/main/core.js.map"
and it does not work without setting the dir
yup, one min
after some tinkering with yury’s config I’ve found the culprit: yury decided to point output files produced by cljs compiler into custom “out” folder, but he didn’t instruct leiningen to clean it when issuing lein clean
. this probably coupled with aggressive caching in cljs compiler, so when he was tinkering with the project.clj and re-running lein cljsbuild once <build-id>
, the changes didn’t take effect (because misconfigured out dir was still present from previous builds) - this puzzled me at first too, but I have the basic survival experience from clojurescript world: "if it does not work, kill it with fire and start from scratch"
yup, I guess I'll just make another release task to make it packaging-ready bundle
thanks
also changed out
to output