I just updated Scittle includes on my project and it working with Cljs-devtools and Dataspex! clojure-spin🔥 Awesome. This is a major ergonomics upgrade. Than @borkdude for scittle growth. Thx @timothypratley for the includes generator.
Here is a little snippet to automatically substitute regular console.log for pprint if it’s not included.
;; Load pprint if available, otherwise use native logging
(try
(do
(require 'cljs.pprint)
(def pprint cljs.pprint/pprint)
(js/console.log "Cljs pprint Loaded"))
(catch js/Error e
(let [error-message (.-message e)]
#_(if (string/includes? error-message "Could not find namespace"))
(def pprint js/console.log) ;; use regular logging fn instead of pprint
(js/console.log "Cljs pprint not found, substitued native logging"))))
I don’t have pprint in production, but was always worried that I might leave a usage of it in the code going to production and that would crash the production deployment.Is there anything special I need to do to enable source maps? Maybe I’m not sure how it’s supposed to work. I’m running all the dev builds. On my browser devtools console, various log statements link to source in the scittle.js file, not my user code.
so the mystery is solved. shadow does produce .map files by default in prod, but it does this for the build report (when it's enabled). but it's not linking them. for this, you still need to enable the compilation option. PR or issue welcome
Makes sense. That's probably what I experienced before and why I made the issue https://github.com/babashka/scittle/issues/114 I have it working locally so can add a PR beginning of next week
Do you see the .map files in the output dir?
And do you see something like //# sourceMappingURL=scittle.core.js.map at the end of the js files?
Oh you are talking about the actual user code / the scittle code?
If you don't have the .map files etc, maybe you are missing :compiler-options {:source-map true} in the shadow-cljs config
Hmm i thought this was already in the Sci, but I don't see it in the shadow-cljs config. But the issue is closed https://github.com/babashka/scittle/issues/114
Ok have to go now. But I'm betting it is the missing compiler option
The map files are the default in shadow. They are included in the npm package
https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/dev/scittle.js.map
also for non-dev: https://cdn.jsdelivr.net/npm/scittle@0.7.28/dist/scittle.js.map
Shadow-cljs config? I’m using the pre-compiled plugins that are hosted on jsdeliver.
I dont see any .js.map references in scittle.js
I’m currently using the scittle-kitchen links. I tried swapping out for the regular scittle.js link. But then the plugins are not found. Apparently the 2 versions of jsdeliver links are not mix-and-match.
I am not understanding what I am supposed to do, or what is supposed to happen.
js source maps setting is enabled in my devtools.
Am i supposed to include somewhere?
Since there is no bundle.js, Is source maps intended to link console messages to my user cljs code?
There are .map files in the scittle kitchen npm repo: https://www.jsdelivr.com/package/npm/scittle-kitchen?tab=files&path=dist%2Fdev
No don’t mix different distributions
If a link takes me to sources like this. Does that mean it’s not working?
I dont see any mention of sourceMappingURL in the scittle.js code
let me try normal scittle to see if source maps work
exceptions are caught by scittle itself normally. how do you get an error to point to scittle itself?
repro plz
ah yes in a timeout:
(js/setTimeout #(assoc :foo :bar :baz) 1)hm yeah no mention of a source map. I'll ask in shadow
https://clojurians.slack.com/archives/C6N245JGG/p1758221192915479
That screen was from the sources tab of devtools, which opens when i click the source link in one of the console log messages. Are source maps supposed to apply there?
I guess so
Thanks!
Can Snitch work in Scittle? https://github.com/AbhinavOmprakash/snitch?tab=readme-ov-file#clojurescript-support
Wow, I thought since it was macro based it might be more of a stretch. Thats encouraging. Will look into it.
Scuttle supports macros much like JVM Clojure
I think it should almost work, except the dependency on cljs.analyzer, but if you ignore that, I don't see any code in there which isn't SCI compatible at first glance.
just replace the ana/macroexpand-1 stuff with regular the regular JVM branch but for scittle using :scittle reader conditional
Scuttle? Scittle damn phone