This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-07
Channels
- # adventofcode (62)
- # babashka (88)
- # beginners (52)
- # boot (2)
- # bristol-clojurians (1)
- # calva (7)
- # cider (15)
- # circleci (4)
- # clj-kondo (12)
- # cljdoc (5)
- # cljsrn (4)
- # clojure (53)
- # clojure-dev (1)
- # clojure-spec (7)
- # clojure-uk (7)
- # clojurescript (25)
- # core-async (14)
- # duct (1)
- # emacs (10)
- # figwheel-main (3)
- # fulcro (11)
- # garden (14)
- # jobs (1)
- # klipse (2)
- # luminus (1)
- # malli (9)
- # re-frame (6)
- # reagent (13)
- # remote-jobs (1)
- # shadow-cljs (124)
- # sql (1)
- # testing (15)
- # tools-deps (13)
- # uncomplicate (1)
- # vim (1)
Still hoping I'll get away without getting into the details of shadow-cljs, so here is one more ... 😉
shadow-cljs
compile
/`watch`give me a somewhat huge (12MB) module. That appears a bit odd for :none
optimization. However, the cljs-runtime folder is 25MB and looks expected to me. Guess it all still somehow makes sense and there may be some desired redundancy. Could anyone please briefly explain how come the module may get that big?
Maybe this will help: https://shadow-cljs.github.io/docs/UsersGuide.html#_build_report
If you don't use all that code, there's definitely some tight coupling that prevents it from being DCE'ed. Also multimethods in libraries that are imported but not used prevent DCE. Maybe some other things I'm not aware of.
Just looking at compile
/ watch
so I assume this is :none
and hence, no DCE involved. The release
build appears fine and just as expected. Will check build-report.
@U06FLL69W see https://clojureverse.org/t/improving-initial-load-time-for-browser-builds-during-development/2518
that has since become the default. if you'd rather use the "old" style of loading many separate files you can set :devtools {:loader-mode :script}
@thheller Somehow felt that what I see is working as intended. And loading the "big" bundle is indeed fast - likely faster than loading hundreds of small files. Thanks for clarification.
its easy to test out. just add the config bit I posted to the build while watch is running an reload the page
see what feels best 😛 it kinda depends on how many files you load. if you use the built-in http server and enable caching both variants are pretty close on fast desktops
Hehe, was pleasantly surprised to see shadow watching build configuration as well. 😃 And :loader-mode :script
indeed changes the size of the module as you pointed out. Again, thanks.
I think I’ve got a minimal repro of @royalaid’s issue, https://github.com/mhuebert/repro-shadow-Symbol
yeah, in the non-minimal build, :output-wrapper
is necessary (setting to false causes some other error)
did they change the behavior of var
? I could have sworn this was supposed to work with var
. let
or const
wouldn't.
if I remove the second var $jscomp
it works fine but no clue how to get the closure compiler to do that
i have deja vu because I ran into this exact same var issue a few months ago but can’t remember the context
I did change the :output-wrapper
default to true
so if you didn't set that manually before you wouldn't run into this
AFK right now - but IIRC I tried a minimal reproduction of the above behavior and it doesn’t work. I can’t point to why (JavaScript scoping is weird) but in the issue I created, the workaround works.
I'll try to figure out what is going on exactly. should be easier given that I have a reproducible case now.
I made an experiment with just a global var and an iife, to see what can be done. Very easy to try things out.
@thheller if something is up with how var is working it might explain the spec issue I and BadAlgorithm see on github
yeah for some strange reason the code that should be setting up the start of the $cljs$spec$alpha$$
object just gives back
it exists because of this https://clojure.atlassian.net/projects/CLJS/issues/CLJS-3055
so then that still leaves the question as to why `
$cljs$spec$alpha$t_cljs$0spec$0alpha35496$$
is just defined and never assigned a value 😕make sure it isn't moved to the other file though. it is typical for the closure compiler to "forward declare" something and then actually declare it later
this isn't CLJS where you have to define stuff before you use it. so as long as its declared somewhere in the file it won't matter 😛
how do you load the modules? are you sure its in the correct order? and not using async
which would lead to race conditions? you can use defer
?
<script src="a.js" async>
<script src="b.js" async>
? this will load scripts in undefined order (based on whichever loads faster)
Hi! My self hosted clojure that uses shadow cljs broke after upgrading from 2.8.40 to 2.8.80. Now the self hosted engine does not load certain dependencies anymore. Right now it looks like anything that depends on react no longer loads.
@hoertlehner if you use deps.edn/project.clj I'm gonna guess its a closure-compiler/closure-library dependency conflict
defer isn’t an option as the init script for the app depends on the modules under it
you can set :js-options {:minimize-require false}
if you want to know what those numbers stand for
it doesn't change anything. it just gives you the long module name instead of a number
I can only repeat what I warned about many times before .. this stuff isn't built for what you are trying to use it for 😛
Hello,
I heard about shadow.cljs and slep on it for the longest time.
Started using it recently and I’m just so happy with it, that I’m
ranting and raving to everybody who’ll listen about how good it is!
Thank you Thomas (& contributors) for such a great tool.
One thing that I’ve stumbled upon, which now I can’t find a link to,
is a discussion that was had here on Slack at some point in the past,
when used with react-native project, with Android simulator, the REPL
connection just goes stale. The advice here was to run
repl-runtime-clear.
My question is: what is the recommended way to do it?
Bellow I’ll describe my setup and the approach, in some very obvious
details, just in case.
I use the REPL via CIDER with nREPL. In my shadow-cljs.edn
I have a
following setup:
...
:nrepl {:port 3333}
:builds
{:app
{:target :react-native
:init-fn
:output-dir "react-native/app"
:js-options {:js-package-dirs ["react-native/node_modules"]}
:devtools {:repl-init-ns
...
Once I start the REPL I specify shadow
as the REPL type and :app
as the build.
This starts the REPL and starts the build, which once complete goes in
the above specified ns
.
When the REPL goes stale, where I can’t even eval something like '2
,
I then do:
> :repl/quit
user> (require '[shadow.cljs.devtools.api])
user> (shadow.cljs.devtools.api/repl-runtime-clear)
user> (shadow.cljs.devtools.api/repl :app)
cljs.user>
At this point, I’ve recovered the REPL and can plough on as expected.
Is this the recommended flow to clear the stale REPL session?
If the answer is yes, what’s the way to create aliases that can be
picked up, so that I don’t have to manually type up the full
(require '[shadow.cljs.devtools.api])
? Say like in leiningen
projects where you can create dev/user.clj
file where you can have
the desired requires.
And another, minor thing, once I’ve done the above, the ns I’m in, as
shown by the prompt is cljs.user
. But as soon as I enter something
at the REPL, then the prompt changes to what I’ve set in my
:devtools {:repl-init-ns
config.
Is there a config that I could set so that the REPL prompt can be
updated automagically?
Thanks@dotemacs I wish that repl-runtime-clear
wasn't necessary at all but I haven't found a good way to solve that problem yet. your workflow seems fine. you can create a user.clj
if you want.
@thheller oh please don’t take it as criticism, I’m very grateful for your work on shadow.cljs!
About adding of user.clj
what is the recommended convention:
• apart from having src
under :source-paths
, would you create something like dev/user.clj
?
• or would you just put user.clj
under src
directory?
• or is there some other way?
What is the “shadow” way of doing it?
that has nothing to do with shadow-cljs really. its clojure doing this. I personally do not like using user.clj
since that is always loaded unconditionally.
you can put it under src or dev (as long as thats in :source-paths
too) it really doesn't matter
then you don't want to include your user.clj so I guess it is useful to stick with using dev
Hi all, it seems that a few people using latest luminus template including shadow-cljs are having a weird issue compiling a jar - IllegalArgumentException: No matching field found: getSourceName for class com.google.javascript.jscomp.JSError . I'm unsure how to proceed. Thanks!
@jcb that happens when an incompatible closure-compiler version is used. most likely via some dependency conflict. should be these versions
[com.google.javascript/closure-compiler-unshaded "v20191027"]
[org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]
[org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
Sorry, I realise that I'm asking questions about something that you didn't write, but, that stepped me forward but that's opened up a number of other build issues -
------ WARNING #1 - ----------------------------------------------------------- Resource: com/cognitect/transit.js:649:8 variable module is undeclared -------------------------------------------------------------------------------- ------ WARNING #2 - ----------------------------------------------------------- Resource: com/cognitect/transit/impl/writer.js:256:8 variable isObject is undeclared -------------------------------------------------------------------------------- nil Closure compilation failed with 62 errors --- goog/array/array.js:42 The result of a goog.define call must be assigned as an isolated statement. --- goog/array/array.js:50 The result of a goog.define call must be assigned as an isolated statement. --- goog/asserts/asserts.js:50 The result of a goog.define call must be assigned as an isolated statement. --- goog/async/run.js:26 The result of a goog.define call must be assigned as an isolated statement. --- goog/async/workqueue.js:43 The result of a goog.define call must be assigned as an isolated statement. --- remaining errors ommitted ...