Fork me on GitHub

(defn parse-dtime
([parser stime]
    [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


So for every cljs file shadow-cljs generates a .js file, but the file is not affected by annotations, where are all externs written?


.shadow-cljs/builds/<build-id>/release/shadow.externs.js or so


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

 (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


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!


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 : Unexpected token < in JSON at position 0
which suggests it’s looking at js instead


that is controlled by :asset-path

thanks3 3