This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-19
Channels
- # beginners (59)
- # calva (20)
- # cider (25)
- # clj-kondo (12)
- # cljdoc (3)
- # cljsrn (15)
- # clojure (104)
- # clojure-europe (4)
- # clojure-italy (10)
- # clojure-nl (3)
- # clojure-spec (14)
- # clojure-uk (13)
- # clojurescript (33)
- # code-reviews (26)
- # core-async (1)
- # cursive (5)
- # data-science (3)
- # datomic (8)
- # emacs (3)
- # fulcro (5)
- # graphql (3)
- # hoplon (1)
- # jobs-discuss (4)
- # kaocha (14)
- # nyc (1)
- # off-topic (33)
- # pathom (4)
- # pedestal (2)
- # quil (1)
- # re-frame (5)
- # reagent (10)
- # reitit (6)
- # rewrite-clj (3)
- # shadow-cljs (173)
- # specter (7)
- # sql (4)
- # vim (58)
- # yada (3)
Hey all. When spec'ing functions, where do you call instrument
in your dev environments?
Especially so that stuff is re-instrumented when something changes.
@thheller Is there way to use this https://www.npmjs.com/package/webpack-bundle-analyzer with shadow-cljs or with regular cljs compilation?
@karol.wojcik why would you if you can use https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report
it was one of the principal driving factors for us having just moved to shadow
Is that report built after advanced compilation?
Very cool.
@thheller If I have a macro and a ^:dynamic
variable used for some initial setup. how can I change this variable and make sure it happen before macro expansion.
will put it before the macro usage work?
hmm, sorry for my bad explain.
assume I have a macro alert
and a variblae *should-alert*
If I set should-alert to false, alert macro will expand to nothing. If I set should-alert to true, alert macro will expand to something.
do you want to control this via build config or how did actually set *should-alert*
?
Anyone able to get this to work with shadow? https://github.com/Engelberg/better-cond
For me it says failed to require macro-ns "better-cond.core"
yes but how did you set it? or how do you want to set it? build config a good place?
@doglooksgood I need to complete example to be able to make any recommendations. I do not yet understand what you are trying to do.
@thheller Here is the whole error: https://gist.github.com/isaksky/eb18e32a33ceab2b619957b055187ecd
> FileNotFoundException: Could not locate better_cond/core__init.class, better_cond/core.clj or better_cond/core.cljc on classpath
I want use macro to generate CSS string, one thing I have to deal with is vendors
.
I want configure which vendor used on which property.
did you properly restart the shadow-cljs server instance after adding the dependency?
@doglooksgood what you are trying to do is a really really really bad idea and will essentially require that cache is entirely disabled
I just added [better-cond "2.1.0"]
to shadow-cljs.edn :dependencies
, like the rest of them
$ shadow-cljs clj-repl shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn cli version: 2.8.50 node: v10.13.0
shadow-cljs - connected to server
shadow-cljs - REPL - see (help)
To quit, type: :repl/quit
[6:0]~shadow.user=>
It said this for me:
$ /mnt/c/src/xportal/assets/node_modules/.bin/shadow-cljs clj-repl shadow-cljs - config: /mnt/c/src/xportal/assets/shadow-cljs.edn cli version: 2.8.41 node: v11.13.0 shadow-cljs - server version: 2.8.41 running at shadow-cljs - nREPL server started on port 55813 shadow-cljs - REPL - see (help) To quit, type: :repl/quit
yes, I know, it is side effects. so I want a side effects free way to achieve this. there's only one another way I know is let user define a new macro, with some options passed in.
@isak and you added the dependencies properly to /mnt/c/src/xportal/assets/shadow-cljs.edn
?
@doglooksgood the only way I can recommend right now is moving that data into the build config
yea it was correct. But now I just for run re-arranged it in the dependency list, and now i'm not getting that error - strange
you can get that in the macro via (get-in @cljs.env/*compiler* [:options :external-config :mcss])
it is not a great solution but any change to :external-config
will invalidate the cache so at least recompiles will happen
where can found some doc for this? you mean even I change the build config, a recompile will happen?
but yes shadow-cljs is setup to recognize changes in :compiler-options
and trigger recompiles accordingly
doing side-effect in macros is still bad though. you could maybe build something on top build hooks https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks
I gotta go right now. I'll be back in about 2 hours. maybe we can continue then if you still need help
@thheller I found another way, don't know if it is good or not. If put those default configuration in a file mcss.defaults.clj
, and let user provides an overwrite version if he wants. is it a good idea? since shadow support this.
Is there a way of excluding shadow-cljs itself when generating the pom.xml
file with shadow-cljs pom
? (apart from mangling the resulting xml with xquery or something)
it is only meant as a helper for tools like Cursive since it can't import shadow-cljs.edn projects
So my strategy is currently to 1. create a pom 2. install deps via maven 3. generate a class path with maven 4. using that classpath with lumo
Yeah, maybe you’re right. I guess the reason I’m using pom.xml in the first place is because of Cursive
I'm trying out shadow-cljs on a new project at work, and with bootstrapped cljs repl, I get intermittent errors when loading the page that only occur if we're including the bootstrap repl functionality. It looks like "sometimes" things are being loaded twice, which results in an avalanche of errors from goog.provide (I think). Does anyone have any pointers on how you would debug this ? I've compared to example projects and don't quite see what I am doing that would cause this.
did you follow https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html?
@thheller Yes, I believe I followed that. I will review the code now to verify it. What I mean when I say "bootstrap repl functionality" is that if I leave the build as-is but remove references to my repl namespace (which requires cljs.js), the errors seem to disappear.
I will go review that article you presented now and compare to my project - back shortly.
@thheller Yes, I realize that. I'm just saying, the errors are particular to that NS being included. I have no idea what causes them. This hasn't happened in previous things I've done using cljsbuild instead of shadow-cljs. I'm just trying to get it resolved. So to answer your previous question, our code does follow that article - I found a couple differences (we were initializing our compiler state to an empty state instead of the default state as you did) , and we were passing some namespaces to load-in-init in the configuration for the init
call, but changing these things doesn't seem to result in anything different than what I am seeing. It is a bit challenging to evaluate because it does not happen on every reload - sometimes it doesn't even happen for many reloads.
At this point, I've thought I fixed it multiple times, due to this intermittency, but it always seems to come back.
if that is included the necessary data is added for self-hosted support for the build
How would I have a repl without including cljs.js ? It depends on what you mean by 'including' I suppose ?
I have a namespace, let's say it's called "repl" - that namepace has a require (as your example also does) which includes things like cljs.js, cljs.env, tools.reader, etc. This namespace implements a graphical repl (using reagent) which calls "eval-str" to implement a repl.
In a manner that as far I can tell is identical to: https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html
(when I say it to identical to your example, I only meant insofar as how it calls eval)
kind of yes. but my example USES the cljs.js
namespace. so would you want to NOT include it?
I need to include it. If I include it, hundreds of errors spew intermittently upon reloading my page.
I only mentioned removing it (ie, commenting out requiring cljs.js and code that calls eval) to say that under those conditions, the errors don't occur (but of course my app doesn't "work" because those features have to be disabled).
ok. to make it clear if you remove that require things WILL break. so don't remove it and lets stop talking about that.
I am not sure how to answer what I am loading. I am not evaluating anything by default at all. The page is a reagent page with a few buttons on it and nothing terribly interesting happening by default.
I am asuming that you have a build config with a :modules {:whatever { ...}}}
and then loading the generated whatever.js
file in the browser?
Main in this case essentially does some loading of external resources (via http calls) and once that stuff is done, it calls this fn as its last thing:
(defn render-app
[]
(let [app (.getElementById js/document "app")]
(r/render [home-page] app)))
The errors happen part-way through initialization as far as I can tell - they start spewing almost immediately upon page reload, and there are hundreds of them.
it is NOT safe you use anything before that has completed its work and the callback was called
My callback doesn't happen to do anything there - but I'm not calling eval-str by the time these errors occur anyway.
Is that what you mean, that I should ensure no one can be calling eval until the init-cb occurs ? I can do that work but that isn't what is happening regardless.
The intermittency is what is confusing - I am trying to force it to happen now by reloading over and over but at the moment I can't get it to occur.
I can only guess what is happening. what you are describing sounds like things are initialized multiple times
The load errors are a signal (since they are provide complaining) but I can verify that it is definitely loading namespaces multiple times when it occurs.
move your <script src="/js/main.js">
to the bottom of your page right above your </body>
What's the alternative to that main call, since loading the script itself doesn't launch the app ?
(what I mean is, it's not like there is a call to (main) at the end of some ns or something)
that at least ensures that part of the code is all loaded in the correct order and initialized correctly
I wonder if I can add some debugging code to dump a stack on load to try to see where the two calls would be originating from.
For the time being, I will commit the changes you suggested about how I invoke main - thank you for that.
When it occurs it again (assuming it does), I will see if I can diagnose using the network info from devtools.