<<
I tried setting a breakpoint on the offending line and stepping thru and
the same thing happened: I ended up in template.cljs at the end.
>>

correction:

I actually set the breakpoint on the line where the function with the
offending line is being called, not on the offending line itself as Chrome
kept removing the breakpoint when I put it next to the offending line
(right after I set it)

Visually:

(ns main.core
  (:require [reagent.core :as reagent :refer [atom]]
            [ajax.core :as ajax]))

(defn app-view []
*------> tried to put the break point right here but I guess I can't break
here as chrome kept removing it... the syntax is foreign to me still
so it **probably
makes sense*
   [:did.sample "..."])

*---> the next line is where the chrome web console shows the error
(without pause on exceptions being enabled) and if I set a break point here
I end up in template.cljs, and doesn't come back to the offending line
above *
(reagent/render-component [app-view] (.getElementById js/document "app"))

I'm sure all of this makes sense since this gets compiled to JS and if I
was to debug the JS then it would all make sense !


On Sun, Jan 25, 2015 at 5:46 PM, Marc Fawzi <[email protected]> wrote:

> Unfortunately, the exception is caught by Reagent not my cljs code and so
> enabling Pause on Caught Exceptions in Chrome takes me to template.cljs
> (which I'm assuming is part of the Reagent implementation)
>
> I tried setting a breakpoint on the offending line and stepping thru and
> the same thing happened: I ended up in template.cljs at the end.
>
> But source maps are heaven sent because at least I know where the bug is
> coming from even if it does not point to the offending line in the function
> being called (it points at the line where that function itself is being
> called)
>
> Having said that, I'm just curious now, not blocked or anything
>
> Love the clarity of the language/programming model
>
> On Sun, Jan 25, 2015 at 8:52 AM, David Nolen <[email protected]>
> wrote:
>
>> That's just how JavaScript error stack traces & source mapping works. If
>> you need to drill down then it's best to enable the exception catching mode
>> of the browser JavaScript debugger. When the error occurs you'll be taken
>> to the offending ClojureScript file. You can navigate the ClojureScript
>> source mapped stack using the standard debugging tools provided by the
>> browser.
>>
>> David
>>
>> On Sun, Jan 25, 2015 at 11:47 AM, Marc Fawzi <[email protected]>
>> wrote:
>>
>>> David,
>>>
>>> Thank you that worked like a charm!
>>>
>>> With source maps the only inconvenience it seems that it points to the
>>> line where the buggy function is being called, and not to the function's
>>> definition
>>>
>>> For example (sorry that this is a reagent sample, have yet to check out
>>> Om) I would expect it to point to  the line that reads:  [:did.sample
>>> ]) since there is no such HTML tag as 'did' ('div' is what it should be
>>> obviously) but the console error (when i click at the last entry in the
>>> call stack -- the one before it is in Reagent somewhere) it points to the
>>> line that reads: (reagent/render-component [app-view] (.getElementById
>>> js/document "app"))
>>>
>>> I suspect that either my brain is fried and that's how it works in
>>> regular JS or it's a general issue with source maps....
>>>
>>> (ns main.core
>>>   (:require [reagent.core :as reagent :refer [atom]]
>>>             [ajax.core :as ajax]))
>>>
>>> (defn app-view []
>>> [:did.sample ])
>>>
>>> (reagent/render-component [app-view] (.getElementById js/document "app"))
>>>
>>>
>>>
>>> On Sun, Jan 25, 2015 at 6:25 AM, David Nolen <[email protected]>
>>> wrote:
>>>
>>>> The :source-map option is in the project.clj he pasted.
>>>>
>>>> Marc if the source-map url is missing from the end of the file it
>>>> sounds like something went wrong with the compile. In these situations it's
>>>> best to run a clean and then re-build. Have you tried that?
>>>>
>>>> On Sun, Jan 25, 2015 at 9:08 AM, Moritz Ulrich <[email protected]>
>>>> wrote:
>>>>
>>>>> Marc Fawzi <[email protected]> writes:
>>>>>
>>>>> > I did some reading on enabling source maps for other languages (more
>>>>> > material exists for e.g. coffeescript) and I think the problem is
>>>>> that lein
>>>>> > cljsbuild is not adding that special comment to index.html to tell
>>>>> the
>>>>> > browser about the source map
>>>>> >
>>>>> > //# sourceMappingURL=/path/to/file.js.map
>>>>> >
>>>>> > in this case "dev/main/core.js.map"
>>>>> >
>>>>> > <!-- scripts and styles -->
>>>>> > <script src="http://fb.me/react-0.12.1.min.js";></script>
>>>>> > <script src="dev/goog/base.js" type="text/javascript"></script>
>>>>> > <script src="dev/app.js" type="text/javascript"></script>
>>>>> > <script type="text/javascript">goog.require("main.core");</script>
>>>>> >
>>>>> > But shouldn't goog.require be smart enough to add that? I have no
>>>>> idea
>>>>> > since I've never used goog.* or the Closure compiler
>>>>> >
>>>>> > It's it lein's job to put that special comment line or is it Google's
>>>>> > Closure's job? Or how does the line get added? We're definitely not
>>>>> sending
>>>>> > an X header for source maps, so we must have that special comment
>>>>> > (according to what I read)
>>>>> >
>>>>> > What am I missing here?
>>>>> >
>>>>> >
>>>>> > On Sat, Jan 24, 2015 at 4:31 PM, David Nolen <[email protected]>
>>>>> wrote:
>>>>> >
>>>>> >> Are you sure the source maps are accessible to the browser? You
>>>>> should see
>>>>> >> them getting loaded in the Network tab.
>>>>> >>
>>>>> >> David
>>>>> >>
>>>>> >> On Sat, Jan 24, 2015 at 7:20 PM, Marc Fawzi <[email protected]>
>>>>> wrote:
>>>>> >>
>>>>> >>>
>>>>> >>> at work, we've implemented a few features/pages in cljs without
>>>>> source
>>>>> >>> map support.. to me that's like using the force, but we know we
>>>>> will
>>>>> >>> eventually get stuck trying to fix a bug that we can't trace to
>>>>> the code
>>>>> >>> manually
>>>>> >>>
>>>>> >>> so we need source map support asap to smooth out the cljs adoption
>>>>> >>> process at our company
>>>>> >>>
>>>>> >>> the way we develop is by running "lein cljsbuild auto dev" and
>>>>> >>> refreshing the browser once we make changes (figwheel is on my
>>>>> list of
>>>>> >>> tools to investigate)
>>>>> >>>
>>>>> >>> anyway, the problem is with source maps
>>>>> >>>
>>>>> >>> We run node or python based web server to serve index.html (see
>>>>> below)
>>>>> >>> and we inherited this sample project.clj file
>>>>> >>>
>>>>> >>> (defproject CHANGE-ME-ME "0.1.0-SNAPSHOT"
>>>>> >>>   :description "CHANGE-ME"
>>>>> >>>   :url "https://CHANGE-ME";
>>>>> >>>   :dependencies [[org.clojure/clojure "1.6.0"]
>>>>> >>>                  [org.clojure/clojurescript "0.0-2280"]
>>>>> >>>                  [reagent "0.4.2"]
>>>>> >>>                  [cljs-ajax "0.2.6"]]
>>>>> >>>
>>>>> >>>   :plugins [[lein-environ "0.5.0"]
>>>>> >>>             [lein-cljsbuild "1.0.3"]]
>>>>> >>>
>>>>> >>>   :cljsbuild {:builds [{:id "dev"
>>>>> >>>                         :source-paths ["src"]
>>>>> >>>                         :compiler {:optimizations :none
>>>>> >>>                                    :output-to "public/dev/app.js"
>>>>> >>>                                    :output-dir "public/dev/"
>>>>> >>>                                    :source-map true}}
>>>>> >>>                        {:id "prod"
>>>>> >>>                         :source-paths ["src"]
>>>>> >>>                         :compiler {:optimizations :advanced
>>>>> >>>                                    :output-to "public/js/app.js"
>>>>> >>>                                    :pretty-print false}}
>>>>> >>>                        ]}
>>>>> >>>
>>>>> >>>   :min-lein-version "2.0.0")
>>>>> >>>
>>>>> >>> The index.html is
>>>>> >>>
>>>>> >>> <!DOCTYPE html>
>>>>> >>> <html>
>>>>> >>> <head>
>>>>> >>>     <META http-equiv="Content-Type" content="text/html;
>>>>> charset=UTF-8">
>>>>> >>>     <title>Reagent Starter Project</title>
>>>>> >>> </head>
>>>>> >>> <body>
>>>>> >>> <div class="container">
>>>>> >>>     <div id="app"></div>
>>>>> >>> </div>
>>>>> >>>
>>>>> >>> <!-- scripts and styles -->
>>>>> >>> <script src="http://fb.me/react-0.12.1.min.js";></script>
>>>>> >>> <script src="dev/goog/base.js" type="text/javascript"></script>
>>>>> >>> <script src="dev/app.js" type="text/javascript"></script>
>>>>> >>> <script type="text/javascript">goog.require("main.core");</script>
>>>>> >>> </body>
>>>>> >>> </html>
>>>>> >>>
>>>>> >>> I have not used anything but pure JS before so I'm not sure what
>>>>> to do to
>>>>> >>> get source maps working but as of now they are enabled in chrome
>>>>> but
>>>>> >>> exceptions are displayed in the console in cljs/reagent JS sources
>>>>> like
>>>>> >>> ratom.js and not in the cljs file
>>>>> >>>
>>>>> >>> I read the wiki on source maps and tried using source-map-path but
>>>>> that
>>>>> >>> didn't work
>>>>> >>>
>>>>> >>> does anyone have an example of source maps that works with a web
>>>>> server?
>>>>> >>>
>>>>> >>> any pointers will be appreciated
>>>>> >>>
>>>>> >>> very frustrating and nerve wrecking that we ca't debug cljs sources
>>>>> >>>
>>>>> >>> help!
>>>>> >>>
>>>>> >>> Thank you in advance
>>>>> >>>
>>>>> >>> Marc
>>>>> >>>
>>>>> >>>
>>>>> >>>
>>>>> >>>
>>>>> >>>  --
>>>>> >>> Note that posts from new members are moderated - please be patient
>>>>> with
>>>>> >>> your first post.
>>>>> >>> ---
>>>>> >>> You received this message because you are subscribed to the Google
>>>>> Groups
>>>>> >>> "ClojureScript" group.
>>>>> >>> To unsubscribe from this group and stop receiving emails from it,
>>>>> send an
>>>>> >>> email to [email protected].
>>>>> >>> To post to this group, send email to
>>>>> [email protected].
>>>>> >>> Visit this group at http://groups.google.com/group/clojurescript.
>>>>> >>>
>>>>> >>
>>>>> >>  --
>>>>> >> Note that posts from new members are moderated - please be patient
>>>>> with
>>>>> >> your first post.
>>>>> >> ---
>>>>> >> You received this message because you are subscribed to the Google
>>>>> Groups
>>>>> >> "ClojureScript" group.
>>>>> >> To unsubscribe from this group and stop receiving emails from it,
>>>>> send an
>>>>> >> email to [email protected].
>>>>> >> To post to this group, send email to [email protected]
>>>>> .
>>>>> >> Visit this group at http://groups.google.com/group/clojurescript.
>>>>> >>
>>>>> >
>>>>> > --
>>>>> > Note that posts from new members are moderated - please be patient
>>>>> with your first post.
>>>>> > ---
>>>>> > You received this message because you are subscribed to the Google
>>>>> Groups "ClojureScript" group.
>>>>> > To unsubscribe from this group and stop receiving emails from it,
>>>>> send an email to [email protected].
>>>>> > To post to this group, send email to [email protected].
>>>>> > Visit this group at http://groups.google.com/group/clojurescript.
>>>>>
>>>>> Have you set the :source-map compiler option? With it set to a path,
>>>>> source maps work just fine (in :advanced and :none) for me.
>>>>>
>>>>> --
>>>>> Note that posts from new members are moderated - please be patient
>>>>> with your first post.
>>>>> ---
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "ClojureScript" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> To post to this group, send email to [email protected].
>>>>> Visit this group at http://groups.google.com/group/clojurescript.
>>>>>
>>>>
>>>>  --
>>>> Note that posts from new members are moderated - please be patient with
>>>> your first post.
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "ClojureScript" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To post to this group, send email to [email protected].
>>>> Visit this group at http://groups.google.com/group/clojurescript.
>>>>
>>>
>>>  --
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "ClojureScript" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/clojurescript.
>>>
>>
>>  --
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "ClojureScript" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/clojurescript.
>>
>
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to