hey there - I'm trying to understand what's happening with *print-fn*
such that if I print something from a function in the browser, I'll see that output in my repl. I can see that *print-fn*
appears to be bound to the same thing (?) in both the client and the repl, but the behaviour diverges.
repl-print-fn
it seems.. although I guess that's just the var
I couldn't see anything in the docs about repl output too
if I (prn :foo)
from a connected repl, I see the output in the repl and the browser console, but if I do the same thing from a function (eg reagent component), then i only see it in the console.
shadow-cljs does not capture arbitrary prints outside the nREPL evaluation. pretty sure no CLJS REPL does
Hello 👋 Is it expected that release
build won't write into location specified in {:release {:output-to "..."}}
?
actually this is more or less a problem with nrepl and the nrepl clients
if you use the plain shadow-cljs cljs-repl app
then those prints should be captured
it is just an artifact of most nrepl clients not accepting output that is not tied to a specific evaluation
shadow-cljs does capture the prints, it just has nowhere to send them in case of nrepl
depends. which :target
are you talking about? :output-to
for example is not an option for :browser
:target :browser
that should be :output-dir
then
ah, so there's no way to specify output-dir per module?
no, it is by design that all :modules
should live in the same directory. otherwise complicates things with loader and source maps and so on
got it :thumbsup: what about compiler namespaces, are they written into :output-dir
as well when running release
?
no, in case you mean the cljs-runtime
dir you otherwise get with watch
or compile
output
perfect! thanks 🙏
btw, are there any docs on how shadow bundles NPM deps? is it using own bundler? does it split npm deps together with cljs splits?
yes, yes, yes
https://code.thheller.com/blog/shadow-cljs/2018/06/15/why-not-webpack.html has some background info on how things work
some other posts also talk about it
thanks! I have some more questions if you don't mind: what about DCE? does it exist, is it on par or better than webpack? what happens with NPM deps when compiling with advanced optimizations?
for npm dependencies it does not exist no, they only go through :simple
I might add it at some point but currently everything is pretty webpack specific so even other JS bundlers struggle with it
I see. So how's JS deps are included into cljs splits then? Does shadow splits NPM deps into modules based on requrie's from cljs code and then prepends JS splits to CLJS ones?
basically yes
but its file based not module based, so even if they are in the same package they might end up in different modules depends on how you use them
https://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html
cool! thanks :thumbsup:
does anyone know of a reference architecture/starter kit for clojurescript that has typescript interop? Would this be interesting to anyone?
thanks @thheller
and yep, i'm using an nrepl
some kind of plumbing for a connected build would be pretty neat, getting prints back from the client
I got to code splitting and hitting an issue now: goog is not defined
the setup is simple: there's module A and module B that depends on A, when A is loading the exception is thrown
should mention it happens in release build with advanced optimizations
the line where it fails is goog=goog||{}
which I guess comes from goog's base.js
hmm? advanced shouldn't contain this?
hmm, good point, might be something coming from a library, let me see, thanks
here's code block around that line compiled with :pseudo-names true
$APP.$JSCompiler_stubMap$$ = [];
goog = goog || {};
$goog$global$$ = this || self;
$goog$NONCE_PATTERN_$$ = /^[\w+/_-]+[=]{0,2}$/;
$goog$cspNonce_$$ = null;
$goog$UID_PROPERTY_$$ = "closure_uid_" + (1E9 * Math.random() >>> 0);
$goog$uidCounter_$$ = 0;
$APP.$goog$now$$ = Date.now || function() {
return +new Date
}
;
$goog$evalWorksForGlobals_$$ = null;
$APP.$goog$inherits$$($goog$debug$Error$$, Error);
is that something that shouldn't be there after advanced?
not a clue where this is from. it shouldn't be there.
which versions do you use? make sure it all matches properly. using mismatched closure compiler, CLJS or shadow-cljs versions causes all sorts of weird issues
shadow 2.10.21 cljs 1.10.773
in a regular build it should be something like var da=da||{}
or pseudo-named var $goog$$ = $goog$$ || {}
huh, actually I'm building using shadow from NPM of one version and requiring shadow's loader, which is coming from shadow of another version declared in deps.edn, should fix that as well
yeah those should be somewhat close but only the deps.edn version is really relevant
npm stuff only affects the shadow-cljs
command line tools, nothing from the compilation