This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-19
Channels
- # adventofcode (4)
- # beginners (80)
- # boot (4)
- # cbus (2)
- # cider (62)
- # clara (18)
- # cljs-dev (8)
- # cljsrn (10)
- # clojure (139)
- # clojure-brasil (3)
- # clojure-dev (27)
- # clojure-italy (1)
- # clojure-russia (3)
- # clojure-spec (4)
- # clojure-uk (47)
- # clojurescript (102)
- # core-async (10)
- # cursive (7)
- # datomic (71)
- # emacs (32)
- # fulcro (99)
- # funcool (1)
- # hoplon (3)
- # jobs (1)
- # jobs-discuss (6)
- # jobs_rus (2)
- # leiningen (3)
- # luminus (2)
- # lumo (14)
- # mount (7)
- # off-topic (19)
- # re-frame (25)
- # ring-swagger (4)
- # rum (3)
- # shadow-cljs (142)
- # specter (2)
- # sql (16)
- # timbre (1)
- # vim (3)
Also, any idea whats up here?
SHADOW import error /home/asp/projects/logview/target/shadow-cljs/builds/server/dev/out/cljs-runtime/macchiato.cookies.js
Error: Cannot find module 'cookies'
@thheller is it possible for me to use shadow in this manner: put all intermediate output in target
, but put the final entry point in resources
? in prod, we only use a single js in resources. in dev, we do what i just said, and serve target/js at /js in dev time. i’ve got shadow working, but because it puts stuff in resources, it now complains that it’s finding sources twice.
ie my working cljsbuild config
:output-to "resources/app/js/app.js"
:output-dir "target/js/out"
:asset-path "/js/out"
dep in the root of the project (not in a profile), a (shadow/start!)
call showing shadow-cljs - server running at
in my repl.
but, when i shadow-cljs watch
, i get: ClassNotFoundException shadow.cljs.devtools.cli
. what have i forgotten?
that’s right after a shadow-cljs - connected to server
message
does the cljs hot code reloading work without using the built in web server?
(i know the docs say css requires the web server)
even when using :lein {:profile "+dev"}
, :http-handler
can’t find my dev profile http handler namespace.
@thheller the docs could really do with an example devtools code snippet. i’ve been reading the source to figure out how to give it its options correctly 🙂
@robert-stuttaford You reading the new user guide?
Robert finds https://github.com/thheller/shadow-cljs/tree/master/shadow-cljs.edn
yes sir
now that i’m reading that edn in github, i can see how output-dir, asset-path and http-root are meant to hang together
to be clear: the guide has been tremendously helpful in many other ways @tony.kay 🙂
thanks, but yeah, we know it is incomplete...it was thrown together from existing stuff and my additions in about 2 days
wow. that’s a massive doc for a week’s work
@theasp npm deps are kept in package.json
. libaries can publish a deps.cljs
with :npm-deps {"thing" "version"}
which shadow-cljs
will transfer over to package.json
. unfortunately most libaries do not yet do this.
@robert-stuttaford for now just add a require for shadow.cljs.devtools.cli
where you require shadow.cljs.devtools.server
.
here is a full devtools example https://github.com/shadow-cljs/quickstart-browser/blob/master/shadow-cljs.edn
@doglooksgood “missing instance” means you probably need to call (shadow.cljs.devtools.server/start!)
somewhere to start the embedded server instance
@robert-stuttaford the css and cljs hot loading works without the built-in http server yes. cljs just works, css just requires that you set :watch-dir
which should point to the document root of your webserver.
rad thanks @thheller will try things
when running the embedded server you can also do everything directly from the REPL if you want
feels like i’m really close to having things set up right. will keep pushing
(shadow.cljs.devtools.api/compile :build)
is the same as calling shadow-cljs compile build
would the webserver support the use of immutant.web.async
, given that you use undertow for the webserver?
@robert-stuttaford We also run it embedded for 2 months now works like a charm if you need help let me know
i think i just won through!
Awesome we just do this:
(defn start-cljs-repl []
(shadow-server/start!)
(shadow/watch :app)
(shadow/watch :test)
(shadow/watch :devcards)
(shadow/nrepl-select :app))
and if something breaks you can just run shadow-server/stop! and restart everything
very nice!
i’m enjoying having fast cli commands with the server running in the jvm. prefer to have the cljs output separate to the web server
Yeah we use cider and emacs, so we like to run some command in emacs which starts everything inside of emacs
and then all the autocompletion works
i may even finally learn to use a cljs repl properly
@robert-stuttaford draft-js
was among the packages I tested when writing the npm
integration. I might be able to help if you have questions.
thanks thheller - i’ve got a working spike together 🙂 just getting the css watching working, and then i’m happy i can Build Features
kudos on shadow - it’s come a bloody long way since i used your previous toolchain!
@mitchelkuijpers what does nrepl-select do?
switches the current nrepl over to CLJS. so whatever you type next in the REPL will eval in the app
build
@thheller any thoughts on splitting the root js from all the extra js output on disk?
(cf. my question at 7:07am)
if just creates headaches. it is already separated out into the <output-dir>/cljs-runtime
directory
production does not produce or need the cljs-runtime
dir so you can ignore that for any release
right. the issue is that if i put it all in resources, it’s all on the classpath, and shadow finds its own output and complains about double provides
the code is a library project; the jar includes the release js
i’ll work it out. just have to find another way 😎
you include the lib, add its ring handler to your ring app, and it serves the rest turn-key style
means the app that uses it need not compile any js
its fine, our CI handles building the js and including it. the way i do it with cljsbuild just makes the routing easier.
putting compiled things into a jar just seems wrong to me since you now have to restart the server process if you want to update the JS/CSS
all the stuff inside the box is developed in the library project, with a dev-only web server and repls and whatnot
https://github.com/magnars/prone is a good example of how we’re working
means we can run this feature set on any of our web visible services. untangling capability from location.
@thheller, just confirming shadow does nothing to install npm deps - you have to do that yourself, right?
unless the library you are using properly declares :npm-deps
via deps.cljs
yes, you have to do npm install
is that the consuming library or the consumed library? i guess i should include a package.json with all of these?
{:draft-js "0.10.4"
:draft-js-export-html "1.2.0"
:immutable "3.7.4"
:react "15.6.2"
:react-dom "15.6.2"}
this is my cljsbuild map 🙂
i’ll sort, thanks
@thheller I want to start the build in my nrepl(launched by cider), compile cljs and run clj code in same jvm. is it supported now? didn't found any guide for this.
@doglooksgood see the example @mitchelkuijpers pasted a couple minutes ago. shadow-server
is the shadow.cljs.devtools.server
ns. shadow
is shadow.cljs.devtools.api
(require '[shadow.cljs.devtools.server :as shadow]
'[shadow.cljs.devtools.api :as shadow-api])
(shadow/start!)
(shadow-api/watch :app)
I’ll work on the embedding section of the docs, seems like a lot of people want to do this.
fixed thanks
@mitchelkuijpers has done that for cider I believe. I do not know how you’d setup the middleware with cider.
thanks for the help today!
you need these 3 https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/server/nrepl.clj#L233-L235
eg. shadow.cljs.devtools.server.nrepl/cljs-select
needs to be in your nrepl middleware
I recommend using the standalone version which you can cider-connect
to. It does all the complicated setup so you don’t have to.
I will send you the middleware @robert-stuttaford but I am currently out for lunch
@mitchelkuijpers @doglooksgood asked for the nrepl stuff but send it to me as well please
I saw your shadow-cljsjs
project that provide replacements for cljsjs. but the react version is likely use the dev version?
the watch
and compile
will use the dev version, release will use the release version
they really don’t seem to expect that someone processes the dev version and doesn’t just use it as they shipped it
the dev version does a whole bunch of extra checks to validate you are using everything correctly. most of the time that is useful.
{:resolve {"react" {:target :npm :require "react/cjs/react.production.min.js"}}}
(for react v16)
create a repo to record how to do this. https://github.com/DogLooksGood/shadow-cljs-lein-cider-config
:repl-options {:init-ns user
:nrepl-middleware [;; provided by fake-piggieback, only because tools expect piggieback
cemerick.piggieback/wrap-cljs-repl
;; cljs support
shadow.cljs.devtools.server.nrepl/cljs-load-file
shadow.cljs.devtools.server.nrepl/cljs-eval
shadow.cljs.devtools.server.nrepl/cljs-select]}}}
what's the best way of building a jar that includes both some backend clojure code (built via the usual lein compile & uberjar) and ideally some shadowcljs-built frontend code?
maybe some sort of first-step build to put things under resources/, and then do the lein build?
shadow-cljs does not yet support building jars so yeah generate the code into some path that is preferably not on the classpath
then run lein to generate the jar (can use a profile to add the path to :resource-paths
)
better yet don’t put .js
files in .jar
. instead serve them directly from a directory if possible. otherwise you’ll need to restart the JVM process every time you want to update the .js
.