(defn parse-dtime
([parser stime]
(let
[d (js/Date. 0 0 0 0 0 0 0)
n (.strictParse parser stime d
--------------^-----------------------------------------------------------------
Cannot infer target type in expression (. parser strictParse stime d)
How to tell compiler, that parser is instance of goog.i18n.DateTimeParse. DateTimeParse.strictParse is from goog library and is renamed during advanced compilation.Try to switch [parser stime]
to [^js parser stime]
. Does that work?
if its safe to rename you can do [^goog parser stime]
. ^js
is fine too but prevents the renaming
Thanks, code is compiled without errors and it is working properly. But I don't understand a shadow-cljs and compiler's magic powers ^js => strictParse is not renamed, and there is a code strictParse = function(a, b, c) # how compiler knows that strictParse must be exposed, what happens when there are more classes with strictParse? how compiler ^goog.i18n.DateTimeParse, ^goog => in both cases, result is the same, method is renamed and it works properly. I just don't get it how ^goog provides enough information
^goog
just tells externs inference that it does NOT need to collect externs for this and as such the closure compiler is free to rename it
^js
creates externs for strictParse
and as such closure will not rename it
completely fine to just use ^js
since the code size difference will be so tiny it won't matter
I know about the size, I just want to understand my code. the renaming must happen on two places in my code and in the google library. So compiler will rename all strictParse (marked as renamable) globally, not case by case, so ^goog means all "attachments - properties, methods" of this object. This is undocumented feature?
no you misunderstand how :advanced
optimizations and externs work
the CLJS compiler generates identical code with ^js
or ^goog
. it does not affect the generated JS at all.
externs then control whether the closure compiler is allowed to rename something or not. the CLJS compiler is out of the picture at that time.
so as far as the closure compiler is concerned there is no such thing as the closure library or CLJS code. it just sees a bunch of JS code
and the renaming it does is documented, just not sure where
hello! pretty new to cljs: for browser
target I tried to eval a quoted code list into Clojurescript runtime. while cljs.js/eval works with simple things like [1 2 3
, anything that needs core NS stuff will tell me they are undefine with warning: i.e
(cjs/eval
(cjs/empty-state)
(parse-string "(cljs.core/println \"ehhlo bootstrapped\")")
{:eval cjs/js-eval
:source-map true
:context :expr}
(fn [r] r))
but if I choose browser
target, start the browser, connect to cljs-repl, and change to bootstrap
target midflight, it works .
If I choose bootstrap
target, browser fails to connect to my cljs-repl;
Can I just use browser
or bootstrap
target instead of the mid-flight switch hack to make it work?if you want to do self-hosted stuff you need to do the setup described here https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html
don't know what kind of hackery you are trying but browser+bootstrap are supposed to be 2 separate builds. it does not work otherwise.
ah, I see, they are meant to be separated and call in certain orders. That’s probably why my hack kinda work. Thanks!
So for every cljs file shadow-cljs generates a .js file, but the file is not affected by annotations, where are all externs written?
is source map path hardcoded? I set my output-dir
to be out
and I am getting
DevTools failed to load SourceMap: Could not parse content for <http://127.0.0.1:8080/js/cljs-runtime/goog.dom.nodetype.js.map>: Unexpected token < in JSON at position 0
which suggests it’s looking at js
instead.shadow-cljs/builds/<build-id>/release/shadow.externs.js
or so
that is controlled by :asset-path