Fork me on GitHub
#clojurescript
<
2022-05-11
>
ns00:05:36

Hello, I have a question about debugging release build. So I deployed my app to server and I'm running into an error there which isn't present on my local dev build. My problem is that I have no idea how to go about debugging it on the server, mainly due to the fact that the build is minified, there is no source maps, there is no re-frame-10x, etc. you get the point. I'm wondering if someone can give me some pointers on how to build a version that I can deploy to server without all these limitations. I'm using Shadow Cljs, if that helps. Thanks!

thheller06:05:33

@nedim you can run shadow-cljs release app --debug or shadow-cljs release app --pseudo-names. first is pseudo-names + source maps, second is just pseudo-names. both make debugging much easier

thheller06:05:06

or just :compiler-options {:source-map true} in the build config to enable source maps in general for your release build

thheller06:05:07

and I recommend just doing a release build locally and work on it there. no need for it to go to actual production server with what is likely an externs issue

👆 2
ns18:05:32

@U05224H0W Perfect, thank you so much!

augustl08:05:50

seconding pseudo names! It turns the names from obscure minified names like fA and b to $myapp$mything$$.actualFunctionName$. The dollar signs indicates that it's a name that would be minified when you run without pseudo names. Then you at least have some idea about what part of the code that fails 🙂

👍 2
popeye15:05:40

I have a data like below

[{:person-name "john"
    :person-id 1234
    :person-address "Holand"}
    {:person-name "hari"
    :person-id 3456
    :person-address "NY"}] , how can I print the values like 

   person-name person-id  person-address
   "John"       1234       "Holand"
   "hari"       3456      "NY"

p-himik15:05:21

Is this acceptable?

(clojure.pprint/print-table [{:person-name    "john"
                              :person-id      1234
                              :person-address "Holand"}
                             {:person-name    "hari"
                              :person-id      3456
                              :person-address "NY"}])

| :person-name | :person-id | :person-address |
|--------------+------------+-----------------|
|         john |       1234 |          Holand |
|         hari |       3456 |              NY |

popeye16:05:25

but this will print in console not on page

p-himik16:05:59

This will print into *out* which you can rebind with binding or with-out-str.

p-himik16:05:18

Ah, it's CLJS not CLJ - so it will be *print-fn* and not *out*. But same principle.

augustl19:05:17

@U01J3DB39R6 seems like map-ing over the vector would work. Or do you want to print the column names dynamically based on the map keys?

popeye05:05:16

I wrote it using [:table , and it worked well 🙂

🎉 1
James Amberger18:05:35

no string/format in cljs?

p-himik18:05:39

To be fair, there's no string/format in CLJ either. But I guess you meant just format, from clojure.core. :) And yeah, it doesn't exist in CLJS. But there's goog.string.format.

James Amberger19:05:02

Thank you, I think you probably saved me at least an hour on those details.

👍 1
dvingo20:05:29

cl-format is also in cljs https://cljs.github.io/api/cljs.pprint/#cl-format (but pretty heavy on the code bundle size)