Fork me on GitHub

is it possible to change the red colour that shadow prints in a cider emacs buffer to something else?


It seems that source maps are not used by the browser if I create a release build with :compiler-options {:source-map true}. Meanwhile, they are used with watch. Did I not add some flag?

Ivan Koz15:02:29

If anybody using shadow-cljs with the Cursive, how do you connect to cljs watcher repl? Currently i'm calling (shadow.cljs.devtools.api/repl :app) manually, any better way to do it?


@robert-stuttaford color should be disabled if you are connected over nrepl? otherwise you may (alter-var-root!*color* (constantly false)).


seems it's not the warnings, but the top-level status


i tried the alter-var-root, it had no effect


i'm using cider-connect-clj&cljs to connect to shadow's nrepl service


uhm yeah that is not shadow-cljs making that red


that is never red


ok, thanks! i'll dig in cider!


@p-himik should work fine? what do you mean by "not used"?


If I use shadow-cljs watch and trigger an exception in the browser, the stacktrace shows correct CLJS files, and I can open them in the browser. If I use shadow-cljs release, the stacktrace shows minified files. Of course, I cannot use shadow-cljs built-in debug server for this (I think), so I use python -m http.server in the directory with index.html.


all that matters is that the .map file is created and that the .js file has a //# sourceMappingUrl ... at the bottom


beyond that I don't what would be different


Yes, the .map is there. And the sourceMappingUrl is there as well. In fact, the Python server shows that the source map is downloaded by the browser. But it's not used for some reason.


in the chrome devtools sources tab


it should show the original sources somewhere?


maybe you are somewhere in the code it can't map. don't really know what you are doing


normally source map coverage should be pretty good though


Yes, Chrome shows the CLJS sources there. I just throw an error when I click a button. With the release build, it results in this in the JS console:

Uncaught Error: Button clicked
    at main.js:593
    at Object.da (react-dom.production.min.js:17)
    at Oa (react-dom.production.min.js:18)
    at ub (react-dom.production.min.js:18)
    at wa (react-dom.production.min.js:18)
    at vb (react-dom.production.min.js:20)
    at O (react-dom.production.min.js:20)
    at P (react-dom.production.min.js:20)
    at Mi (react-dom.production.min.js:82)
    at ig (react-dom.production.min.js:289)
With the debug build, it results in the correct core.cljs file being mentioned with the correct line.


The app itself is the smallest one created from that uses the latest version of shadow-cljs and updated React stuff.


And I'm pretty sure that the source map itself is just fine because: 1. There's no warning about it being malformed 2. I can see the original CLJS files in DevTools but I don't see any requests for them Do you have any idea why the source map is still not used for the stacktraces? Do you need anything from me to aid you?


I really can't do anything if the trace is that deep in react


in release the minified react version is used. react doesn't ship source maps so there is no possibility of mapping it back


But how would React affect my source code? I just removed React from the equation by just throwing an exception straight in the start function - same deal.


Notice how it says main.js in the exception printout.


ah yeah I can explain that


but that has nothing to do with your actual error ...


I'm assuming you are calling the init via :init-fn


that call itself has no source map


and closure inlines it so init no longer exists and just directly throws at the top level


And yet again, it's not that. :(



It's still that example from your repo. :)


I'm not sure what you are aftter


the init-fn call NEVER has source maps


and if init just calls start then closure will inline that so there no longer is a start


and adding an exported function really doesn't matter there at all


I do not use init-fn.


That script tag above works. Meaning, the ^:export works. Meaning, the core/init function is not inlined anywhere.


Then how is it being called from the HTML file?


you are misunderstanding how this works. look at the bottom of the JS file how exports are created


basically it'll have inline the body of start into init


and then bound the resulting funciton to the "exported" name


I have replaced (start) with just the exception. This is what I have in CLJS:

(defn ^:export init []
  (throw (js/Error. "Hi there")))
And this is what it ends up as in the compiled JS:
function Xf() {
    throw Error("Hi there");


what exactly are you looking for? that react error from previously isn't anywhere near what you are looking at now


But that's the whole problem, there's nothing I haven't described. I have the above code. In the debug mode, DevTools matches it with the source map. In the release mode, it does not - that is the problem.


no your example is too simplistic


do something that actually survives advanced optimizations and isn't inlined


also don't throw in init ...


even a setTimeout helps


The exact same issue with setTimeout.


do more stuff .. thats all I can say. add an event listener to body that after the fifth click throws or something


something that actually involves running code that is NOT react and NOT in init


That worked. Well, to some extent - it said that I had an error somewhere deep in cljs.core. But that's definitely not the case.


The code:

(defn do-bad-stuff [stuff]
  (throw (js/Error. stuff)))

(defn ^:export init []
  (.setTimeout js/window #(do-bad-stuff "From setTimeout 0") 0)
  (.setTimeout js/window #(do-bad-stuff "From setTimeout 100") 100))


but still inlined 😛


God dammit... :)


easy way to escape inline is multi methods 😛


Or self-referencing, it seems.


So now I have this

(defn do-bad-stuff [delay]
  (.setTimeout js/window #(do-bad-stuff (+ delay 1000)) delay)
  (throw (js/Error. delay)))

(defn ^:export init []
  (do-bad-stuff 0))
compiled as this
var ca = function ca(a) {
    window.setTimeout(function () {
        var c = a + 1E3;
        return ca.a ? ca.a(c) :, c)
    }, a);
    throw Error(a);

function ia() {
    return ca(0)
and outputting this
Uncaught Error: 0
    at ca (main.js:4821)
    at Object.ia [as init] (main.js:4825)
    at (index):14
So it somehow became worse.


uhm thats still throwing in init ...


The subsequent throws that happen asynchronously have the exact same message.


A new iteration:

(defn do-bad-stuff [delay]
  (.setTimeout js/window
               (fn []
                 (do-bad-stuff (+ delay 1000))
                 (throw (js/Error. delay)))

(defn ^:export init []
  (do-bad-stuff 0))
var ca = function ca(a) {
    return window.setTimeout(function () {
        var c = a + 1E3;
        ca.a ? ca.a(c) :, c);
        throw Error(a);
    }, a)

function ia() {
    return ca(0)
Uncaught Error: 0
    at core.cljs:10374


So: - Not inlined - Not throwing in init - Still wrong location


@nxtk that is currently the only way. you can create a custom REPL command and bind it to a key to make it "easier"

Ivan Koz15:02:37

good idea, ty

Ivan Koz16:02:04

can shadow-cljs refresh page, reconnect when connection was closed?

Wilson Velez18:02:33

Hi, I’m implementing a reframe app with highcharts.js, one the options the library has is to show a message when there are no data to draw,, but for it to works it need to include a js file, the file is inside the npm module (highcharts/modules/no-data-to-display.js), righ now I’m requiring

["highcharts/highstock" :as Highcharts]
["highcharts-react-official" :default HighchartsReact]
and it works fine, but without the no data label, how should I include this file?

Wilson Velez18:02:42

when I include the name as

I get > Compilation failed! > The required JS dependency “highcharts/module/no-data-to-display” is not available, it was required by “fund_performance/stockchart.cljs”. > > Search in: > /Users/wvelezva/dev/workspace/fund-performance/node_modules > You probably need to run: > npm install highcharts/module/no-data-to-display > > See:


You have a typo, it should be "modules".

Wilson Velez18:02:50

thanks, now I don’t have the message but it doesn’t show the no data message

Wilson Velez18:02:04

so, the way I’m including the file is fine?


Since it doesn't complain anymore, it should be fine, yes. > The actual text to display is set in the lang.noData option Did you set the option?

Wilson Velez18:02:21

this is all the configuration I’m using

{:credits {:enabled false}
   :title ""
   :rangeSelector {:buttonPosition {:x -200}} ;;to hide the zoom buttons but letting the input dates visible
   :legend {:enabled true}
   :lang {:noData "There are no data to display or there are any Fund Selected"}
   :noData {:style {:fontWeight "bold"
                    :fontSize "15px"
                    :color "#303030"}}
   :plotOptions {:series {:showInLegend true
                          :events {:click #(.log js/console (str "p= " (.. % -point -x) " sn=" (.. % -point -series -name)))}}}
   :tooltip {:pointFormat "{}: <b>{point.y:.1f}%</b>"}
   :series [{:type "line"
             :name "Random data"
             :data []}]}

Wilson Velez18:02:36

:lang {:noData "There are no data to display or there are any Fund Selected"}


No idea. If you convert this structure to JS recursively (i.e. with something like clj->js), then it looks fine to me. Does your data work in a pure JS environment?

Wilson Velez15:02:19

Hi @p-himik, sorry for the delay (family calls) 🙂, and thanks for your help, I created this fiddle, locally it also works


> locally it also works You mean, you got it working after all, so the case is closed?

Wilson Velez15:02:51

no, plain js works


Can you create a CLJS project on GitHub that has everything that you need and that looks just like that JS that works? So I could check it out and maybe see what's wrong.

Wilson Velez15:02:50

I don’t want to abuse your help, I hope this isn’t too much trouble for you


That's why I don't try to create the project myself. :)


But if you create it, I can look.

Wilson Velez16:02:29

sorry it take me too long, I’m not used to work with github


Don't sweat it, I'm not just sitting and waiting. :)


An advice about Git - don't push before you check the contents of the commits. If you seen something out of place (like committed compiler cache), just amend the required commit, maybe with interactive rebase. And only then push. This way, it won't end up in the history. Right now, for example, Git had to download almost 10k files because of this. But the actual source code is just a few.

Wilson Velez16:02:40

yes, I know, my bad


Got it working.

Wilson Velez17:02:00

what was my problem?


I figured it out from the source code of the no-data module, but turns out that there's also documentation for this:


Notice how they load modules.


It's not just a require or import. The also call the imported function on the Highcharts object.


You just need the replace the no-data require with this: ["highcharts/modules/no-data-to-display" :as no-data-module] And call (no-data-module Highcharts) somewhere at the top level or in init.

Wilson Velez17:02:17

yes, I noticed that but it was complete “chinese” to me

Wilson Velez17:02:09

I really know very little about modules, commonjs and the others

Wilson Velez17:02:41

I didn’t know it was a function I thought it was some kind of import


Heh, yeah, the proliferation of the ways to require JS stuff in the JS world makes it a swamp I dare not to venture into. That's why most of the time I just look at the compiled output and try to understand what's going on, while also debugging it in the browser.

Wilson Velez17:02:46

I don’t know how to thank you!


No problem. :)

Wilson Velez17:02:47

so this line makes two things


Wilson Velez17:02:52

one is the require

Wilson Velez17:02:24

the other is call the “module” function over the Highchart object

Wilson Velez17:02:50

module being, exporting or no-display-to-data in my case